Idris2Doc : Postgres.Data.PostgresTable

Postgres.Data.PostgresTable

(source)

Reexports

importpublic Data.DPair
importpublic Data.List1
importpublic Data.List.Elem
importpublic Data.Vect.Quantifiers
importpublic Data.String

Definitions

dataIdent : Type
  A Postgres identifier, generally speaking. Could be a table name
or a column name or more broadly speaking any proper name that
Postgres syntactically recognizes between double-quotes.

Totality: total
Visibility: public export
Constructor: 
Id : String->Ident

Hint: 
ShowIdent
dataAlias : Type
  An Alias is a valid table identifier that may either
be a string specified by the programmer or it may be
auto-generated in the course of creating subqueries.

Totality: total
Visibility: public export
Constructors:
Named : String->Alias
Generated : Nat->Alias

Hints:
EqAlias
ShowAlias
aliasIdentifier : Alias->Ident
  Aliases can always be turned into identifiers.

Totality: total
Visibility: public export
toAlias : Ident->Alias
  Turning an identifier into an alias is not inteded to be the lossless
reversal of `aliasIdentifier`. An identifier will always become a named
alias even if it was at one point a generated alias before being turned into
an identifier.

Totality: total
Visibility: public export
dataTableStatement : Type
  A table name or subquery.

Totality: total
Visibility: public export
Constructors:
Identifier : String->MaybeAlias->TableStatement
  A table name.
Subquery : String->Alias->TableStatement
  A subquery.
Fragment : String->TableStatement
  A fragment (can be selected against, but is not named or aliased)

Hint: 
ShowTableStatement
tableAlias : TableStatement->MaybeAlias
Totality: total
Visibility: public export
tableAliasOrName : TableStatement->MaybeIdent
  The table alias or name.

Totality: total
Visibility: public export
named : String-> {defaultNothing_ : MaybeAlias} ->TableStatement
  Construct a table statement for a table with the given name.

Totality: total
Visibility: public export
subquery : String->Alias->TableStatement
  Construct a table statement using a subquery.

Totality: total
Visibility: export
recordColumnIdentifier : Type
  A column is identified by its name and optionally the alias
of a table the column comes from. In some situations the `sourceTable`
for a column will be needed in order to unambiguously refer to one
of a few columns in the same query with the same name.

Generally it will be clunky to create ColumnIdentifiers using the type's
consutrctor directly so most column identifiers will come from string values
because ColumnIdentifier's `FromString` conformance allows Idris 2 to transform
strings into ColumnIdentifiers. This allows for:
- "table1.column1" = MkColumnId (Just $ Named "table1") "column1"
- "column1" = MkColumnId Nothing "column1"

Table aliases here do not necessarily need to refer to a table that has
been given a Postgres alias (a la "(select ...) AS an_alias"). A normal table
or view name is appropriate and can be turned into an alias for use in a column
identifier with the `toAlias` function.

Totality: total
Visibility: public export
Constructor: 
MkColumnId : MaybeAlias->String->ColumnIdentifier

Projections:
.name : ColumnIdentifier->String
.sourceTable : ColumnIdentifier->MaybeAlias

Hints:
FromStringColumnIdentifier
ShowColumnIdentifier
.sourceTable : ColumnIdentifier->MaybeAlias
Totality: total
Visibility: public export
sourceTable : ColumnIdentifier->MaybeAlias
Totality: total
Visibility: public export
.name : ColumnIdentifier->String
Totality: total
Visibility: public export
name : ColumnIdentifier->String
Totality: total
Visibility: public export
replaceSource : MaybeAlias->ColumnIdentifier->ColumnIdentifier
Totality: total
Visibility: public export
forgetSource : ColumnIdentifier->ColumnIdentifier
Totality: total
Visibility: public export
dataAnonymousColumnIdentifier : ColumnIdentifier->Type
Totality: total
Visibility: public export
Constructor: 
Anon : AnonymousColumnIdentifier (MkColumnIdNothing{_:9968})
interfacePostgresTable : Type->Type
  Some representation of a Postgres table.

Parameters: t
Methods:
tableStatement : t->TableStatement
  A table name or subselect statement from which the following columns could be selected.
columns : t->List (ColumnIdentifier, ExistsPColType)
  The columns this table offers. Column names should not include double quotes, even where they
are needed when written down in SQL statements.
as : t->String->t
  Set the alias on a table.

Fixity Declaration: infix operator, level 0

Implementations:
PostgresTableRuntimeTable
PostgresTablePersistedTable
tableStatement : PostgresTablet=>t->TableStatement
  A table name or subselect statement from which the following columns could be selected.

Totality: total
Visibility: public export
columns : PostgresTablet=>t->List (ColumnIdentifier, ExistsPColType)
  The columns this table offers. Column names should not include double quotes, even where they
are needed when written down in SQL statements.

Totality: total
Visibility: public export
as : PostgresTablet=>t->String->t
  Set the alias on a table.

Totality: total
Visibility: public export
Fixity Declaration: infix operator, level 0
alias : PostgresTablet=>t->MaybeAlias
Totality: total
Visibility: export
aliasOrName : PostgresTablet=>t->MaybeAlias
  Get the alias or name of a table; prefer the alias, as a renamed table
_should_ be referred to by its alias, but use the table's original name
if one is available and there is no alias set.

Totality: total
Visibility: public export
recordRuntimeTable : Type
  A runtime representation of a table. These have string fields and table statements so as to not limit
themselves to nominal postgres tables; you can also represent joins naturally where the table statement is
a SELECT with a JOIN instead of just a table's name.

Totality: total
Visibility: public export
Constructor: 
RT : TableStatement->List (ColumnIdentifier, ExistsPColType) ->RuntimeTable

Projections:
.columns : RuntimeTable->List (ColumnIdentifier, ExistsPColType)
.tableStatement : RuntimeTable->TableStatement

Hint: 
PostgresTableRuntimeTable
.tableStatement : RuntimeTable->TableStatement
Totality: total
Visibility: public export
tableStatement : RuntimeTable->TableStatement
Totality: total
Visibility: public export
.columns : RuntimeTable->List (ColumnIdentifier, ExistsPColType)
Totality: total
Visibility: public export
columns : RuntimeTable->List (ColumnIdentifier, ExistsPColType)
Totality: total
Visibility: public export
recordPersistedTable : Type
  A persisted table is an actual named (or view) table in the database.

Totality: total
Visibility: public export
Constructor: 
PT : String-> {defaultNothing_ : MaybeAlias} ->List (String, ExistsPColType) ->PersistedTable

Projections:
.alias : PersistedTable->MaybeAlias
.columns : PersistedTable->List (String, ExistsPColType)
.tableName : PersistedTable->String

Hint: 
PostgresTablePersistedTable
.tableName : PersistedTable->String
Totality: total
Visibility: public export
tableName : PersistedTable->String
Totality: total
Visibility: public export
.alias : PersistedTable->MaybeAlias
Totality: total
Visibility: public export
alias : PersistedTable->MaybeAlias
Totality: total
Visibility: public export
.columns : PersistedTable->List (String, ExistsPColType)
Totality: total
Visibility: public export
columns : PersistedTable->List (String, ExistsPColType)
Totality: total
Visibility: public export
aliasOrName : PersistedTable->Alias
Totality: total
Visibility: public export
col : Nullability->PType->ExistsPColType
  Construct an existential column type from a Postgres type and its
nullability.

Totality: total
Visibility: public export
pgTable : String->List (String, (Nullability, PType)) ->PersistedTable
  Construct a persisted table representation (a table name and the names,
types, and nullabilities of the columns of a table.)

```idris example
myTable = table "table1" [ ("id" , NonNullable, PInteger)
, ("name" , NonNullable, PString)
, ("favorite_color", Nullable , PString)
]
```

Totality: total
Visibility: public export
dataLooseColumnMapping : (0_ : (PType->Type->Type)) ->List (ColumnIdentifier, ExistsPColType) -> (ColumnIdentifier, Type) ->Type
  A mapping between a column name and Idris type to some element in a list of column identifiers
and Postgres types. This mapping proves that the column identifiers exists and that the Postgres
type for that column can be cast to the Idris type specified. This mapping allows for "loose"
matches where the ColumnIdentifier being matched against does not specify a source table but the
column name can be found in the list of columns given. Loose matching is only ok if the match would
not succeed against multiple columns (Postgres will complain of ambiguity, for good reason). Use the
ColumnMapping type to avoid loose matches.

Totality: total
Visibility: public export
Constructors:
HereNul : (ident : ColumnIdentifier) -> (ty : Type) ->castTyptty=>LooseColumnMappingcastTy ((ident, Evidencept (MkColTypeNullablept)) ::xs) (ident, Maybety)
HereNulLoose : (columnName : String) -> (ty : Type) ->castTyptty=>LooseColumnMappingcastTy ((MkColumnId{_:10677}columnName, Evidencept (MkColTypeNullablept)) ::xs) (MkColumnIdNothingcolumnName, Maybety)
Here : (ident : ColumnIdentifier) -> (ty : Type) ->castTyptty=>LooseColumnMappingcastTy ((ident, Evidencept (MkColTypeNonNullablept)) ::xs) (ident, ty)
HereLoose : (columnName : String) -> (ty : Type) ->castTyptty=>LooseColumnMappingcastTy ((MkColumnId{_:10764}columnName, Evidencept (MkColTypeNonNullablept)) ::xs) (MkColumnIdNothingcolumnName, ty)
There : LooseColumnMappingcastTyxs (ident, ty) ->LooseColumnMappingcastTy (x::xs) (ident, ty)
HasLooseMappings : (0_ : (PType->Type->Type)) ->PostgresTablet=>t->Vectn (ColumnIdentifier, Type) ->Type
Totality: total
Visibility: public export
dataColumnMapping : (0_ : (PType->Type->Type)) ->List (ColumnIdentifier, ExistsPColType) -> (ColumnIdentifier, Type) ->Type
  A mapping between a column name and Idris type to some element in a list of column identifiers
and Postgres types. This mapping proves that the column identifiers exists and that the Postgres
type for that column can be cast to the Idris type specified.

Totality: total
Visibility: public export
Constructors:
HereNul : (ident : ColumnIdentifier) -> (ty : Type) ->castTyptty=>ColumnMappingcastTy ((ident, Evidencept (MkColTypeNullablept)) ::xs) (ident, Maybety)
Here : (ident : ColumnIdentifier) -> (ty : Type) ->castTyptty=>ColumnMappingcastTy ((ident, Evidencept (MkColTypeNonNullablept)) ::xs) (ident, ty)
There : ColumnMappingcastTyxs (ident, ty) ->ColumnMappingcastTy (x::xs) (ident, ty)
HasMappings : (0_ : (PType->Type->Type)) ->PostgresTablet=>t->Vectn (ColumnIdentifier, Type) ->Type
Totality: total
Visibility: public export
select : {auto{conArg:11210} : PostgresTablet} -> (table : t) -> (cols : Vectn (ColumnIdentifier, Type)) -> {auto0_ : HasMappingsIdrCasttablecols} ->String
  Create a select statement based on the columns you would like to grab from the
given table.

Totality: total
Visibility: public export
insert : (table : PersistedTable) -> (cols : VectnColumnIdentifier) ->HVectcolTypes->HasLooseMappingsPGCasttable (cols `zip` colTypes) =>String
  Insert the given values into the given columns of a new row in the given table.

Totality: total
Visibility: public export
dataJoin : t1->t2->Type
Totality: total
Visibility: public export
Constructor: 
On : {auto{conArg:11507} : PostgresTablet} -> {auto{conArg:11510} : PostgresTableu} -> (c1 : ColumnIdentifier) -> (c2 : ColumnIdentifier) -> {auto0_ : Elemc1 (fst<$>columnst1)} -> {auto0_ : Elemc2 (fst<$>columnst2)} ->Joint1t2
HasOnMapping : ColumnIdentifier->PostgresTablet=>t->Type
Totality: total
Visibility: public export
elemForOnMapping : {auto{conArg:11617} : PostgresTablet} -> (table : t) -> (c : ColumnIdentifier) ->HasOnMappingctable-> (c' : ColumnIdentifier**Elemc' (fst<$>columnstable))
Totality: total
Visibility: public export
(==) : {auto{conArg:11687} : PostgresTablet} -> {auto{conArg:11690} : PostgresTableu} -> (c1 : ColumnIdentifier) -> (c2 : ColumnIdentifier) ->HasOnMappingc1t1=>HasOnMappingc2t2=>Joint1t2
  In a join-statement, produce the clause that links the two tables together by
a shared column. In pseudo-code: "table1 join table2 'on' col1 = col2".

```idris example
innerJoin' table1 table2 ("col_from_table1" == "col_from_table2")
```

Totality: total
Visibility: public export
Fixity Declaration: infix operator, level 6
column1 : Jointu->ColumnIdentifier
Totality: total
Visibility: public export
column2 : Jointu->ColumnIdentifier
Totality: total
Visibility: public export
innerJoin' : PostgresTablet=> (table1 : t) ->PostgresTableu=> (table2 : u) ->Jointable1table2->RuntimeTable
  Construct a runtime table by inner-joining two other tables on a specified column.

```idris example
innerJoin' table1 table2 ("col_from_table1" == "col_from_table2")
```

Totality: total
Visibility: public export
leftJoin' : PostgresTablet=> (table1 : t) ->PostgresTableu=> (table2 : u) ->Jointable1table2->RuntimeTable
  Construct a runtime table by left-joining two other tables on a specified column.

```idris example
leftJoin' table1 table2 ("col_from_table1" == "col_from_table2")
```

Totality: total
Visibility: public export
rightJoin' : PostgresTablet=> (table1 : t) ->PostgresTableu=> (table2 : u) ->Jointable1table2->RuntimeTable
  Construct a runtime table by right-joining two other tables on a specified column.

```idris example
rightJoin' table1 table2 ("col_from_table1" == "col_from_table2")
```

Totality: total
Visibility: public export
dataJoinType : Type
Totality: total
Visibility: public export
Constructors:
Inner : JoinType
Left : JoinType
Right : JoinType
dataTablePair : table1->table2->Type
Totality: total
Visibility: public export
Constructor: 
MkTP : JoinType->PostgresTablet=>PostgresTableu=> (table1 : t) -> (table2 : u) ->TablePairtable1table2
innerJoin : PostgresTablet=>PostgresTableu=> (table1 : t) -> (table2 : u) ->TablePairtable1table2
  Inner-join two tables.
This produces a pair of tables and a join strategy. You then need to use `onColumns` to take the table pair
and add the columns that the join should occur over.

Totality: total
Visibility: public export
Fixity Declaration: infixl operator, level 10
leftJoin : PostgresTablet=>PostgresTableu=> (table1 : t) -> (table2 : u) ->TablePairtable1table2
  Left-join two tables.
This produces a pair of tables and a join strategy. You then need to use `onColumns` to take the table pair
and add the columns that the join should occur over.

Totality: total
Visibility: public export
Fixity Declaration: infixl operator, level 10
rightJoin : PostgresTablet=>PostgresTableu=> (table1 : t) -> (table2 : u) ->TablePairtable1table2
  Right-join two tables.
This produces a pair of tables and a join strategy. You then need to use `onColumns` to take the table pair
and add the columns that the join should occur over.

Totality: total
Visibility: public export
Fixity Declaration: infixl operator, level 10
onColumns : TablePairtable1table2->Jointable1table2->RuntimeTable
  Given that you've already paired two tables up (see `innerJoin`, `leftJoin`, `rightJoin`)
you use `onColumns` to specify which columns from each table in the pair should be equal
in the joined table. The end result is a new table.

Psuedo-example:
table1 `innerJoin` table2 `onColumns` ("table1.col1" == "table2.col2")

Totality: total
Visibility: public export
Fixity Declaration: infixl operator, level 10
allCastable : {auto{conArg:12589} : PostgresTablet} -> (table : t) ->HasMappingsIdrCasttablecols=>AllCastable (snd<$>cols)
Totality: total
Visibility: export