| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.PostgreSQL.Tx.Squeal.Internal.Reexport
Synopsis
- class IsLabel (x :: Symbol) a where
- fromLabel :: a
- (>>>) :: forall k cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c
- (&) :: a -> (a -> b) -> b
- newtype ExceptT e (m :: Type -> Type) a = ExceptT (m (Either e a))
- data Path (p :: k -> k -> Type) (x :: k) (y :: k) where
- data IsoQ (c :: k -> k -> Type) (x :: k) (y :: k) = IsoQ {}
- newtype K a (b :: k) = K a
- unK :: forall k a (b :: k). K a b -> a
- data NP (a :: k -> Type) (b :: [k]) where
- newtype StateT s (m :: Type -> Type) a = StateT {
- runStateT :: s -> m (a, s)
- data Oid
- data ExecStatus
- data Connection
- commentOnSchema :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (KnownSymbol sch, Has sch db schema) => Alias sch -> Text -> Definition db db
- commentOnColumn :: forall (sch :: Symbol) (tab :: Symbol) (col :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (cons :: TableConstraints) (cols :: ColumnsType) (def :: Optionality) (nulltyp :: NullType). (KnownSymbol sch, KnownSymbol tab, KnownSymbol col, Has sch db schema, Has tab schema ('Table '(cons, cols)), Has col cols '(def, nulltyp)) => QualifiedAlias sch tab -> Alias col -> Text -> Definition db db
- commentOnFunction :: forall (sch :: Symbol) (fun :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (function :: FunctionType). (KnownSymbol sch, KnownSymbol fun, Has sch db schema, Has fun schema ('Function function)) => QualifiedAlias sch fun -> Text -> Definition db db
- commentOnIndex :: forall (sch :: Symbol) (ind :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (index :: IndexType). (KnownSymbol sch, KnownSymbol ind, Has sch db schema, Has ind schema ('Index index)) => QualifiedAlias sch ind -> Text -> Definition db db
- commentOnView :: forall (sch :: Symbol) (vie :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (view :: RowType). (KnownSymbol sch, KnownSymbol vie, Has sch db schema, Has vie schema ('View view)) => QualifiedAlias sch vie -> Text -> Definition db db
- commentOnType :: forall (sch :: Symbol) (typ :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (type_ :: PGType). (KnownSymbol sch, KnownSymbol typ, Has sch db schema, Has typ schema ('Typedef type_)) => QualifiedAlias sch typ -> Text -> Definition db db
- commentOnTable :: forall (sch :: Symbol) (tab :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (table :: TableType). (KnownSymbol sch, KnownSymbol tab, Has sch db schema, Has tab schema ('Table table)) => QualifiedAlias sch tab -> Text -> Definition db db
- dropFunctionIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol). (Has sch db schema, KnownSymbol fun) => QualifiedAlias sch fun -> Definition db (Alter sch (DropSchemumIfExists fun 'Function schema) db)
- dropFunction :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol). (Has sch db schema, KnownSymbol fun) => QualifiedAlias sch fun -> Definition db (Alter sch (DropSchemum fun 'Function schema) db)
- createOrReplaceSetFunction :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (rets :: [(Symbol, NullType)]). (Has sch db schema, KnownSymbol fun, SListI args, SListI rets) => QualifiedAlias sch fun -> NP (TypeExpression db) args -> NP (Aliased (TypeExpression db)) rets -> FunctionDefinition db args ('ReturnsTable rets) -> Definition db (Alter sch (CreateOrReplace fun ('Function (args :=> 'ReturnsTable rets)) schema) db)
- createSetFunction :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (rets :: [(Symbol, NullType)]). (Has sch db schema, KnownSymbol fun, SListI args, SListI rets) => QualifiedAlias sch fun -> NP (TypeExpression db) args -> NP (Aliased (TypeExpression db)) rets -> FunctionDefinition db args ('ReturnsTable rets) -> Definition db (Alter sch (Create fun ('Function (args :=> 'ReturnsTable rets)) schema) db)
- languageSqlQuery :: forall (db :: SchemasType) (args :: [NullType]) (rets :: RowType). Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db args rets -> FunctionDefinition db args ('ReturnsTable rets)
- languageSqlExpr :: forall (db :: SchemasType) (args :: [NullType]) (ret :: NullType). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db args ('[] :: [(Symbol, RowType)]) ret -> FunctionDefinition db args ('Returns ret)
- createOrReplaceFunction :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (ret :: NullType). (Has sch db schema, KnownSymbol fun, SListI args) => QualifiedAlias sch fun -> NP (TypeExpression db) args -> TypeExpression db ret -> FunctionDefinition db args ('Returns ret) -> Definition db (Alter sch (CreateOrReplace fun ('Function (args :=> 'Returns ret)) schema) db)
- createFunction :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (ret :: NullType). (Has sch db schema, KnownSymbol fun, SListI args) => QualifiedAlias sch fun -> NP (TypeExpression db) args -> TypeExpression db ret -> FunctionDefinition db args ('Returns ret) -> Definition db (Alter sch (Create fun ('Function (args :=> 'Returns ret)) schema) db)
- newtype FunctionDefinition (db :: k) (args :: k1) (ret :: k2) = UnsafeFunctionDefinition {}
- dropIndexIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (ix :: Symbol). (Has sch db schema, KnownSymbol ix) => QualifiedAlias sch ix -> Definition db (Alter sch (DropSchemumIfExists ix 'Index schema) db)
- dropIndex :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (ix :: Symbol). (Has sch db schema, KnownSymbol ix) => QualifiedAlias sch ix -> Definition db (Alter sch (DropSchemum ix 'Index schema) db)
- brin :: IndexMethod 'Brin
- gin :: IndexMethod 'Gin
- spgist :: IndexMethod 'Spgist
- gist :: IndexMethod 'Gist
- hash :: IndexMethod 'Hash
- btree :: IndexMethod 'Btree
- createIndexIfNotExists :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (ix :: Symbol) (method :: IndexType). (Has sch db schema, Has tab schema ('Table table), KnownSymbol ix) => Alias ix -> QualifiedAlias sch tab -> IndexMethod method -> [SortExpression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: TableToRow table]] -> Definition db (Alter sch (CreateIfNotExists ix ('Index method) schema) db)
- createIndex :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (ix :: Symbol) (method :: IndexType). (Has sch db schema, Has tab schema ('Table table), KnownSymbol ix) => Alias ix -> QualifiedAlias sch tab -> IndexMethod method -> [SortExpression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: TableToRow table]] -> Definition db (Alter sch (Create ix ('Index method) schema) db)
- newtype IndexMethod (ty :: k) = UnsafeIndexMethod {}
- dropProcedureIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol). (Has sch db schema, KnownSymbol pro) => QualifiedAlias sch pro -> Definition db (Alter sch (DropSchemumIfExists pro 'Procedure schema) db)
- dropProcedure :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol). (Has sch db schema, KnownSymbol pro) => QualifiedAlias sch pro -> Definition db (Alter sch (DropSchemum pro 'Procedure schema) db)
- languageSqlManipulation :: forall (db :: SchemasType) (args :: [NullType]). [Manipulation ('[] :: [(Symbol, RowType)]) db args ('[] :: [(Symbol, NullType)])] -> ProcedureDefinition db args
- createOrReplaceProcedure :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol) (args :: [NullType]). (Has sch db schema, KnownSymbol pro, SListI args) => QualifiedAlias sch pro -> NP (TypeExpression db) args -> ProcedureDefinition db args -> Definition db (Alter sch (CreateOrReplace pro ('Procedure args) schema) db)
- createProcedure :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol) (args :: [NullType]). (Has sch db schema, KnownSymbol pro, SListI args) => QualifiedAlias sch pro -> NP (TypeExpression db) args -> ProcedureDefinition db args -> Definition db (Alter sch (Create pro ('Procedure args) schema) db)
- newtype ProcedureDefinition (db :: k) (args :: k1) = UnsafeProcedureDefinition {}
- dropSchemaCascadeIfExists :: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch => Alias sch -> Definition db (DropIfExists sch db)
- dropSchemaCascade :: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch => Alias sch -> Definition db (Drop sch db)
- createSchemaIfNotExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (KnownSymbol sch, Has sch db schema) => Alias sch -> Definition db (CreateIfNotExists sch ('[] :: [(Symbol, SchemumType)]) db)
- createSchema :: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch => Alias sch -> Definition db (Create sch ('[] :: [(Symbol, SchemumType)]) db)
- mainMigrateIso :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory (IsoQ def) (IsoQ (Indexed PQ IO ())) => ByteString -> Path (Migration (IsoQ def)) db0 db1 -> IO ()
- mainMigrate :: forall (p :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory p (Indexed PQ IO ()) => ByteString -> Path (Migration p) db0 db1 -> IO ()
- migrateDown :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (IsoQ (Indexed PQ IO ())) => Path (Migration def) db0 db1 -> PQ db1 db0 IO ()
- migrateUp :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (IsoQ (Indexed PQ IO ())) => Path (Migration def) db0 db1 -> PQ db0 db1 IO ()
- migrate :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (Indexed PQ IO ()) => Path (Migration def) db0 db1 -> PQ db0 db1 IO ()
- data Migration (def :: k -> k1 -> Type) (db0 :: k) (db1 :: k1) = Migration {
- migrationName :: Text
- migrationDef :: def db0 db1
- class (Category def, Category run) => Migratory (def :: k -> k -> Type) (run :: k -> k -> Type) | def -> run where
- runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration def) db0 db1 -> run db0 db1
- type MigrationsTable = '["migrations_unique_name" ::: 'Unique '["name"]] :=> '["name" ::: ('NoDef :=> 'NotNull 'PGtext), "executed_at" ::: ('Def :=> 'NotNull 'PGtimestamptz)]
- alterType :: forall (db :: SchemasType) (ty :: ColumnType) (ty0 :: ColumnType). ColumnTypeExpression db ty -> AlterColumn db ty0 ty
- dropNotNull :: forall (db :: SchemasType) (constraint :: Optionality) (ty :: PGType). AlterColumn db (constraint :=> 'NotNull ty) (constraint :=> 'Null ty)
- setNotNull :: forall (db :: SchemasType) (constraint :: Optionality) (ty :: PGType). AlterColumn db (constraint :=> 'Null ty) (constraint :=> 'NotNull ty)
- dropDefault :: forall (db :: SchemasType) (ty :: NullType). AlterColumn db ('Def :=> ty) ('NoDef :=> ty)
- setDefault :: forall (db :: SchemasType) (ty :: NullType) (constraint :: Optionality). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, RowType)]) ty -> AlterColumn db (constraint :=> ty) ('Def :=> ty)
- alterColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType) (ty0 :: ColumnType) (ty1 :: ColumnType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns)), Has column columns ty0) => Alias column -> AlterColumn db ty0 ty1 -> AlterTable sch tab db (constraints :=> Alter column ty1 columns)
- renameColumn :: forall (column0 :: Symbol) (column1 :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column0, KnownSymbol column1, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column0 -> Alias column1 -> AlterTable sch tab db (constraints :=> Rename column0 column1 columns)
- dropColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> AlterTable sch tab db (constraints :=> Drop column columns)
- dropConstraint :: forall (constraint :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol constraint, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias constraint -> AlterTable sch tab db (Drop constraint constraints :=> columns)
- addConstraint :: forall (alias :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType) (constraint :: TableConstraint). (KnownSymbol alias, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias alias -> TableConstraintExpression sch tab db constraint -> AlterTable sch tab db (Create alias constraint constraints :=> columns)
- alterTableSetSchema :: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has tab schema0 ('Table table), Has sch1 db schema1) => QualifiedAlias sch0 tab -> Alias sch1 -> Definition db (SetSchema sch0 sch1 schema0 schema1 tab 'Table table db)
- alterTableIfExistsRename :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab0 :: Symbol) (tab1 :: Symbol). (Has sch db schema, KnownSymbol tab0, KnownSymbol tab1) => QualifiedAlias sch tab0 -> Alias tab1 -> Definition db (Alter sch (RenameIfExists tab0 tab1 schema) db)
- alterTableRename :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab1 :: Symbol) (tab0 :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab1, Has tab0 schema ('Table table)) => QualifiedAlias sch tab0 -> Alias tab1 -> Definition db (Alter sch (Rename tab0 tab1 schema) db)
- alterTableIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab) => QualifiedAlias sch tab -> AlterTable sch tab db table -> Definition db (Alter sch (AlterIfExists tab ('Table table) schema) db)
- alterTable :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab) => QualifiedAlias sch tab -> AlterTable sch tab db table -> Definition db (Alter sch (Alter tab ('Table table) schema) db)
- dropTableIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol). (Has sch db schema, KnownSymbol tab) => QualifiedAlias sch tab -> Definition db (Alter sch (DropSchemumIfExists tab 'Table schema) db)
- dropTable :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol). (Has sch db schema, KnownSymbol tab) => QualifiedAlias sch tab -> Definition db (Alter sch (DropSchemum tab 'Table schema) db)
- createTableIfNotExists :: forall (sch :: Symbol) (tab :: Symbol) (columns :: [(Symbol, ColumnType)]) (col :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (constraints :: [(Symbol, TableConstraint)]) (db0 :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (db1 :: [(Symbol, [(Symbol, SchemumType)])]). (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch db0 schema0, db1 ~ Alter sch (CreateIfNotExists tab ('Table (constraints :=> columns)) schema0) db0) => QualifiedAlias sch tab -> NP (Aliased (ColumnTypeExpression db0)) columns -> NP (Aliased (TableConstraintExpression sch tab db1)) constraints -> Definition db0 db1
- createTable :: forall (sch :: Symbol) (tab :: Symbol) (columns :: [(Symbol, ColumnType)]) (col :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (constraints :: [(Symbol, TableConstraint)]) (db0 :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (db1 :: [(Symbol, [(Symbol, SchemumType)])]). (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch db0 schema0, db1 ~ Alter sch (Create tab ('Table (constraints :=> columns)) schema0) db0) => QualifiedAlias sch tab -> NP (Aliased (ColumnTypeExpression db0)) columns -> NP (Aliased (TableConstraintExpression sch tab db1)) constraints -> Definition db0 db1
- newtype AlterTable (sch :: Symbol) (tab :: Symbol) (db :: SchemasType) (table :: TableType) = UnsafeAlterTable {}
- class AddColumn (ty :: ColumnType) where
- addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ty -> AlterTable sch tab db (constraints :=> Create column ty columns)
- newtype AlterColumn (db :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) = UnsafeAlterColumn {}
- alterTypeSetSchema :: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (ty :: Symbol) (td :: PGType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has ty schema0 ('Typedef td), Has sch1 db schema1) => QualifiedAlias sch0 ty -> Alias sch1 -> Definition db (SetSchema sch0 sch1 schema0 schema1 ty 'Typedef td db)
- alterTypeRename :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (ty1 :: Symbol) (ty0 :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol ty1, Has ty0 schema ('Typedef ty)) => QualifiedAlias sch ty0 -> Alias ty1 -> Definition db (Alter sch (Rename ty0 ty1 schema) db)
- dropTypeIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (td :: Symbol). (Has sch db schema, KnownSymbol td) => QualifiedAlias sch td -> Definition db (Alter sch (DropSchemumIfExists td 'Typedef schema) db)
- dropType :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (td :: Symbol). (Has sch db schema, KnownSymbol td) => QualifiedAlias sch td -> Definition db (Alter sch (DropSchemum td 'Typedef schema) db)
- createTypeRange :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (range :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol range) => QualifiedAlias sch range -> (forall (null :: PGType -> NullType). TypeExpression db (null ty)) -> Definition db (Alter sch (Create range ('Typedef ('PGrange ty)) schema) db)
- createDomain :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (dom :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol dom) => QualifiedAlias sch dom -> (forall (null :: PGType -> NullType). TypeExpression db (null ty)) -> (forall (tab :: Symbol). Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: '["value" ::: 'Null ty]]) -> Definition db (Alter sch (Create dom ('Typedef ty) schema) db)
- createTypeCompositeFrom :: forall hask (sch :: Symbol) (ty :: Symbol) (db :: SchemasType) (schema :: SchemaType). (All (FieldTyped db) (RowPG hask), KnownSymbol ty, Has sch db schema) => QualifiedAlias sch ty -> Definition db (Alter sch (Create ty ('Typedef (PG (Composite hask))) schema) db)
- createTypeComposite :: forall (ty :: Symbol) (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fields :: [(Symbol, NullType)]). (KnownSymbol ty, Has sch db schema, SListI fields) => QualifiedAlias sch ty -> NP (Aliased (TypeExpression db)) fields -> Definition db (Alter sch (Create ty ('Typedef ('PGcomposite fields)) schema) db)
- createTypeEnumFrom :: forall hask (sch :: Symbol) (enum :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (Generic hask, All KnownSymbol (LabelsPG hask), KnownSymbol enum, Has sch db schema) => QualifiedAlias sch enum -> Definition db (Alter sch (Create enum ('Typedef (PG (Enumerated hask))) schema) db)
- createTypeEnum :: forall (enum :: Symbol) (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (labels :: [Symbol]). (KnownSymbol enum, Has sch db schema, All KnownSymbol labels) => QualifiedAlias sch enum -> NP PGlabel labels -> Definition db (Alter sch (Create enum ('Typedef ('PGenum labels)) schema) db)
- alterViewSetSchema :: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has vw schema0 ('View view), Has sch1 db schema1) => QualifiedAlias sch0 vw -> Alias sch1 -> Definition db (SetSchema sch0 sch1 schema0 schema1 vw 'View view db)
- alterViewRename :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (ty1 :: Symbol) (ty0 :: Symbol) (vw :: RowType). (Has sch db schema, KnownSymbol ty1, Has ty0 schema ('View vw)) => QualifiedAlias sch ty0 -> Alias ty1 -> Definition db (Alter sch (Rename ty0 ty1 schema) db)
- dropViewIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol). (Has sch db schema, KnownSymbol vw) => QualifiedAlias sch vw -> Definition db (Alter sch (DropIfExists vw schema) db)
- dropView :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol). (Has sch db schema, KnownSymbol vw) => QualifiedAlias sch vw -> Definition db (Alter sch (DropSchemum vw 'View schema) db)
- createOrReplaceView :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol) (view :: RowType). (Has sch db schema, KnownSymbol vw) => QualifiedAlias sch vw -> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) view -> Definition db (Alter sch (CreateOrReplace vw ('View view) schema) db)
- createView :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol) (view :: RowType). (Has sch db schema, KnownSymbol vw) => QualifiedAlias sch vw -> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) view -> Definition db (Alter sch (Create vw ('View view) schema) db)
- destroyConnectionPool :: forall k io (db :: k). MonadUnliftIO io => Pool (K Connection db) -> io ()
- usingConnectionPool :: forall io (db :: SchemasType) x. MonadUnliftIO io => Pool (K Connection db) -> PQ db db io x -> io x
- createConnectionPool :: forall (db :: SchemasType) io. MonadUnliftIO io => ByteString -> Int -> NominalDiffTime -> Int -> io (Pool (K Connection db))
- withConnection :: forall (db0 :: SchemasType) (db1 :: SchemasType) io x. MonadUnliftIO io => ByteString -> PQ db0 db1 io x -> io x
- evalPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m x
- execPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m (K Connection db1)
- runPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m (x, K Connection db1)
- newtype PQ (db0 :: SchemasType) (db1 :: SchemasType) (m :: Type -> Type) x = PQ {
- unPQ :: K Connection db0 -> m (K x db1)
- indexedDefine :: forall (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). (IndexedMonadTransPQ pq, MonadIO io) => Definition db0 db1 -> Indexed pq io () db0 db1
- class (forall (i :: k) (j :: k) (m :: Type -> Type). Monad m => Functor (t i j m), forall (i :: k) (j :: k) (m :: Type -> Type). (i ~ j, Monad m) => Monad (t i j m), forall (i :: k) (j :: k). i ~ j => MonadTrans (t i j)) => IndexedMonadTrans (t :: k -> k -> (Type -> Type) -> Type -> Type) where
- pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => t i j m (x -> y) -> t j k1 m x -> t i k1 m y
- pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => t i j m (t j k1 m y) -> t i k1 m y
- pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> t j k1 m y) -> t i j m x -> t i k1 m y
- pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => t j k1 m y -> t i j m x -> t i k1 m y
- pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> t j k1 m z) -> (x -> t i j m y) -> x -> t i k1 m z
- newtype Indexed (t :: k -> k1 -> k2 -> k3 -> Type) (m :: k2) (r :: k3) (i :: k) (j :: k1) = Indexed {
- runIndexed :: t i j m r
- class IndexedMonadTrans pq => IndexedMonadTransPQ (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) where
- define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> pq db0 db1 io ()
- manipulation_ :: forall (db :: SchemasType). Manipulation ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, NullType)]) -> Definition db db
- newtype Definition (db0 :: SchemasType) (db1 :: SchemasType) = UnsafeDefinition {}
- foreignKey :: forall (db :: [(Symbol, [(Symbol, SchemumType)])]) (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, SchemumType)]) (schema1 :: [(Symbol, SchemumType)]) (child :: Symbol) (parent :: Symbol) (table :: TableType) (reftable :: TableType) (columns :: [Symbol]) (refcolumns :: [Symbol]) (constraints :: TableConstraints) (cols :: ColumnsType) (reftys :: [(Symbol, ColumnType)]) (tys :: [(Symbol, ColumnType)]). ForeignKeyed db sch0 sch1 schema0 schema1 child parent table reftable columns refcolumns constraints cols reftys tys => NP Alias columns -> QualifiedAlias sch0 parent -> NP Alias refcolumns -> OnDeleteClause -> OnUpdateClause -> TableConstraintExpression sch1 child db ('ForeignKey columns sch0 parent refcolumns)
- primaryKey :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, ColumnType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToColumns table) subcolumns, AllNotNull subcolumns) => NP Alias aliases -> TableConstraintExpression sch tab db ('PrimaryKey aliases)
- unique :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, NullType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToRow table) subcolumns) => NP Alias aliases -> TableConstraintExpression sch tab db ('Unique aliases)
- check :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, NullType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToRow table) subcolumns) => NP Alias aliases -> (forall (t :: Symbol). Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[t ::: subcolumns]) -> TableConstraintExpression sch tab db ('Check aliases)
- newtype TableConstraintExpression (sch :: Symbol) (tab :: Symbol) (db :: SchemasType) (constraint :: TableConstraint) = UnsafeTableConstraintExpression {}
- type ForeignKeyed (db :: [(Symbol, [(Symbol, SchemumType)])]) (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, SchemumType)]) (schema1 :: [(Symbol, SchemumType)]) (child :: Symbol) (parent :: Symbol) (table :: TableType) (reftable :: TableType) (columns :: [Symbol]) (refcolumns :: [Symbol]) (constraints :: TableConstraints) (cols :: ColumnsType) (reftys :: [(Symbol, ColumnType)]) (tys :: [(Symbol, ColumnType)]) = (Has sch0 db schema0, Has sch1 db schema1, Has parent schema0 ('Table reftable), Has child schema1 ('Table table), HasAll columns (TableToColumns table) tys, reftable ~ (constraints :=> cols), HasAll refcolumns cols reftys, AllZip SamePGType tys reftys, Uniquely refcolumns constraints)
- newtype OnDeleteClause = OnDelete ReferentialAction
- newtype OnUpdateClause = OnUpdate ReferentialAction
- data ReferentialAction
- = NoAction
- | Restrict
- | Cascade
- | SetNull
- | SetDefault
- callN :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (xs :: [NullType]) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has pro schema ('Procedure xs), SListI xs) => QualifiedAlias sch pro -> NP (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])) xs -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- unsafeCallN :: forall (xs :: [NullType]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI xs => ByteString -> NP (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])) xs -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- call :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (x :: NullType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has pro schema ('Procedure '[x])) => QualifiedAlias sch pro -> Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]) x -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- unsafeCall :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (x :: NullType). ByteString -> Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]) x -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- deleteFrom_ :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table)) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table] -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- deleteFrom :: forall (row :: [(Symbol, NullType)]) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI row, Has sch db schema, Has tab0 schema ('Table table)) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> UsingClause with db params from -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from) -> ReturningClause with db params ((tab ::: TableToRow table) ': from) row -> Manipulation with db params row
- inlineValues :: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) => hask -> [hask] -> QueryClause with db params columns
- inlineValues_ :: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) => hask -> QueryClause with db params columns
- insertInto_ :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), SListI (TableToColumns table)) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> QueryClause with db params (TableToColumns table) -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- insertInto :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (row :: [(Symbol, NullType)]) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), SListI (TableToColumns table), SListI row) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> QueryClause with db params (TableToColumns table) -> ConflictClause tab with db params table -> ReturningClause with db params '[tab ::: TableToRow table] row -> Manipulation with db params row
- pattern Values_ :: forall columns with db params (from :: FromType). SListI columns => NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from))) columns -> QueryClause with db params columns
- data QueryClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: [(Symbol, (Optionality, NullType))]) where
- Values :: forall (columns :: [(Symbol, (Optionality, NullType))]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). SListI columns => NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from))) columns -> [NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from))) columns] -> QueryClause with db params columns
- Select :: forall (columns :: [(Symbol, (Optionality, NullType))]) (grp :: Grouping) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). SListI columns => NP (Aliased (Optional (Expression grp ('[] :: [(Symbol, RowType)]) with db params from))) columns -> TableExpression grp ('[] :: [(Symbol, RowType)]) with db params from -> QueryClause with db params columns
- Subquery :: forall (columns :: [(Symbol, (Optionality, NullType))]) (row :: RowType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). ColumnsToRow columns ~ row => Query ('[] :: [(Symbol, RowType)]) with db params row -> QueryClause with db params columns
- data ConflictClause (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: ([(Symbol, TableConstraint)], ColumnsType)) where
- OnConflictDoRaise :: forall (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: ([(Symbol, TableConstraint)], ColumnsType)). ConflictClause tab with db params table
- OnConflict :: forall (table :: ([(Symbol, TableConstraint)], ColumnsType)) (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]). ConflictTarget table -> ConflictAction tab with db params table -> ConflictClause tab with db params table
- data ConflictAction (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: TableType) where
- DoNothing :: forall (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: TableType). ConflictAction tab with db params table
- DoUpdate :: forall (row :: RowType) (table :: TableType) (from :: [(Symbol, RowType)]) (tab :: Symbol) (updates :: [(Symbol, (Optionality, NullType))]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (row ~ TableToRow table, from ~ '[tab ::: row, "excluded" ::: row], Updatable table updates) => NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from))) updates -> [Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from] -> ConflictAction tab with db params table
- data ConflictTarget (table :: ([(Symbol, kind)], k)) where
- OnConstraint :: forall kind k (con :: Symbol) (constraints :: [(Symbol, kind)]) (constraint :: kind) (columns :: k). Has con constraints constraint => Alias con -> ConflictTarget '(constraints, columns)
- update_ :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (updates :: [(Symbol, (Optionality, NullType))]) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), KnownSymbol tab, Updatable table updates) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table]))) updates -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table] -> Manipulation with db params ('[] :: [(Symbol, NullType)])
- update :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (updates :: [(Symbol, (Optionality, NullType))]) (row :: [(Symbol, NullType)]) (tab :: Symbol) (with :: FromType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (Has sch db schema, Has tab0 schema ('Table table), Updatable table updates, SListI row) => Aliased (QualifiedAlias sch) (tab ::: tab0) -> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from)))) updates -> UsingClause with db params from -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from) -> ReturningClause with db params ((tab ::: TableToRow table) ': from) row -> Manipulation with db params row
- longRunningMode :: TransactionMode
- defaultMode :: TransactionMode
- rollback :: forall (db :: SchemasType). Manipulation_ db () ()
- commit :: forall (db :: SchemasType). Manipulation_ db () ()
- begin :: forall (db :: SchemasType). TransactionMode -> Manipulation_ db () ()
- data TransactionMode = TransactionMode {}
- data IsolationLevel
- data AccessMode
- data DeferrableMode
- class Monad pq => MonadPQ (db :: SchemasType) (pq :: Type -> Type) | pq -> db
- manipulation :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (GenericParams db params x xs, GenericRow row y ys) => Manipulation ('[] :: [(Symbol, RowType)]) db params row -> Statement db x y
- query :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (GenericParams db params x xs, GenericRow row y ys) => Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db params row -> Statement db x y
- data Statement (db :: SchemasType) x y where
- Manipulation :: forall (db :: SchemasType) (params :: [NullType]) (row :: [(Symbol, NullType)]) x y. (All (OidOfNull db) params, SListI row) => EncodeParams db params x -> DecodeRow row y -> Manipulation ('[] :: [(Symbol, RowType)]) db params row -> Statement db x y
- Query :: forall (db :: SchemasType) (params :: [NullType]) (row :: [(Symbol, NullType)]) x y. (All (OidOfNull db) params, SListI row) => EncodeParams db params x -> DecodeRow row y -> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db params row -> Statement db x y
- type GenericParams (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) = (All (OidOfNull db) params, IsProductType x xs, AllZip (ToParam db) params xs)
- type GenericRow (row :: [(Symbol, NullType)]) y (ys :: RecordCode) = (IsRecord y ys, AllZip FromField row ys)
- queryStatement :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query ('[] :: [(Symbol, RowType)]) with db params columns -> Manipulation with db params columns
- pattern Returning_ :: SListI row => NP (Aliased (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from)) row -> ReturningClause with db params from row
- newtype Manipulation (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType) = UnsafeManipulation {}
- type family Manipulation_ (db :: SchemasType) params row where ...
- newtype ReturningClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (row :: RowType) = Returning (Selection 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from row)
- data UsingClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) where
- NoUsing :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]). UsingClause with db params ('[] :: [(Symbol, RowType)])
- Using :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). FromClause ('[] :: [(Symbol, RowType)]) with db params from -> UsingClause with db params from
- selectDistinctOn_ :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) => [SortExpression grp lat with db params from] -> NP (Aliased (Expression grp lat with db params from)) columns -> TableExpression grp lat with db params from -> Query lat with db params columns
- selectDistinctOn :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) => [SortExpression grp lat with db params from] -> Selection grp lat with db params from columns -> TableExpression grp lat with db params from -> Query lat with db params columns
- selectDistinct_ :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) => NP (Aliased (Expression grp lat with db params from)) columns -> TableExpression grp lat with db params from -> Query lat with db params columns
- selectDistinct :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI columns, columns ~ (col ': cols)) => Selection grp lat with db params from columns -> TableExpression grp lat with db params from -> Query lat with db params columns
- select_ :: forall (row :: [(Symbol, NullType)]) (x :: (Symbol, NullType)) (xs :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI row, row ~ (x ': xs)) => NP (Aliased (Expression grp lat with db params from)) row -> TableExpression grp lat with db params from -> Query lat with db params row
- select :: forall (row :: [(Symbol, NullType)]) (x :: (Symbol, NullType)) (xs :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI row, row ~ (x ': xs)) => Selection grp lat with db params from row -> TableExpression grp lat with db params from -> Query lat with db params row
- data Selection (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (row :: RowType) where
- Star :: forall (tab :: Symbol) (from :: [(Symbol, RowType)]) (row :: RowType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). HasUnique tab from row => Selection 'Ungrouped lat with db params from row
- DotStar :: forall (tab :: Symbol) (from :: [(Symbol, RowType)]) (row :: RowType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). Has tab from row => Alias tab -> Selection 'Ungrouped lat with db params from row
- List :: forall (row :: RowType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). SListI row => NP (Aliased (Expression grp lat with db params from)) row -> Selection grp lat with db params from row
- Over :: forall (row :: RowType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). SListI row => NP (Aliased (WindowFunction grp lat with db params from)) row -> WindowDefinition grp lat with db params from -> Selection grp lat with db params from row
- Also :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (right :: RowType) (left :: RowType). Selection grp lat with db params from right -> Selection grp lat with db params from left -> Selection grp lat with db params from (Join left right)
- nthValue :: forall (null :: PGType -> NullType) (ty :: PGType). '[null ty, 'NotNull 'PGint4] --#-> 'Null ty
- lastValue :: forall (ty :: NullType). ty -#-> ty
- firstValue :: forall (ty :: NullType). ty -#-> ty
- lead :: forall (ty :: NullType). '[ty, 'NotNull 'PGint4, ty] --#-> ty
- lag :: forall (ty :: NullType). '[ty, 'NotNull 'PGint4, ty] --#-> ty
- ntile :: 'NotNull 'PGint4 -#-> 'NotNull 'PGint4
- cumeDist :: WinFun0 ('NotNull 'PGfloat8)
- percentRank :: WinFun0 ('NotNull 'PGfloat8)
- denseRank :: WinFun0 ('NotNull 'PGint8)
- rowNumber :: WinFun0 ('NotNull 'PGint8)
- rank :: WinFun0 ('NotNull 'PGint8)
- unsafeWindowFunctionN :: forall (xs :: [NullType]) (y :: NullType). SListI xs => ByteString -> xs --#-> y
- unsafeWindowFunction1 :: forall (x :: NullType) (y :: NullType). ByteString -> x -#-> y
- partitionBy :: forall (bys :: [NullType]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). SListI bys => NP (Expression grp lat with db params from) bys -> WindowDefinition grp lat with db params from
- pattern Window :: forall grp lat with db params from (arg :: NullType). Expression grp lat with db params from arg -> WindowArg grp '[arg] lat with db params from
- pattern Windows :: NP (Expression grp lat with db params from) args -> WindowArg grp args lat with db params from
- data WindowDefinition (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where
- WindowDefinition :: forall (bys :: [NullType]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). SListI bys => NP (Expression grp lat with db params from) bys -> [SortExpression grp lat with db params from] -> WindowDefinition grp lat with db params from
- newtype WindowFunction (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) = UnsafeWindowFunction {}
- data WindowArg (grp :: Grouping) (args :: [NullType]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) = WindowArg {
- windowArgs :: NP (Expression grp lat with db params from) args
- windowFilter :: [Condition grp lat with db params from]
- type WinFun0 (x :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowFunction grp lat with db params from x
- type (-#->) (x :: NullType) (y :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowArg grp '[x] lat with db params from -> WindowFunction grp lat with db params from y
- type (--#->) (xs :: [NullType]) (y :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowArg grp xs lat with db params from -> WindowFunction grp lat with db params from y
- distinctNotNull :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (x :: PGType). Expression 'Ungrouped lat with db params from ('Null x) -> AggregateArg '['NotNull x] lat with db params from
- allNotNull :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (x :: PGType). Expression 'Ungrouped lat with db params from ('Null x) -> AggregateArg '['NotNull x] lat with db params from
- pattern All :: forall lat with db params from (x :: NullType). Expression 'Ungrouped lat with db params from x -> AggregateArg '[x] lat with db params from
- pattern Alls :: NP (Expression 'Ungrouped lat with db params from) xs -> AggregateArg xs lat with db params from
- pattern Distinct :: forall lat with db params from (x :: NullType). Expression 'Ungrouped lat with db params from x -> AggregateArg '[x] lat with db params from
- pattern Distincts :: NP (Expression 'Ungrouped lat with db params from) xs -> AggregateArg xs lat with db params from
- class Aggregate (arg :: [NullType] -> k -> k1 -> k2 -> k3 -> k4 -> Type) (expr :: k -> k1 -> k2 -> k3 -> k4 -> NullType -> Type) | expr -> arg where
- countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). expr lat with db params from ('NotNull 'PGint8)
- count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from -> expr lat with db params from ('NotNull 'PGint8)
- sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGSum ty))
- arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from -> expr lat with db params from ('Null ('PGvararray ty))
- jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from -> expr lat with db params from ('Null 'PGjson)
- jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from -> expr lat with db params from ('Null 'PGjsonb)
- bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => arg '[null int] lat with db params from -> expr lat with db params from ('Null int)
- bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => arg '[null int] lat with db params from -> expr lat with db params from ('Null int)
- boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from -> expr lat with db params from ('Null 'PGbool)
- boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from -> expr lat with db params from ('Null 'PGbool)
- every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from -> expr lat with db params from ('Null 'PGbool)
- max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null ty)
- min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null ty)
- avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGint8)
- regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> expr lat with db params from ('Null 'PGfloat8)
- stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from -> expr lat with db params from ('Null (PGAvg ty))
- data AggregateArg (xs :: [NullType]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType)
- = AggregateAll {
- aggregateArgs :: NP (Expression 'Ungrouped lat with db params from) xs
- aggregateOrder :: [SortExpression 'Ungrouped lat with db params from]
- aggregateFilter :: [Condition 'Ungrouped lat with db params from]
- | AggregateDistinct {
- aggregateArgs :: NP (Expression 'Ungrouped lat with db params from) xs
- aggregateOrder :: [SortExpression 'Ungrouped lat with db params from]
- aggregateFilter :: [Condition 'Ungrouped lat with db params from]
- = AggregateAll {
- class FilterWhere (arg :: k -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (grp :: Grouping) | arg -> grp where
- filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> arg xs lat with db params from -> arg xs lat with db params from
- type family PGSum (ty :: PGType) :: PGType where ...
- type family PGAvg (ty :: PGType) :: PGType where ...
- inlineColumns :: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) => hask -> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])))) columns
- inlineFields :: forall hask (fields :: RecordCode) (row :: [(Symbol, NullType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask fields, AllZip InlineField fields row) => hask -> NP (Aliased (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]))) row
- class Inline x where
- class InlineParam x (ty :: NullType) where
- inlineParam :: x -> Expr ty
- class InlineField (field :: (Symbol, Type)) (fieldpg :: (Symbol, NullType)) where
- inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P field -> Aliased (Expression grp lat with db params from) fieldpg
- class InlineColumn (field :: (Symbol, Type)) (column :: (Symbol, ColumnType)) where
- inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P field -> Aliased (Optional (Expression grp lat with db params from)) column
- arrAny :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType). Expression grp lat with db params from ty1 -> Operator ty1 ty2 ('Null 'PGbool) -> Expression grp lat with db params from ('Null ('PGvararray ty2)) -> Condition grp lat with db params from
- arrAll :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType). Expression grp lat with db params from ty1 -> Operator ty1 ty2 ('Null 'PGbool) -> Expression grp lat with db params from ('Null ('PGvararray ty2)) -> Condition grp lat with db params from
- unnest :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) -|-> ("unnest" ::: '["unnest" ::: ty])
- index2 :: forall (i :: Nat) (j :: Nat) (m :: Nat) (n :: Nat) (ty :: NullType). (1 <= i, i <= m, KnownNat i, 1 <= j, j <= n, KnownNat j) => 'NotNull ('PGfixarray '[m, n] ty) --> ty
- index1 :: forall (i :: Nat) (n :: Nat) (ty :: NullType). (1 <= i, i <= n, KnownNat i) => 'NotNull ('PGfixarray '[n] ty) --> ty
- index :: forall (null :: PGType -> NullType) (ty :: NullType). Word64 -> null ('PGvararray ty) --> NullifyType ty
- cardinality :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) --> null 'PGint8
- array2 :: forall (tys :: [NullType]) (tyss :: [[NullType]]) (n1 :: Nat) (ty :: NullType) (n2 :: Nat) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). (All ([NullType] ~ tys) tyss, All (SListI :: [NullType] -> Constraint) tyss, Length tyss ~ n1, All (NullType ~ ty) tys, Length tys ~ n2) => NP (NP (Expression grp lat with db params from)) tyss -> Expression grp lat with db params from (null ('PGfixarray '[n1, n2] ty))
- array1 :: forall (n :: Nat) (tys :: [NullType]) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). (n ~ Length tys, All (NullType ~ ty) tys) => NP (Expression grp lat with db params from) tys -> Expression grp lat with db params from (null ('PGfixarray '[n] ty))
- array0 :: forall (db :: SchemasType) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). TypeExpression db ty -> Expression grp lat with db params from (null ('PGvararray ty))
- array :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). [Expression grp lat with db params from ty] -> Expression grp lat with db params from (null ('PGvararray ty))
- isNotUnknown :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool
- isUnknown :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool
- isNotFalse :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool
- isFalse :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool
- isNotTrue :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool
- isTrue :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool
- isNotDistinctFrom :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('NotNull 'PGbool)
- isDistinctFrom :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- notBetweenSymmetric :: BetweenExpr
- betweenSymmetric :: BetweenExpr
- notBetween :: BetweenExpr
- between :: BetweenExpr
- least :: forall (ty :: NullType). FunctionVar ty ty ty
- greatest :: forall (ty :: NullType). FunctionVar ty ty ty
- (.>) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- (.<=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- (.<) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- (.>=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- (./=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- (.==) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool)
- type BetweenExpr = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). Expression grp lat with db params from ty -> (Expression grp lat with db params from ty, Expression grp lat with db params from ty) -> Condition grp lat with db params from
- field :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tydef :: Symbol) (row :: RowType) (field :: Symbol) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). (Has sch db schema, Has tydef schema ('Typedef ('PGcomposite row)), Has field row ty) => QualifiedAlias sch tydef -> Alias field -> Expression grp lat with db params from ('NotNull ('PGcomposite row)) -> Expression grp lat with db params from ty
- rowStar :: forall (tab :: Symbol) (from :: [(Symbol, RowType)]) (row :: RowType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (null :: PGType -> NullType). Has tab from row => Alias tab -> Expression grp lat with db params from (null ('PGcomposite row))
- row :: forall (row :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). SListI row => NP (Aliased (Expression grp lat with db params from)) row -> Expression grp lat with db params from (null ('PGcomposite row))
- jsonbToRecordSet :: JsonToRecordFunction 'PGjsonb
- jsonToRecordSet :: JsonToRecordFunction 'PGjson
- jsonbToRecord :: JsonToRecordFunction 'PGjsonb
- jsonToRecord :: JsonToRecordFunction 'PGjson
- jsonbPopulateRecordSet :: JsonPopulateFunction "jsonb_populate_record_set" 'PGjsonb
- jsonPopulateRecordSet :: JsonPopulateFunction "json_populate_record_set" 'PGjson
- jsonbPopulateRecord :: JsonPopulateFunction "jsonb_populate_record" 'PGjsonb
- jsonPopulateRecord :: JsonPopulateFunction "json_populate_record" 'PGjson
- jsonbObjectKeys :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_object_keys" ::: '["jsonb_object_keys" ::: 'NotNull 'PGtext])
- jsonObjectKeys :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_object_keys" ::: '["json_object_keys" ::: 'NotNull 'PGtext])
- jsonbEachText :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_each_text" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext])
- jsonEachText :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_each_text" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext])
- jsonbEach :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson])
- jsonEach :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson])
- jsonbPretty :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGtext
- jsonbInsert :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext)), null 'PGjsonb, null 'PGbool] ---> null 'PGjsonb
- jsonbSet :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext)), null 'PGjsonb, null 'PGbool] ---> null 'PGjsonb
- jsonbStripNulls :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGjsonb
- jsonStripNulls :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGjson
- jsonbTypeof :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGtext
- jsonTypeof :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGtext
- jsonbArrayLength :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGint4
- jsonArrayLength :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGint4
- jsonbZipObject :: forall (null :: PGType -> NullType). '[null ('PGvararray ('NotNull 'PGtext)), null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGjsonb
- jsonZipObject :: forall (null :: PGType -> NullType). '[null ('PGvararray ('NotNull 'PGtext)), null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGjson
- jsonbObject :: forall (null :: PGType -> NullType) (n :: Nat). null ('PGfixarray '[n, 2] ('NotNull 'PGtext)) --> null 'PGjsonb
- jsonObject :: forall (null :: PGType -> NullType) (n :: Nat). null ('PGfixarray '[n, 2] ('NotNull 'PGtext)) --> null 'PGjson
- jsonbBuildArray :: forall (tuple :: [NullType]) (null :: PGType -> NullType). SListI tuple => tuple ---> null 'PGjsonb
- jsonBuildArray :: forall (tuple :: [NullType]) (null :: PGType -> NullType). SListI tuple => tuple ---> null 'PGjson
- rowToJson :: forall (null :: PGType -> NullType) (ty :: RowType). null ('PGcomposite ty) --> null 'PGjson
- arrayToJson :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) --> null 'PGjson
- toJsonb :: forall (null :: PGType -> NullType) (ty :: PGType). null ty --> null 'PGjsonb
- toJson :: forall (null :: PGType -> NullType) (ty :: PGType). null ty --> null 'PGjson
- (#-.) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) (null 'PGjsonb)
- (.-.) :: forall (key :: PGType) (null :: PGType -> NullType). In key '['PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2] => Operator (null 'PGjsonb) (null key) (null 'PGjsonb)
- (.?&) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGbool)
- (.?|) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGbool)
- (.?) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null 'PGtext) ('Null 'PGbool)
- (.#>>) :: forall (json :: PGType) (null :: PGType -> NullType). In json PGJsonType => Operator (null json) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGtext)
- (.#>) :: forall (json :: PGType) (null :: PGType -> NullType). In json PGJsonType => Operator (null json) (null ('PGvararray ('NotNull 'PGtext))) ('Null json)
- (.->>) :: forall (json :: PGType) (key :: PGType) (null :: PGType -> NullType). (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) ('Null 'PGtext)
- (.->) :: forall (json :: PGType) (key :: PGType) (null :: PGType -> NullType). (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) ('Null json)
- class SListI tys => JsonBuildObject (tys :: [NullType]) where
- jsonBuildObject :: forall (null :: PGType -> NullType). tys ---> null 'PGjson
- jsonbBuildObject :: forall (null :: PGType -> NullType). tys ---> null 'PGjsonb
- type JsonPopulateFunction (fun :: Symbol) (json :: PGType) = forall (db :: SchemasType) (row :: RowType) (lat :: FromType) (with :: FromType) (params :: [NullType]). In json PGJsonType => TypeExpression db ('NotNull ('PGcomposite row)) -> Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) ('NotNull json) -> FromClause lat with db params '[fun ::: row]
- type JsonToRecordFunction (json :: PGType) = forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (tab :: Symbol) (row :: [(Symbol, NullType)]). (SListI row, In json PGJsonType) => Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) ('NotNull json) -> Aliased (NP (Aliased (TypeExpression db))) (tab ::: row) -> FromClause lat with db params '[tab ::: row]
- nullIf :: forall (ty :: PGType). '['NotNull ty, 'NotNull ty] ---> 'Null ty
- matchNull :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (nullty :: NullType) (ty :: PGType). Expression grp lat with db params from nullty -> (Expression grp lat with db params from ('NotNull ty) -> Expression grp lat with db params from nullty) -> Expression grp lat with db params from ('Null ty) -> Expression grp lat with db params from nullty
- isNotNull :: forall (ty :: PGType) (null :: PGType -> NullType). 'Null ty --> null 'PGbool
- isNull :: forall (ty :: PGType) (null :: PGType -> NullType). 'Null ty --> null 'PGbool
- fromNull :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('NotNull ty) -> Expression grp lat with db params from ('Null ty) -> Expression grp lat with db params from ('NotNull ty)
- coalesce :: forall (ty :: PGType) (null :: PGType -> NullType). FunctionVar ('Null ty) (null ty) (null ty)
- monoNotNull :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). (forall (null :: PGType -> NullType). Expression grp lat with db params from (null ty)) -> Expression grp lat with db params from ('NotNull ty)
- unsafeNotNull :: forall (ty :: PGType). 'Null ty --> 'NotNull ty
- notNull :: forall (ty :: PGType). 'NotNull ty --> 'Null ty
- null_ :: forall (ty :: PGType). Expr ('Null ty)
- notIn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). Expression grp lat with db params from ty -> [Expression grp lat with db params from ty] -> Expression grp lat with db params from (null 'PGbool)
- in_ :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). Expression grp lat with db params from ty -> [Expression grp lat with db params from ty] -> Expression grp lat with db params from (null 'PGbool)
- subAny :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType) (col :: Symbol). Expression grp lat with db params from ty1 -> Operator ty1 ty2 ('Null 'PGbool) -> Query (Join lat from) with db params '[col ::: ty2] -> Condition grp lat with db params from
- subAll :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType) (col :: Symbol). Expression grp lat with db params from ty1 -> Operator ty1 ty2 ('Null 'PGbool) -> Query (Join lat from) with db params '[col ::: ty2] -> Condition grp lat with db params from
- exists :: forall (lat :: [(Symbol, RowType)]) (from :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (row :: RowType) (grp :: Grouping) (null :: PGType -> NullType). Query (Join lat from) with db params row -> Expression grp lat with db params from (null 'PGbool)
- fullOuterJoinLateral :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (NullifyFrom (Join left '[query]))
- fullOuterJoin :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (NullifyFrom (Join left right))
- fullOuter :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (NullifyFrom (Join left right))
- rightOuterJoinLateral :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (Join (NullifyFrom left) '[query])
- rightOuterJoin :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join (NullifyFrom left) right)
- rightOuter :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join (NullifyFrom left) right)
- leftOuterJoinLateral :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (Join left (NullifyFrom '[query]))
- leftOuterJoin :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left (NullifyFrom right))
- leftOuter :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left (NullifyFrom right))
- innerJoinLateral :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query -> Condition 'Ungrouped lat with db params (Join left '[query]) -> FromClause lat with db params left -> FromClause lat with db params (Join left '[query])
- innerJoin :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- inner :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right -> Condition 'Ungrouped lat with db params (Join left right) -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- crossJoinLateral :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query -> FromClause lat with db params left -> FromClause lat with db params (Join left '[query])
- crossJoin :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: FromType). FromClause lat with db params right -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- cross :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right -> FromClause lat with db params left -> FromClause lat with db params (Join left right)
- data JoinItem (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType) where
- Join :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: FromType). FromClause lat with db params right -> JoinItem lat with db params left right
- JoinLateral :: forall (lat :: FromType) (left :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query -> JoinItem lat with db params left '[query]
- JoinFunction :: forall (db :: SchemasType) (arg :: NullType) (set :: (Symbol, RowType)) (lat :: FromType) (with :: FromType) (params :: [NullType]) (left :: FromType). SetFun db arg set -> Expression 'Ungrouped lat with db params left arg -> JoinItem lat with db params left '[set]
- JoinFunctionN :: forall (args :: [NullType]) (db :: SchemasType) (set :: (Symbol, RowType)) (lat :: FromType) (with :: FromType) (params :: [NullType]) (left :: FromType). SListI args => SetFunN db args set -> NP (Expression 'Ungrouped lat with db params left) args -> JoinItem lat with db params left '[set]
- lockRows :: forall (from :: [(Symbol, RowType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). LockingClause from -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from
- offset :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Word64 -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from
- limit :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Word64 -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from
- having :: forall (bys :: [(Symbol, Symbol)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Condition ('Grouped bys) lat with db params from -> TableExpression ('Grouped bys) lat with db params from -> TableExpression ('Grouped bys) lat with db params from
- groupBy :: forall (bys :: [(Symbol, Symbol)]) (from :: FromType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI bys => NP (By from) bys -> TableExpression 'Ungrouped lat with db params from -> TableExpression ('Grouped bys) lat with db params from
- where_ :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (grp :: Grouping). Condition 'Ungrouped lat with db params from -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from
- from :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). FromClause lat with db params from -> TableExpression 'Ungrouped lat with db params from
- data TableExpression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) = TableExpression {
- fromClause :: FromClause lat with db params from
- whereClause :: [Condition 'Ungrouped lat with db params from]
- groupByClause :: GroupByClause grp from
- havingClause :: HavingClause grp lat with db params from
- orderByClause :: [SortExpression grp lat with db params from]
- limitClause :: [Word64]
- offsetClause :: [Word64]
- lockingClauses :: [LockingClause from]
- data By (from :: FromType) (by :: (Symbol, Symbol)) where
- By1 :: forall (table :: Symbol) (from :: FromType) (columns :: [(Symbol, NullType)]) (column :: Symbol) (ty :: NullType). (HasUnique table from columns, Has column columns ty) => Alias column -> By from '(table, column)
- By2 :: forall (table :: Symbol) (from :: FromType) (columns :: [(Symbol, NullType)]) (column :: Symbol) (ty :: NullType). (Has table from columns, Has column columns ty) => Alias table -> Alias column -> By from '(table, column)
- newtype GroupByClause (grp :: k) (from :: k1) = UnsafeGroupByClause {}
- data HavingClause (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where
- NoHaving :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). HavingClause 'Ungrouped lat with db params from
- Having :: forall (bys :: [(Symbol, Symbol)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [Condition ('Grouped bys) lat with db params from] -> HavingClause ('Grouped bys) lat with db params from
- data LockingClause (from :: [(Symbol, kind)]) where
- For :: forall kind (tabs :: [Symbol]) (from :: [(Symbol, kind)]) (tables :: [(Symbol, kind)]). HasAll tabs from tables => LockStrength -> NP Alias tabs -> Waiting -> LockingClause from
- data LockStrength
- = Update
- | NoKeyUpdate
- | Share
- | KeyShare
- data Waiting
- = Wait
- | NoWait
- | SkipLocked
- ifThenElse :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). Condition grp lat with db params from -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty
- caseWhenThenElse :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). [(Condition grp lat with db params from, Expression grp lat with db params from ty)] -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty
- (.||) :: forall (null :: PGType -> NullType). Operator (null 'PGbool) (null 'PGbool) (null 'PGbool)
- (.&&) :: forall (null :: PGType -> NullType). Operator (null 'PGbool) (null 'PGbool) (null 'PGbool)
- not_ :: forall (null :: PGType -> NullType). null 'PGbool --> null 'PGbool
- false :: forall (null :: PGType -> NullType). Expr (null 'PGbool)
- true :: forall (null :: PGType -> NullType). Expr (null 'PGbool)
- type Condition (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) = Expression grp lat with db params from ('Null 'PGbool)
- ceiling_ :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac
- round_ :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac
- trunc :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac
- rem_ :: forall (int :: PGType) (null :: PGType -> NullType). In int PGIntegral => Operator (null int) (null int) (null int)
- quot_ :: forall (int :: PGType) (null :: PGType -> NullType). In int PGIntegral => Operator (null int) (null int) (null int)
- atan2_ :: forall (float :: PGType) (null :: PGType -> NullType). In float PGFloating => '[null float, null float] ---> null float
- param :: forall (n :: Nat) (ty :: NullType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (grp :: Grouping). (NullTyped db ty, HasParameter n params ty) => Expression grp lat with db params from ty
- class KnownNat n => HasParameter (n :: Nat) (params :: [NullType]) (ty :: NullType) | n params -> ty where
- parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db ty -> Expression grp lat with db params from ty
- cmdTuples :: MonadIO io => Result y -> io (Maybe Row)
- cmdStatus :: MonadIO io => Result y -> io Text
- liftResult :: MonadIO io => (Result -> IO x) -> Result y -> io x
- data Result y where
- enumValue :: forall (labels :: [Symbol]) y. (All KnownSymbol labels, PG y ~ 'PGenum labels) => NP (K y :: Symbol -> Type) labels -> StateT ByteString (Except Text) y
- genericRow :: forall (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (IsRecord y ys, AllZip FromField row ys) => DecodeRow row y
- decodeRow :: forall (row :: [(Symbol, NullType)]) y. (NP (K (Maybe ByteString) :: (Symbol, NullType) -> Type) row -> Either Text y) -> DecodeRow row y
- consRow :: forall (head :: NullType) h t z (col :: Symbol) (tail :: RowType). FromValue head h => (h -> t -> z) -> Alias col -> DecodeRow tail t -> DecodeRow ((col ::: head) ': tail) z
- appendRows :: forall (left :: [(Symbol, NullType)]) l r z (right :: RowType). SListI left => (l -> r -> z) -> DecodeRow left l -> DecodeRow right r -> DecodeRow (Join left right) z
- runDecodeRow :: forall (row :: RowType) y. DecodeRow row y -> NP (K (Maybe ByteString) :: (Symbol, NullType) -> Type) row -> Either Text y
- rowValue :: forall y (row :: RowType). (PG y ~ 'PGcomposite row, SListI row) => DecodeRow row y -> StateT ByteString (Except Text) y
- devalue :: Value x -> StateT ByteString (Except Text) x
- class IsPG y => FromPG y where
- fromPG :: StateT ByteString (Except Text) y
- class FromValue (ty :: NullType) y where
- fromValue :: Maybe ByteString -> Either Text y
- class FromField (field :: (Symbol, NullType)) (y :: (Symbol, Type)) where
- class FromArray (dims :: [Nat]) (ty :: NullType) y where
- newtype DecodeRow (row :: RowType) y = DecodeRow {}
- appendParams :: forall (db :: SchemasType) (params0 :: [NullType]) x (params1 :: [NullType]). EncodeParams db params0 x -> EncodeParams db params1 x -> EncodeParams db (Join params0 params1) x
- aParam :: forall (db :: SchemasType) x. ToParam db (NullPG x) x => EncodeParams db '[NullPG x] x
- (*.) :: forall (db :: SchemasType) x x0 (ty0 :: NullType) x1 (ty1 :: NullType). (ToParam db ty0 x0, ToParam db ty1 x1) => (x -> x0) -> (x -> x1) -> EncodeParams db '[ty0, ty1] x
- (.*) :: forall (db :: SchemasType) x0 (ty :: NullType) x (tys :: [NullType]). ToParam db ty x0 => (x -> x0) -> EncodeParams db tys x -> EncodeParams db (ty ': tys) x
- nilParams :: forall (db :: SchemasType) x. EncodeParams db ('[] :: [NullType]) x
- genericParams :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]). (IsProductType x xs, AllZip (ToParam db) params xs) => EncodeParams db params x
- class IsPG x => ToPG (db :: SchemasType) x where
- class ToParam (db :: SchemasType) (ty :: NullType) x where
- class ToField (db :: SchemasType) (field :: (Symbol, NullType)) (x :: (Symbol, Type)) where
- class ToArray (db :: SchemasType) (dims :: [Nat]) (ty :: NullType) x where
- arrayPayload :: x -> ReaderT (K Connection db) IO Encoding
- arrayDims :: [Int32]
- arrayNulls :: Bool
- newtype EncodeParams (db :: SchemasType) (tys :: [NullType]) x = EncodeParams {}
- rangeMerge :: forall (null :: PGType -> NullType) (ty :: PGType). '[null ('PGrange ty), null ('PGrange ty)] ---> null ('PGrange ty)
- upperInf :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool
- upperInc :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool
- lowerInf :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool
- lowerInc :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool
- isEmpty :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool
- upperBound :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null ty
- lowerBound :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null ty
- (@-) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
- (@*) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
- (@+) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty))
- (-|-) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
- (&>) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
- (&<) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
- (@>>) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
- (<<@) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool)
- (@>.) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) ('NotNull ty) ('Null 'PGbool)
- (.<@) :: forall (ty :: PGType) (null :: PGType -> NullType). Operator ('NotNull ty) (null ('PGrange ty)) ('Null 'PGbool)
- whole :: Range x
- singleton :: x -> Range x
- atMost :: x -> Range x
- lessThan :: x -> Range x
- atLeast :: x -> Range x
- moreThan :: x -> Range x
- (<..<=) :: x -> x -> Range x
- (<=..<) :: x -> x -> Range x
- (<..<) :: x -> x -> Range x
- (<=..<=) :: x -> x -> Range x
- range :: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). TypeExpression db (null ('PGrange ty)) -> Range (Expression grp lat with db params from ('NotNull ty)) -> Expression grp lat with db params from (null ('PGrange ty))
- data Bound x
- data Range x
- data SortExpression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where
- Asc :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('NotNull ty) -> SortExpression grp lat with db params from
- Desc :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('NotNull ty) -> SortExpression grp lat with db params from
- AscNullsFirst :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('Null ty) -> SortExpression grp lat with db params from
- AscNullsLast :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('Null ty) -> SortExpression grp lat with db params from
- DescNullsFirst :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('Null ty) -> SortExpression grp lat with db params from
- DescNullsLast :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('Null ty) -> SortExpression grp lat with db params from
- class OrderBy (expr :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (grp :: Grouping) | expr -> grp where
- orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> expr lat with db params from -> expr lat with db params from
- ilike :: forall (null :: PGType -> NullType). Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool)
- like :: forall (null :: PGType -> NullType). Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool)
- charLength :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGint4
- upper :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtext
- lower :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtext
- tsHeadline :: forall (document :: PGType) (null :: PGType -> NullType). In document '['PGtext, 'PGjson, 'PGjsonb] => '[null document, null 'PGtsquery] ---> null 'PGtext
- tsFilter :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGvararray ('NotNull ('PGchar 1)))] ---> null 'PGtsvector
- tsDelete :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGtsvector
- jsonbToTSvector :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null 'PGjsonb] ---> null 'PGtsvector
- jsonToTSvector :: forall (null :: PGType -> NullType). '[null 'PGjson, null 'PGjson] ---> null 'PGtsvector
- strip :: forall (null :: PGType -> NullType). null 'PGtsvector --> null 'PGtsvector
- setWeight :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGchar 1)] ---> null 'PGtsvector
- toTSvector :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGtext, 'PGjson, 'PGjsonb] => null ty --> null 'PGtsvector
- toTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery
- queryTree :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGtext
- websearchToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery
- phraseToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery
- plainToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery
- numnode :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGint4
- tsvectorLength :: forall (null :: PGType -> NullType). null 'PGtsvector --> null 'PGint4
- arrayToTSvector :: forall (null :: PGType -> NullType). null ('PGvararray ('NotNull 'PGtext)) --> null 'PGtsvector
- (<->) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery)
- (.!) :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGtsquery
- (.|) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery)
- (.&) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery)
- (@@) :: forall (null :: PGType -> NullType). Operator (null 'PGtsvector) (null 'PGtsquery) ('Null 'PGbool)
- interval_ :: forall (null :: PGType -> NullType). Milli -> TimeUnit -> Expr (null 'PGinterval)
- makeTimestamptz :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtimestamptz
- makeTimestamp :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtimestamp
- makeTime :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtime
- makeDate :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4] ---> null 'PGdate
- now :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamptz)
- localTimestamp :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamp)
- localTime :: forall (null :: PGType -> NullType). Expr (null 'PGtime)
- currentTimestamp :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamptz)
- currentTime :: forall (null :: PGType -> NullType). Expr (null 'PGtimetz)
- currentDate :: forall (null :: PGType -> NullType). Expr (null 'PGdate)
- class TimeOp (time :: k) (diff :: k) | time -> diff where
- (!+) :: forall (null :: k -> NullType). Operator (null time) (null diff) (null time)
- (+!) :: forall (null :: k -> NullType). Operator (null diff) (null time) (null time)
- (!-) :: forall (null :: k -> NullType). Operator (null time) (null diff) (null time)
- (!-!) :: forall (null :: k -> NullType). Operator (null time) (null time) (null diff)
- data TimeUnit
- columntypeFrom :: forall hask (db :: SchemasType). ColumnTyped db ('NoDef :=> NullPG hask) => ColumnTypeExpression db ('NoDef :=> NullPG hask)
- nulltypeFrom :: forall hask (db :: SchemasType). NullTyped db (NullPG hask) => TypeExpression db (NullPG hask)
- bigserial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8)
- serial8 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8)
- serial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4)
- serial4 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4)
- smallserial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2)
- serial2 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2)
- default_ :: forall (db :: SchemasType) (ty :: NullType). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, RowType)]) ty -> ColumnTypeExpression db ('NoDef :=> ty) -> ColumnTypeExpression db ('Def :=> ty)
- notNullable :: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType). TypeExpression db (null ty) -> ColumnTypeExpression db ('NoDef :=> 'NotNull ty)
- nullable :: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType). TypeExpression db (null ty) -> ColumnTypeExpression db ('NoDef :=> 'Null ty)
- pgtypeFrom :: forall hask (db :: SchemasType) (null :: PGType -> NullType). PGTyped db (PG hask) => TypeExpression db (null (PG hask))
- record :: forall (db :: SchemasType) (null :: PGType -> NullType) (record :: RowType). TypeExpression db (null ('PGcomposite record))
- daterange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGdate))
- tstzrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamptz))
- tsrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamp))
- numrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGnumeric))
- int8range :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint8))
- int4range :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint4))
- oid :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGoid)
- tsquery :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtsquery)
- tsvector :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtsvector)
- fixarray :: forall (dims :: [Nat]) (db :: SchemasType) (null :: PGType -> NullType) (pg :: NullType). All KnownNat dims => TypeExpression db pg -> TypeExpression db (null ('PGfixarray dims pg))
- vararray :: forall (db :: SchemasType) (pg :: NullType) (null :: PGType -> NullType). TypeExpression db pg -> TypeExpression db (null ('PGvararray pg))
- jsonb :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGjsonb)
- json :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGjson)
- inet :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGinet)
- uuid :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGuuid)
- interval :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGinterval)
- timetz :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz)
- timeWithTimeZone :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz)
- time :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtime)
- date :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGdate)
- timestamptz :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz)
- timestampWithTimeZone :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz)
- timestamp :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamp)
- bytea :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGbytea)
- characterVarying :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGvarchar n))
- varchar :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGvarchar n))
- character :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGchar n))
- char :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGchar n))
- text :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtext)
- money :: forall (schema :: SchemasType) (null :: PGType -> NullType). TypeExpression schema (null 'PGmoney)
- doublePrecision :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8)
- float8 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8)
- real :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4)
- float4 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4)
- numeric :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGnumeric)
- bigint :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint8)
- int8 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint8)
- integer :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4)
- int :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4)
- int4 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4)
- smallint :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint2)
- int2 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint2)
- bool :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGbool)
- typeview :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (null :: PGType -> NullType). (Has sch db schema, Has vw schema ('View view)) => QualifiedAlias sch vw -> TypeExpression db (null ('PGcomposite view))
- typetable :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (null :: PGType -> NullType). (Has sch db schema, Has tab schema ('Table table)) => QualifiedAlias sch tab -> TypeExpression db (null ('PGcomposite (TableToRow table)))
- typedef :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (td :: Symbol) (ty :: PGType) (null :: PGType -> NullType). (Has sch db schema, Has td schema ('Typedef ty)) => QualifiedAlias sch td -> TypeExpression db (null ty)
- inferredtype :: forall (db :: SchemasType) (ty :: NullType) (lat :: Grouping) (common :: FromType) (grp :: FromType) (params :: [NullType]) (from :: FromType). NullTyped db ty => Expression lat common grp db params from ty -> Expression lat common grp db params from ty
- astype :: forall (db :: SchemasType) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). TypeExpression db ty -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty
- cast :: forall (db :: SchemasType) (ty1 :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType) (ty0 :: NullType). TypeExpression db ty1 -> Expression grp lat with db params from ty0 -> Expression grp lat with db params from ty1
- newtype TypeExpression (db :: SchemasType) (ty :: NullType) = UnsafeTypeExpression {}
- class PGTyped (db :: SchemasType) (ty :: PGType) where
- pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ty)
- class FieldTyped (db :: SchemasType) (ty :: (Symbol, NullType)) where
- fieldtype :: Aliased (TypeExpression db) ty
- newtype ColumnTypeExpression (db :: SchemasType) (ty :: ColumnType) = UnsafeColumnTypeExpression {}
- class NullTyped (db :: SchemasType) (ty :: NullType) where
- nulltype :: TypeExpression db ty
- class ColumnTyped (db :: SchemasType) (column :: ColumnType) where
- columntype :: ColumnTypeExpression db column
- generateSeriesTimestamp :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGtimestamp, 'PGtimestamptz] => '[null ty, null ty, null 'PGinterval] --|-> ("generate_series" ::: '["generate_series" ::: null ty])
- generateSeriesStep :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGint4, 'PGint8, 'PGnumeric] => '[null ty, null ty, null ty] --|-> ("generate_series" ::: '["generate_series" ::: null ty])
- generateSeries :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGint4, 'PGint8, 'PGnumeric] => '[null ty, null ty] --|-> ("generate_series" ::: '["generate_series" ::: null ty])
- setFunctionN :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (tys :: [NullType]) (row :: RowType). (Has sch db schema, Has fun schema ('Function (tys :=> 'ReturnsTable row)), SListI tys) => QualifiedAlias sch fun -> SetFunN db tys (fun ::: row)
- unsafeSetFunctionN :: forall (fun :: Symbol) (tys :: [NullType]) (row :: RowType). (SListI tys, KnownSymbol fun) => ByteString -> tys --|-> (fun ::: row)
- setFunction :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (ty :: NullType) (row :: RowType). (Has sch db schema, Has fun schema ('Function ('[ty] :=> 'ReturnsTable row))) => QualifiedAlias sch fun -> SetFun db ty (fun ::: row)
- unsafeSetFunction :: forall (fun :: Symbol) (ty :: NullType) (row :: RowType). KnownSymbol fun => ByteString -> ty -|-> (fun ::: row)
- type (-|->) (arg :: NullType) (set :: (Symbol, RowType)) = forall (db :: SchemasType). SetFun db arg set
- type (--|->) (arg :: [NullType]) (set :: (Symbol, RowType)) = forall (db :: SchemasType). SetFunN db arg set
- type SetFun (db :: SchemasType) (arg :: NullType) (row :: (Symbol, RowType)) = forall (lat :: FromType) (with :: FromType) (params :: [NullType]). Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) arg -> FromClause lat with db params '[row]
- type SetFunN (db :: SchemasType) (args :: [NullType]) (set :: (Symbol, RowType)) = forall (lat :: FromType) (with :: FromType) (params :: [NullType]). NP (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)])) args -> FromClause lat with db params '[set]
- values_ :: forall (cols :: [(Symbol, NullType)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI cols => NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols -> Query lat with db params cols
- values :: forall (cols :: [(Symbol, NullType)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI cols => NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols -> [NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols] -> Query lat with db params cols
- functionN :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (xs :: [NullType]) (y :: NullType). (Has sch db schema, Has fun schema ('Function (xs :=> 'Returns y)), SListI xs) => QualifiedAlias sch fun -> FunN db xs y
- unsafeFunctionN :: forall (xs :: [NullType]) (y :: NullType). SListI xs => ByteString -> xs ---> y
- function :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (x :: NullType) (y :: NullType). (Has sch db schema, Has fun schema ('Function ('[x] :=> 'Returns y))) => QualifiedAlias sch fun -> Fun db x y
- unsafeFunction :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y
- unsafeRightOp :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y
- unsafeLeftOp :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y
- unsafeBinaryOp :: forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType). ByteString -> Operator ty0 ty1 ty2
- unsafeFunctionVar :: forall (x0 :: NullType) (x1 :: NullType) (y :: NullType). ByteString -> FunctionVar x0 x1 y
- newtype Expression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) = UnsafeExpression {}
- type Expr (x :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x
- type Operator (x1 :: NullType) (x2 :: NullType) (y :: NullType) = forall (db :: SchemasType). OperatorDB db x1 x2 y
- type OperatorDB (db :: SchemasType) (x1 :: NullType) (x2 :: NullType) (y :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x1 -> Expression grp lat with db params from x2 -> Expression grp lat with db params from y
- type (-->) (x :: NullType) (y :: NullType) = forall (db :: SchemasType). Fun db x y
- type Fun (db :: SchemasType) (x :: NullType) (y :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x -> Expression grp lat with db params from y
- type (--->) (xs :: [NullType]) (y :: NullType) = forall (db :: SchemasType). FunN db xs y
- type FunN (db :: SchemasType) (xs :: [NullType]) (y :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). NP (Expression grp lat with db params from) xs -> Expression grp lat with db params from y
- type FunctionVar (x0 :: NullType) (x1 :: NullType) (y :: NullType) = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [Expression grp lat with db params from x0] -> Expression grp lat with db params from x1 -> Expression grp lat with db params from y
- class PGSubset (ty :: k) where
- class PGIntersect (ty :: k) where
- mapOptional :: forall k expr (x :: k) (y :: k) (def :: Optionality). (expr x -> expr y) -> Optional expr (def :=> x) -> Optional expr (def :=> y)
- pattern NotDefault :: ty -> Optional I ('Def :=> ty)
- data Optional (expr :: k -> Type) (ty :: (Optionality, k)) where
- common :: forall (cte :: Symbol) (with :: [(Symbol, RowType)]) (common :: RowType) (alias :: Symbol) (lat :: FromType) (db :: SchemasType) (params :: [NullType]). Has cte with common => Aliased Alias (alias ::: cte) -> FromClause lat with db params '[alias ::: common]
- view :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (alias :: Symbol) (lat :: FromType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has vw schema ('View view)) => Aliased (QualifiedAlias sch) (alias ::: vw) -> FromClause lat with db params '[alias ::: view]
- subquery :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query lat with db params) query -> FromClause lat with db params '[query]
- table :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (alias :: Symbol) (lat :: FromType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab schema ('Table table)) => Aliased (QualifiedAlias sch) (alias ::: tab) -> FromClause lat with db params '[alias ::: TableToRow table]
- newtype FromClause (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) = UnsafeFromClause {}
- withRecursive :: forall (lat :: FromType) (recursive :: (Symbol, RowType)) (with :: [(Symbol, RowType)]) (db :: SchemasType) (params :: [NullType]) (row :: RowType). Aliased (Query lat (recursive ': with) db params) recursive -> Query lat (recursive ': with) db params row -> Query lat with db params row
- class With (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) where
- with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression statement db params) with0 with1 -> statement with1 db params row -> statement with0 db params row
- data CommonTableExpression (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) where
- CommonTableExpression :: forall (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) (with0 :: FromType) (db :: SchemasType) (params :: [NullType]) (cte :: Symbol) (common :: RowType). Aliased (statement with0 db params) (cte ::: common) -> CommonTableExpression statement db params with0 ((cte ::: common) ': with0)
- exceptAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns
- except :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns
- intersectAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns
- intersect :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns
- unionAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns
- union :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns
- newtype Query (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (row :: RowType) = UnsafeQuery {}
- type family Query_ (db :: SchemasType) params row where ...
- lowerConnection :: forall a (schema :: a) (db :: [a]). K Connection (schema ': db) -> K Connection db
- finish :: forall k io (db :: k). MonadIO io => K Connection db -> io ()
- connectdb :: forall (db :: SchemasType) io. MonadIO io => ByteString -> io (K Connection db)
- class OidOf (db :: SchemasType) (pg :: PGType) where
- class OidOfArray (db :: SchemasType) (pg :: PGType) where
- oidOfArray :: ReaderT (K Connection db) IO Oid
- class OidOfNull (db :: SchemasType) (ty :: NullType) where
- class OidOfField (db :: SchemasType) (field :: (Symbol, NullType)) where
- oidOfField :: ReaderT (K Connection db) IO Oid
- type family PG hask :: PGType
- class IsPG hask where
- type family LabelsPG hask :: [ConstructorName] where ...
- type family RowPG hask :: RowType where ...
- type family RowOf (record :: [(Symbol, Type)]) :: RowType where ...
- type family NullPG hask :: NullType where ...
- type family TuplePG hask :: [NullType] where ...
- type family TupleOf (tuple :: [Type]) :: [NullType] where ...
- type family TupleCodeOf hask (code :: [[Type]]) :: [Type] where ...
- type family ConstructorsOf (datatype :: DatatypeInfo) :: [ConstructorInfo] where ...
- type family ConstructorNameOf (constructor :: ConstructorInfo) :: ConstructorName where ...
- type family ConstructorNamesOf (constructors :: [ConstructorInfo]) :: [ConstructorName] where ...
- type family DimPG hask :: [Nat] where ...
- type family FixPG hask :: NullType where ...
- data PGType
- = PGbool
- | PGint2
- | PGint4
- | PGint8
- | PGnumeric
- | PGfloat4
- | PGfloat8
- | PGmoney
- | PGchar Nat
- | PGvarchar Nat
- | PGtext
- | PGbytea
- | PGtimestamp
- | PGtimestamptz
- | PGdate
- | PGtime
- | PGtimetz
- | PGinterval
- | PGuuid
- | PGinet
- | PGjson
- | PGjsonb
- | PGvararray NullType
- | PGfixarray [Nat] NullType
- | PGenum [Symbol]
- | PGcomposite RowType
- | PGtsvector
- | PGtsquery
- | PGoid
- | PGrange PGType
- | UnsafePGType Symbol
- data NullType
- type (:=>) (constraint :: k) (ty :: k1) = '(constraint, ty)
- data Optionality
- type ColumnType = (Optionality, NullType)
- type ColumnsType = [(Symbol, ColumnType)]
- data TableConstraint
- type TableConstraints = [(Symbol, TableConstraint)]
- type family Uniquely (key :: [Symbol]) (constraints :: TableConstraints) where ...
- type TableType = (TableConstraints, ColumnsType)
- type RowType = [(Symbol, NullType)]
- type FromType = [(Symbol, RowType)]
- type family ColumnsToRow (columns :: ColumnsType) :: RowType where ...
- type family TableToColumns (table :: TableType) :: ColumnsType where ...
- type family TableToRow (table :: TableType) :: RowType where ...
- type PGNum = '['PGint2, 'PGint4, 'PGint8, 'PGnumeric, 'PGfloat4, 'PGfloat8]
- type PGFloating = '['PGfloat4, 'PGfloat8, 'PGnumeric]
- type PGIntegral = '['PGint2, 'PGint4, 'PGint8]
- class SamePGType (ty0 :: (Symbol, ColumnType)) (ty1 :: (Symbol, ColumnType))
- type family AllNotNull (columns :: ColumnsType) where ...
- type family NotAllNull (columns :: ColumnsType) where ...
- type family NullifyType (ty :: NullType) :: NullType where ...
- type family NullifyRow (columns :: RowType) :: RowType where ...
- type family NullifyFrom (tables :: FromType) :: FromType where ...
- type family Create (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family CreateIfNotExists (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family CreateOrReplace (alias :: Symbol) (x :: t) (xs :: [(Symbol, t)]) :: [(Symbol, t)] where ...
- type family Drop (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family DropSchemum (alias :: Symbol) (sch :: k1 -> k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family DropIfExists (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family DropSchemumIfExists (alias :: Symbol) (sch :: k1 -> k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family Alter (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family AlterIfExists (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family Rename (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family RenameIfExists (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family SetSchema (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, k)]) (schema1 :: [(Symbol, k)]) (obj :: Symbol) (srt :: k1 -> k) (ty :: k1) (db :: [(Symbol, [(Symbol, k)])]) :: [(Symbol, [(Symbol, k)])] where ...
- type family ConstraintInvolves (column :: Symbol) (constraint :: TableConstraint) :: Bool where ...
- type family DropIfConstraintsInvolve (column :: Symbol) (constraints :: [(Symbol, TableConstraint)]) :: [(Symbol, TableConstraint)] where ...
- data SchemumType
- type FunctionType = ([NullType], ReturnsType)
- data IndexType
- data ReturnsType
- type SchemaType = [(Symbol, SchemumType)]
- type SchemasType = [(Symbol, SchemaType)]
- type family Public (schema :: SchemaType) :: SchemasType where ...
- class IsPGlabel (label :: Symbol) expr where
- label :: expr
- data PGlabel (label :: Symbol) = PGlabel
- type PGJsonKey = '['PGint2, 'PGint4, 'PGtext]
- type PGJsonType = '['PGjson, 'PGjsonb]
- class IsNotElem (x :: k) (isElem :: k1)
- class AllUnique (xs :: [(Symbol, a)])
- type Updatable (table :: TableType) (columns :: [(Symbol, a)]) = (All (HasIn (TableToColumns table) :: (Symbol, a) -> Constraint) columns, AllUnique columns, SListI (TableToColumns table))
- type family UserTypeName (schema :: SchemaType) (ty :: PGType) :: Maybe Symbol where ...
- type family UserTypeNamespace (sch :: Symbol) (td :: Maybe Symbol) (schemas :: SchemasType) (ty :: PGType) :: (Symbol, Symbol) where ...
- type family UserType (db :: SchemasType) (ty :: PGType) :: (Symbol, Symbol) where ...
- mapAliased :: forall k expr (x :: k) (y :: k) (alias :: Symbol). (expr x -> expr y) -> Aliased expr (alias ::: x) -> Aliased expr (alias ::: y)
- renderAliased :: forall k expression (aliased :: (Symbol, k)). (forall (ty :: k). expression ty -> ByteString) -> Aliased expression aliased -> ByteString
- type (:::) (alias :: Symbol) (ty :: k) = '(alias, ty)
- data Grouping
- class (KnownSymbol table, KnownSymbol column) => GroupedBy (table :: Symbol) (column :: Symbol) (bys :: k)
- data Alias (alias :: Symbol) = Alias
- data Aliased (expression :: k -> Type) (aliased :: (Symbol, k)) where
- class KnownSymbol alias => Aliasable (alias :: Symbol) expression aliased | aliased -> expression, aliased -> alias where
- type HasUnique (alias :: Symbol) (fields :: [(Symbol, k)]) (field :: k) = fields ~ '[alias ::: field]
- type Has (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) = HasErr fields alias fields field
- class KnownSymbol alias => HasErr (err :: k) (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) | alias fields -> field
- class HasIn (fields :: k) (field :: k1)
- class All KnownSymbol aliases => HasAll (aliases :: [Symbol]) (fields :: [(Symbol, kind)]) (subfields :: [(Symbol, kind)]) | aliases fields -> subfields
- class IsQualified (qualifier :: Symbol) (alias :: Symbol) expression where
- data QualifiedAlias (qualifier :: Symbol) (alias :: Symbol) = QualifiedAlias
- one :: forall k f (x :: k). f x -> NP f '[x]
- (*:) :: forall k f (x :: k) (y :: k). f x -> f y -> NP f '[x, y]
- disjoin :: forall k (xs :: [k]) (ys :: [k]) (expr :: k -> Type). SListI xs => NP expr (Join xs ys) -> (NP expr xs, NP expr ys)
- type family Join (xs :: [a]) (ys :: [a]) :: [a] where ...
- class Additional (expr :: [a] -> Type) where
- type family Elem (x :: k) (xs :: [k]) :: Bool where ...
- type family In (x :: t) (xs :: [t]) where ...
- type family Length (xs :: [k]) :: Nat where ...
- getFixChar :: forall (n :: Nat). FixChar n -> Text
- fixChar :: forall (n :: Nat). KnownNat n => Text -> Maybe (FixChar n)
- getVarChar :: forall (n :: Nat). VarChar n -> Text
- varChar :: forall (n :: Nat). KnownNat n => Text -> Maybe (VarChar n)
- newtype Money = Money {}
- newtype Json hask = Json {
- getJson :: hask
- newtype Jsonb hask = Jsonb {
- getJsonb :: hask
- newtype Composite record = Composite {
- getComposite :: record
- newtype Enumerated enum = Enumerated {
- getEnumerated :: enum
- newtype VarArray arr = VarArray {
- getVarArray :: arr
- newtype FixArray arr = FixArray {
- getFixArray :: arr
- newtype Only x = Only {
- fromOnly :: x
- data VarChar (n :: Nat)
- data FixChar (n :: Nat)
- throwSqueal :: MonadUnliftIO io => SquealException -> io a
- trySqueal :: MonadUnliftIO io => io a -> io (Either SquealException a)
- handleSqueal :: MonadUnliftIO io => (SquealException -> io a) -> io a -> io a
- catchSqueal :: MonadUnliftIO io => io a -> (SquealException -> io a) -> io a
- pattern UniqueViolation :: ByteString -> SquealException
- pattern CheckViolation :: ByteString -> SquealException
- pattern SerializationFailure :: ByteString -> SquealException
- data SQLState = SQLState {}
- data SquealException
- printSQL :: (RenderSQL sql, MonadIO io) => sql -> io ()
- class RenderSQL sql where
- renderSQL :: sql -> ByteString
- type Pool = Pool
Documentation
class IsLabel (x :: Symbol) a where #
Instances
| alias1 ~ alias2 => IsLabel alias1 (Alias alias2) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| FromValue ty (Maybe y) => IsLabel fld (MaybeT (DecodeRow ((fld ::: ty) ': row)) y) | |
| IsLabel fld (MaybeT (DecodeRow row) y) => IsLabel fld (MaybeT (DecodeRow (field ': row)) y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| FromValue ty y => IsLabel fld (DecodeRow ((fld ::: ty) ': row) y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsLabel fld (DecodeRow row y) => IsLabel fld (DecodeRow (field ': row) y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsLabel col (By rels by) | |
Defined in Squeal.PostgreSQL.Query.Table | |
| (q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.Type.Alias Methods fromLabel :: QualifiedAlias q' a' # | |
| (HasUnique rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsLabel col (NP (By rels) bys) | |
Defined in Squeal.PostgreSQL.Query.Table | |
| (HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column # | |
| aliases ~ '[alias] => IsLabel alias (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) | |
| (q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) # | |
| (HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsLabel col (Selection 'Ungrouped lat with db params from row1) | |
Defined in Squeal.PostgreSQL.Query.Select | |
| (HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsLabel col (Selection ('Grouped bys) lat with db params from row1) | |
Defined in Squeal.PostgreSQL.Query.Select | |
| (HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (Expression 'Ungrouped lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression 'Ungrouped lat with db params from ty # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsLabel col (Expression ('Grouped bys) lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression ('Grouped bys) lat with db params from ty # | |
(>>>) :: forall k cat (a :: k) (b :: k) (c :: k). Category cat => cat a b -> cat b c -> cat a c infixr 1 #
Left-to-right composition
newtype ExceptT e (m :: Type -> Type) a #
A monad transformer that adds exceptions to other monads.
ExceptT constructs a monad parameterized over two things:
- e - The exception type.
- m - The inner monad.
The return function yields a computation that produces the given
value, while >>= sequences two subcomputations, exiting on the
first exception.
Instances
data Path (p :: k -> k -> Type) (x :: k) (y :: k) where #
A Path with steps in p is a singly linked list of
"type-aligned" constructions of p.
>>>:{let path :: Path (->) String Int path = length :>> (\x -> x^2) :>> Done in qfold path "hello" :} 25
Constructors
| Done :: forall k (p :: k -> k -> Type) (x :: k). Path p x x | |
| (:>>) :: forall k (p :: k -> k -> Type) (x :: k) (y1 :: k) (y :: k). p x y1 -> Path p y1 y -> Path p x y infixr 7 |
Instances
| QFunctor (Path :: (k -> k -> Type) -> k -> k -> Type) | |
Defined in Control.Category.Free | |
| QPointed (Path :: (k -> k -> Type) -> k -> k -> Type) | |
Defined in Control.Category.Free | |
| QMonad (Path :: (k -> k -> Type) -> k -> k -> Type) | |
| CFree (Path :: (k -> k -> Type) -> k -> k -> Type) | |
Defined in Control.Category.Free | |
| QFoldable (Path :: (k -> k -> Type) -> k -> k -> Type) | |
Defined in Control.Category.Free Methods qfoldMap :: forall q p (x :: k0) (y :: k0). Category q => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> q x1 y1) -> Path p x y -> q x y # qfold :: forall q (x :: k0) (y :: k0). Category q => Path q x y -> q x y # qfoldr :: forall k1 p q (y :: k0) (z :: k1) (x :: k0). (forall (x1 :: k0) (y1 :: k0) (z1 :: k1). p x1 y1 -> q y1 z1 -> q x1 z1) -> q y z -> Path p x y -> q x z # qfoldl :: forall k1 q p (x :: k1) (y :: k0) (z :: k0). (forall (x1 :: k1) (y1 :: k0) (z1 :: k0). q x1 y1 -> p y1 z1 -> q x1 z1) -> q x y -> Path p y z -> q x z # qtoMonoid :: forall m p (x :: k0) (y :: k0). Monoid m => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> m) -> Path p x y -> m # qtoList :: forall p a (x :: k0) (y :: k0). (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> a) -> Path p x y -> [a] # qtraverse_ :: forall m q p (x :: k0) (y :: k0). (Applicative m, Category q) => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> m (q x1 y1)) -> Path p x y -> m (q x y) # | |
| QTraversable (Path :: (k -> k -> Type) -> k -> k -> Type) | |
Defined in Control.Category.Free Methods qtraverse :: forall m p q (x :: k0) (y :: k0). Applicative m => (forall (x1 :: k0) (y1 :: k0). p x1 y1 -> m (q x1 y1)) -> Path p x y -> m (Path q x y) # | |
| Category (Path p :: k -> k -> Type) | |
| (KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 # | |
| (forall (x1 :: k) (y1 :: k). Show (p x1 y1)) => Show (Path p x y) | |
| x ~ y => Semigroup (Path p x y) | |
| x ~ y => Monoid (Path p x y) | |
data IsoQ (c :: k -> k -> Type) (x :: k) (y :: k) #
Arrows of IsoQ are bidirectional edges.
Instances
| Category c => Category (IsoQ c :: k -> k -> Type) | |
| Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ())) | impure rewindable migrations |
| Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ())) | pure rewindable migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 # | |
| (Eq (c x y), Eq (c y x)) => Eq (IsoQ c x y) | |
| (Ord (c x y), Ord (c y x)) => Ord (IsoQ c x y) | |
| (Show (c x y), Show (c y x)) => Show (IsoQ c x y) | |
| (Category c, x ~ y) => Semigroup (IsoQ c x y) | |
| (Category c, x ~ y) => Monoid (IsoQ c x y) | |
The constant type functor.
Like Constant, but kind-polymorphic
in its second argument and with a shorter name.
Constructors
| K a |
Instances
| IsPGlabel label (y -> K y label) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| IsPGlabel label (y -> NP (K y :: Symbol -> Type) '[label]) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| Eq2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
| Ord2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
| Read2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors Methods liftReadsPrec2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> Int -> ReadS (K a b) # liftReadList2 :: (Int -> ReadS a) -> ReadS [a] -> (Int -> ReadS b) -> ReadS [b] -> ReadS [K a b] # liftReadPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec (K a b) # liftReadListPrec2 :: ReadPrec a -> ReadPrec [a] -> ReadPrec b -> ReadPrec [b] -> ReadPrec [K a b] # | |
| Show2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.4.0 |
| NFData2 (K :: Type -> Type -> Type) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
| Functor (K a :: Type -> Type) | |
| Monoid a => Applicative (K a :: Type -> Type) | |
| Foldable (K a :: Type -> Type) | |
Defined in Data.SOP.BasicFunctors Methods fold :: Monoid m => K a m -> m # foldMap :: Monoid m => (a0 -> m) -> K a a0 -> m # foldMap' :: Monoid m => (a0 -> m) -> K a a0 -> m # foldr :: (a0 -> b -> b) -> b -> K a a0 -> b # foldr' :: (a0 -> b -> b) -> b -> K a a0 -> b # foldl :: (b -> a0 -> b) -> b -> K a a0 -> b # foldl' :: (b -> a0 -> b) -> b -> K a a0 -> b # foldr1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # foldl1 :: (a0 -> a0 -> a0) -> K a a0 -> a0 # elem :: Eq a0 => a0 -> K a a0 -> Bool # maximum :: Ord a0 => K a a0 -> a0 # minimum :: Ord a0 => K a a0 -> a0 # | |
| Traversable (K a :: Type -> Type) | |
| Eq a => Eq1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
| Ord a => Ord1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
| Read a => Read1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
Defined in Data.SOP.BasicFunctors | |
| Show a => Show1 (K a :: Type -> Type) | Since: sop-core-0.2.4.0 |
| NFData a => NFData1 (K a :: Type -> Type) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
| Eq a => Eq (K a b) | |
| Ord a => Ord (K a b) | |
| Read a => Read (K a b) | |
| Show a => Show (K a b) | |
| Generic (K a b) | |
| Semigroup a => Semigroup (K a b) | Since: sop-core-0.4.0.0 |
| Monoid a => Monoid (K a b) | Since: sop-core-0.4.0.0 |
| NFData a => NFData (K a b) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.BasicFunctors | |
| type Rep (K a b) | |
Defined in Data.SOP.BasicFunctors | |
| type Code (K a b) | |
Defined in Generics.SOP.Instances | |
| type DatatypeInfoOf (K a b) | |
Defined in Generics.SOP.Instances | |
data NP (a :: k -> Type) (b :: [k]) where #
An n-ary product.
The product is parameterized by a type constructor f and
indexed by a type-level list xs. The length of the list
determines the number of elements in the product, and if the
i-th element of the list is of type x, then the i-th
element of the product is of type f x.
The constructor names are chosen to resemble the names of the list constructors.
Two common instantiations of f are the identity functor I
and the constant functor K. For I, the product becomes a
heterogeneous list, where the type-level list describes the
types of its components. For , the product becomes a
homogeneous list, where the contents of the type-level list are
ignored, but its length still specifies the number of elements.K a
In the context of the SOP approach to generic programming, an n-ary product describes the structure of the arguments of a single data constructor.
Examples:
I 'x' :* I True :* Nil :: NP I '[ Char, Bool ] K 0 :* K 1 :* Nil :: NP (K Int) '[ Char, Bool ] Just 'x' :* Nothing :* Nil :: NP Maybe '[ Char, Bool ]
Constructors
| Nil :: forall k (a :: k -> Type). NP a ('[] :: [k]) | |
| (:*) :: forall k (a :: k -> Type) (x :: k) (xs :: [k]). a x -> NP a xs -> NP a (x ': xs) infixr 5 |
Instances
| (Has rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsQualified rel col (NP (By rels) bys) | |
| (Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| HTrans (NP :: (k1 -> Type) -> [k1] -> Type) (NP :: (k2 -> Type) -> [k2] -> Type) | |
Defined in Data.SOP.NP Methods htrans :: forall c (xs :: l1) (ys :: l2) proxy f g. AllZipN (Prod NP) c xs ys => proxy c -> (forall (x :: k10) (y :: k20). c x y => f x -> g y) -> NP f xs -> NP g ys # hcoerce :: forall (f :: k10 -> Type) (g :: k20 -> Type) (xs :: l1) (ys :: l2). AllZipN (Prod NP) (LiftedCoercible f g) xs ys => NP f xs -> NP g ys # | |
| HSequence (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP Methods hsequence' :: forall (xs :: l) f (g :: k0 -> Type). (SListIN NP xs, Applicative f) => NP (f :.: g) xs -> f (NP g xs) # hctraverse' :: forall c (xs :: l) g proxy f f'. (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g (f' a)) -> NP f xs -> g (NP f' xs) # htraverse' :: forall (xs :: l) g f f'. (SListIN NP xs, Applicative g) => (forall (a :: k0). f a -> g (f' a)) -> NP f xs -> g (NP f' xs) # | |
| HTraverse_ (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP Methods hctraverse_ :: forall c (xs :: l) g proxy f. (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g ()) -> NP f xs -> g () # htraverse_ :: forall (xs :: l) g f. (SListIN NP xs, Applicative g) => (forall (a :: k0). f a -> g ()) -> NP f xs -> g () # | |
| HCollapse (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP | |
| HAp (NP :: (k -> Type) -> [k] -> Type) | |
| HPure (NP :: (k -> Type) -> [k] -> Type) | |
| (KnownSymbol alias, tys ~ '[alias ::: ty]) => Aliasable alias (expression ty) (NP (Aliased expression) tys) | |
| IsPGlabel label (y -> NP (K y :: Symbol -> Type) '[label]) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| Additional (NP expr :: [a] -> Type) | |
| (HasUnique rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsLabel col (NP (By rels) bys) | |
Defined in Squeal.PostgreSQL.Query.Table | |
| (HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| aliases ~ '[alias] => IsLabel alias (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| labels ~ '[label] => IsPGlabel label (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| All (Compose Eq f) xs => Eq (NP f xs) | |
| (All (Compose Eq f) xs, All (Compose Ord f) xs) => Ord (NP f xs) | |
| All (Compose Show f) xs => Show (NP f xs) | |
| All (Compose Semigroup f) xs => Semigroup (NP f xs) | Since: sop-core-0.4.0.0 |
| (All (Compose Monoid f) xs, All (Compose Semigroup f) xs) => Monoid (NP f xs) | Since: sop-core-0.4.0.0 |
| All (Compose NFData f) xs => NFData (NP f xs) | Since: sop-core-0.2.5.0 |
Defined in Data.SOP.NP | |
| All KnownSymbol labels => RenderSQL (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Type.Schema Methods renderSQL :: NP PGlabel labels -> ByteString # | |
| All KnownSymbol aliases => RenderSQL (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods renderSQL :: NP Alias aliases -> ByteString # | |
| type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) | |
Defined in Data.SOP.NP | |
| type Same (NP :: (k1 -> Type) -> [k1] -> Type) | |
| type SListIN (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP | |
| type Prod (NP :: (k -> Type) -> [k] -> Type) | |
| type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) | |
Defined in Data.SOP.NP | |
| type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a | |
Defined in Data.SOP.NP | |
newtype StateT s (m :: Type -> Type) a #
A state transformer monad parameterized by:
s- The state.m- The inner monad.
The return function leaves the state unchanged, while >>= uses
the final state of the first computation as the initial state of
the second.
Instances
Instances
| Eq Oid | |
| Ord Oid | |
| Read Oid | |
| Show Oid | |
| Storable Oid | |
Defined in Database.PostgreSQL.LibPQ | |
| Inline Oid | |
| FromPG Oid | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG Oid | |
Defined in Squeal.PostgreSQL.Type.PG | |
| ToPG db Oid | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| type PG Oid | |
Defined in Squeal.PostgreSQL.Type.PG | |
data ExecStatus #
Constructors
| EmptyQuery | The string sent to the server was empty. |
| CommandOk | Successful completion of a command returning no data. |
| TuplesOk | Successful completion of a command returning data (such as a SELECT or SHOW). |
| CopyOut | Copy Out (from server) data transfer started. |
| CopyIn | Copy In (to server) data transfer started. |
| CopyBoth | Copy In/Out data transfer started. |
| BadResponse | The server's response was not understood. |
| NonfatalError | A nonfatal error (a notice or warning) occurred. |
| FatalError | A fatal error occurred. |
| SingleTuple | The PGresult contains a single result tuple from the current command. This status occurs only when single-row mode has been selected for the query. |
Instances
| Enum ExecStatus | |
Defined in Database.PostgreSQL.LibPQ Methods succ :: ExecStatus -> ExecStatus # pred :: ExecStatus -> ExecStatus # toEnum :: Int -> ExecStatus # fromEnum :: ExecStatus -> Int # enumFrom :: ExecStatus -> [ExecStatus] # enumFromThen :: ExecStatus -> ExecStatus -> [ExecStatus] # enumFromTo :: ExecStatus -> ExecStatus -> [ExecStatus] # enumFromThenTo :: ExecStatus -> ExecStatus -> ExecStatus -> [ExecStatus] # | |
| Eq ExecStatus | |
Defined in Database.PostgreSQL.LibPQ | |
| Show ExecStatus | |
Defined in Database.PostgreSQL.LibPQ Methods showsPrec :: Int -> ExecStatus -> ShowS # show :: ExecStatus -> String # showList :: [ExecStatus] -> ShowS # | |
data Connection #
Connection encapsulates a connection to the backend.
Instances
| Eq Connection | |
Defined in Database.PostgreSQL.LibPQ.Internal | |
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (KnownSymbol sch, Has sch db schema) | |
| => Alias sch | schema |
| -> Text | comment |
| -> Definition db db |
When a user views a schema in the database (i.e. with dn+ schema), it is useful to be able to read a description.
Arguments
| :: forall (sch :: Symbol) (tab :: Symbol) (col :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (cons :: TableConstraints) (cols :: ColumnsType) (def :: Optionality) (nulltyp :: NullType). (KnownSymbol sch, KnownSymbol tab, KnownSymbol col, Has sch db schema, Has tab schema ('Table '(cons, cols)), Has col cols '(def, nulltyp)) | |
| => QualifiedAlias sch tab | table |
| -> Alias col | column |
| -> Text | comment |
| -> Definition db db |
When a user views a table in the database (i.e. with d+ table), it is useful to be able to view descriptions of the columns in that table.
Arguments
| :: forall (sch :: Symbol) (fun :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (function :: FunctionType). (KnownSymbol sch, KnownSymbol fun, Has sch db schema, Has fun schema ('Function function)) | |
| => QualifiedAlias sch fun | function |
| -> Text | comment |
| -> Definition db db |
When a user views a function in the database (i.e. with df+ function), it is useful to be able to read a description of the function.
Arguments
| :: forall (sch :: Symbol) (ind :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (index :: IndexType). (KnownSymbol sch, KnownSymbol ind, Has sch db schema, Has ind schema ('Index index)) | |
| => QualifiedAlias sch ind | index |
| -> Text | comment |
| -> Definition db db |
When a user views an index in the database (i.e. with di+ index), it is useful to be able to read a description of the index.
Arguments
| :: forall (sch :: Symbol) (vie :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (view :: RowType). (KnownSymbol sch, KnownSymbol vie, Has sch db schema, Has vie schema ('View view)) | |
| => QualifiedAlias sch vie | view |
| -> Text | comment |
| -> Definition db db |
When a user views a view in the database (i.e. with dv view), it is useful to be able to read a description of the view.
Arguments
| :: forall (sch :: Symbol) (typ :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (type_ :: PGType). (KnownSymbol sch, KnownSymbol typ, Has sch db schema, Has typ schema ('Typedef type_)) | |
| => QualifiedAlias sch typ | type |
| -> Text | comment |
| -> Definition db db |
When a user views a type in the database (i.e with dT type), it is useful to be able to read a description of the type.
Arguments
| :: forall (sch :: Symbol) (tab :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (table :: TableType). (KnownSymbol sch, KnownSymbol tab, Has sch db schema, Has tab schema ('Table table)) | |
| => QualifiedAlias sch tab | table |
| -> Text | comment |
| -> Definition db db |
When a user views a table in the database (i.e. with d+ table), it is useful to be able to read a description of the table.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol). (Has sch db schema, KnownSymbol fun) | |
| => QualifiedAlias sch fun | function alias |
| -> Definition db (Alter sch (DropSchemumIfExists fun 'Function schema) db) |
Drop a function.
>>>type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))>>>:{let definition :: Definition (Public '[]) (Public '[]) definition = dropFunctionIfExists #fn in printSQL definition :} DROP FUNCTION IF EXISTS "fn";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol). (Has sch db schema, KnownSymbol fun) | |
| => QualifiedAlias sch fun | function alias |
| -> Definition db (Alter sch (DropSchemum fun 'Function schema) db) |
Drop a function.
>>>type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))>>>:{let definition :: Definition (Public '["fn" ::: Fn]) (Public '[]) definition = dropFunction #fn in printSQL definition :} DROP FUNCTION "fn";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (rets :: [(Symbol, NullType)]). (Has sch db schema, KnownSymbol fun, SListI args, SListI rets) | |
| => QualifiedAlias sch fun | function alias |
| -> NP (TypeExpression db) args | arguments |
| -> NP (Aliased (TypeExpression db)) rets | return type |
| -> FunctionDefinition db args ('ReturnsTable rets) | function definition |
| -> Definition db (Alter sch (CreateOrReplace fun ('Function (args :=> 'ReturnsTable rets)) schema) db) |
Create or replace a set function.
>>>type Tab = 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])>>>type Fn = 'Function ('[ 'Null 'PGint4, 'Null 'PGint4] :=> 'ReturnsTable '["ret" ::: 'Null 'PGint4])>>>:{let definition :: Definition (Public '["tab" ::: Tab, "fn" ::: Fn]) (Public '["tab" ::: Tab, "fn" ::: Fn]) definition = createOrReplaceSetFunction #fn (int4 *: int4) (int4 `as` #ret) $ languageSqlQuery (select_ ((param @1 * param @2 + #col) `as` #ret) (from (table #tab))) in printSQL definition :} CREATE OR REPLACE FUNCTION "fn" (int4, int4) RETURNS TABLE ("ret" int4) language sql as $$ SELECT ((($1 :: int4) * ($2 :: int4)) + "col") AS "ret" FROM "tab" AS "tab" $$;
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (rets :: [(Symbol, NullType)]). (Has sch db schema, KnownSymbol fun, SListI args, SListI rets) | |
| => QualifiedAlias sch fun | function alias |
| -> NP (TypeExpression db) args | arguments |
| -> NP (Aliased (TypeExpression db)) rets | return type |
| -> FunctionDefinition db args ('ReturnsTable rets) | function definition |
| -> Definition db (Alter sch (Create fun ('Function (args :=> 'ReturnsTable rets)) schema) db) |
Create a set function.
>>>type Tab = 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])>>>type Fn = 'Function ('[ 'Null 'PGint4, 'Null 'PGint4] :=> 'ReturnsTable '["ret" ::: 'Null 'PGint4])>>>:{let definition :: Definition (Public '["tab" ::: Tab]) (Public '["tab" ::: Tab, "fn" ::: Fn]) definition = createSetFunction #fn (int4 *: int4) (int4 `as` #ret) $ languageSqlQuery (select_ ((param @1 * param @2 + #col) `as` #ret) (from (table #tab))) in printSQL definition :} CREATE FUNCTION "fn" (int4, int4) RETURNS TABLE ("ret" int4) language sql as $$ SELECT ((($1 :: int4) * ($2 :: int4)) + "col") AS "ret" FROM "tab" AS "tab" $$;
Arguments
| :: forall (db :: SchemasType) (args :: [NullType]) (rets :: RowType). Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db args rets | function body |
| -> FunctionDefinition db args ('ReturnsTable rets) |
Use a parametrized Query as a function body
Arguments
| :: forall (db :: SchemasType) (args :: [NullType]) (ret :: NullType). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db args ('[] :: [(Symbol, RowType)]) ret | function body |
| -> FunctionDefinition db args ('Returns ret) |
Use a parameterized Expression as a function body
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (ret :: NullType). (Has sch db schema, KnownSymbol fun, SListI args) | |
| => QualifiedAlias sch fun | function alias |
| -> NP (TypeExpression db) args | arguments |
| -> TypeExpression db ret | return type |
| -> FunctionDefinition db args ('Returns ret) | function definition |
| -> Definition db (Alter sch (CreateOrReplace fun ('Function (args :=> 'Returns ret)) schema) db) |
Create or replace a function. It is not possible to change the name or argument types or return type of a function this way.
>>>type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))>>>:{let definition :: Definition (Public '["fn" ::: Fn]) (Public '["fn" ::: Fn]) definition = createOrReplaceFunction #fn (int4 *: int4) int4 $ languageSqlExpr (param @1 @('Null 'PGint4) * param @2 @('Null 'PGint4) + 1) in printSQL definition :} CREATE OR REPLACE FUNCTION "fn" (int4, int4) RETURNS int4 language sql as $$ SELECT * FROM (VALUES (((($1 :: int4) * ($2 :: int4)) + (1 :: int4)))) AS t ("ret") $$;
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fun :: Symbol) (args :: [NullType]) (ret :: NullType). (Has sch db schema, KnownSymbol fun, SListI args) | |
| => QualifiedAlias sch fun | function alias |
| -> NP (TypeExpression db) args | arguments |
| -> TypeExpression db ret | return type |
| -> FunctionDefinition db args ('Returns ret) | function definition |
| -> Definition db (Alter sch (Create fun ('Function (args :=> 'Returns ret)) schema) db) |
Create a function.
>>>type Fn = 'Function ( '[ 'Null 'PGint4, 'Null 'PGint4] :=> 'Returns ( 'Null 'PGint4))>>>:{let definition :: Definition (Public '[]) (Public '["fn" ::: Fn]) definition = createFunction #fn (int4 *: int4) int4 $ languageSqlExpr (param @1 * param @2 + 1) in printSQL definition :} CREATE FUNCTION "fn" (int4, int4) RETURNS int4 language sql as $$ SELECT * FROM (VALUES (((($1 :: int4) * ($2 :: int4)) + (1 :: int4)))) AS t ("ret") $$;
newtype FunctionDefinition (db :: k) (args :: k1) (ret :: k2) #
Body of a user defined function
Constructors
| UnsafeFunctionDefinition | |
Fields | |
Instances
dropIndexIfExists :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (ix :: Symbol). (Has sch db schema, KnownSymbol ix) => QualifiedAlias sch ix -> Definition db (Alter sch (DropSchemumIfExists ix 'Index schema) db) #
Drop an index if it exists.
dropIndex :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (ix :: Symbol). (Has sch db schema, KnownSymbol ix) => QualifiedAlias sch ix -> Definition db (Alter sch (DropSchemum ix 'Index schema) db) #
Drop an index.
>>>printSQL (dropIndex #ix :: Definition (Public '["ix" ::: 'Index 'Btree]) (Public '[]))DROP INDEX "ix";
brin :: IndexMethod 'Brin #
BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table.
gin :: IndexMethod 'Gin #
GIN indexes are “inverted indexes” which are appropriate for data values that contain multiple component values, such as arrays.
spgist :: IndexMethod 'Spgist #
SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches.
gist :: IndexMethod 'Gist #
GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented.
hash :: IndexMethod 'Hash #
Hash indexes can only handle simple equality comparisons.
btree :: IndexMethod 'Btree #
B-trees can handle equality and range queries on data that can be sorted into some ordering.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (ix :: Symbol) (method :: IndexType). (Has sch db schema, Has tab schema ('Table table), KnownSymbol ix) | |
| => Alias ix | index alias |
| -> QualifiedAlias sch tab | table alias |
| -> IndexMethod method | index method |
| -> [SortExpression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: TableToRow table]] | sorted columns |
| -> Definition db (Alter sch (CreateIfNotExists ix ('Index method) schema) db) |
Create an index if it doesn't exist.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (ix :: Symbol) (method :: IndexType). (Has sch db schema, Has tab schema ('Table table), KnownSymbol ix) | |
| => Alias ix | index alias |
| -> QualifiedAlias sch tab | table alias |
| -> IndexMethod method | index method |
| -> [SortExpression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: TableToRow table]] | sorted columns |
| -> Definition db (Alter sch (Create ix ('Index method) schema) db) |
Create an index.
>>>:{type Table = '[] :=> '[ "a" ::: 'NoDef :=> 'Null 'PGint4 , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ] :}
>>>:{let setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table, "ix" ::: 'Index 'Btree]) setup = createTable #tab (nullable int `as` #a :* nullable real `as` #b) Nil >>> createIndex #ix #tab btree [#a & AscNullsFirst, #b & AscNullsLast] in printSQL setup :} CREATE TABLE "tab" ("a" int NULL, "b" real NULL); CREATE INDEX "ix" ON "tab" USING btree (("a") ASC NULLS FIRST, ("b") ASC NULLS LAST);
newtype IndexMethod (ty :: k) #
PostgreSQL provides several index types: B-tree, Hash, GiST, SP-GiST, GIN and BRIN. Each index type uses a different algorithm that is best suited to different types of queries.
Constructors
| UnsafeIndexMethod | |
Fields | |
Instances
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol). (Has sch db schema, KnownSymbol pro) | |
| => QualifiedAlias sch pro | procedure alias |
| -> Definition db (Alter sch (DropSchemumIfExists pro 'Procedure schema) db) |
Drop a procedure.
>>>type Proc = 'Procedure '[ 'Null 'PGint4, 'Null 'PGint4 ]>>>:{let definition :: Definition (Public '[]) (Public '[]) definition = dropProcedureIfExists #proc in printSQL definition :} DROP PROCEDURE IF EXISTS "proc";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol). (Has sch db schema, KnownSymbol pro) | |
| => QualifiedAlias sch pro | procedure alias |
| -> Definition db (Alter sch (DropSchemum pro 'Procedure schema) db) |
Drop a procedure.
>>>type Proc = 'Procedure '[ 'Null 'PGint4, 'Null 'PGint4]>>>:{let definition :: Definition (Public '["proc" ::: Proc]) (Public '[]) definition = dropProcedure #proc in printSQL definition :} DROP PROCEDURE "proc";
Arguments
| :: forall (db :: SchemasType) (args :: [NullType]). [Manipulation ('[] :: [(Symbol, RowType)]) db args ('[] :: [(Symbol, NullType)])] | procedure body |
| -> ProcedureDefinition db args |
Use a parameterized Manipulation as a procedure body
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol) (args :: [NullType]). (Has sch db schema, KnownSymbol pro, SListI args) | |
| => QualifiedAlias sch pro | procedure alias |
| -> NP (TypeExpression db) args | arguments |
| -> ProcedureDefinition db args | procedure definition |
| -> Definition db (Alter sch (CreateOrReplace pro ('Procedure args) schema) db) |
Create or replace a procedure. It is not possible to change the name or argument types of a procedure this way.
>>>type Proc = 'Procedure '[ 'NotNull 'PGint4 ]>>>type Thing = 'Table ('[] :=> '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4 ])>>>:{let definition :: Definition (Public '["things" ::: Thing ]) (Public '["things" ::: Thing, "proc" ::: Proc]) definition = createOrReplaceProcedure #proc (one int4) . languageSqlManipulation $ [deleteFrom_ #things (#id .== param @1)] in printSQL definition :} CREATE OR REPLACE PROCEDURE "proc" (int4) language sql as $$ DELETE FROM "things" AS "things" WHERE ("id" = ($1 :: int4)); $$;
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (pro :: Symbol) (args :: [NullType]). (Has sch db schema, KnownSymbol pro, SListI args) | |
| => QualifiedAlias sch pro | procedure alias |
| -> NP (TypeExpression db) args | arguments |
| -> ProcedureDefinition db args | procedure definition |
| -> Definition db (Alter sch (Create pro ('Procedure args) schema) db) |
Create a procedure.
>>>type Proc = 'Procedure '[ 'NotNull 'PGint4 ]>>>type Thing = 'Table ('[] :=> '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4 ])>>>:{let definition :: Definition (Public '["things" ::: Thing ]) (Public '["things" ::: Thing, "proc" ::: Proc]) definition = createProcedure #proc (one int4) . languageSqlManipulation $ [deleteFrom_ #things (#id .== param @1)] in printSQL definition :} CREATE PROCEDURE "proc" (int4) language sql as $$ DELETE FROM "things" AS "things" WHERE ("id" = ($1 :: int4)); $$;
newtype ProcedureDefinition (db :: k) (args :: k1) #
Body of a user defined procedure
Constructors
| UnsafeProcedureDefinition | |
Fields | |
Instances
Arguments
| :: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch | |
| => Alias sch | schema alias |
| -> Definition db (DropIfExists sch db) |
Drop a schema if it exists. Automatically drop objects (tables, functions, etc.) that are contained in the schema.
Arguments
| :: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch | |
| => Alias sch | schema alias |
| -> Definition db (Drop sch db) |
Drop a schema. Automatically drop objects (tables, functions, etc.) that are contained in the schema.
>>>:{let definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public] definition = dropSchemaCascade #muh_schema :}
>>>printSQL definitionDROP SCHEMA "muh_schema" CASCADE;
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (KnownSymbol sch, Has sch db schema) | |
| => Alias sch | schema alias |
| -> Definition db (CreateIfNotExists sch ('[] :: [(Symbol, SchemumType)]) db) |
Create a schema if it does not yet exist.
Arguments
| :: forall (sch :: Symbol) (db :: SchemasType). KnownSymbol sch | |
| => Alias sch | schema alias |
| -> Definition db (Create sch ('[] :: [(Symbol, SchemumType)]) db) |
createSchema enters a new schema into the current database.
The schema name must be distinct from the name of any existing schema
in the current database.
A schema is essentially a namespace: it contains named objects
(tables, data types, functions, and operators) whose names
can duplicate those of other objects existing in other schemas.
Named objects are accessed by QualifiedAliases with the schema
name as a prefix.
>>>:{let definition :: Definition '["public" ::: '[]] '["public" ::: '[], "my_schema" ::: '[]] definition = createSchema #my_schema in printSQL definition :} CREATE SCHEMA "my_schema";
Arguments
| :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory (IsoQ def) (IsoQ (Indexed PQ IO ())) | |
| => ByteString | connection string |
| -> Path (Migration (IsoQ def)) db0 db1 | migrations |
| -> IO () |
mainMigrateIso creates a simple executable
from a connection string and a Path of Migration IsoQs.
Arguments
| :: forall (p :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory p (Indexed PQ IO ()) | |
| => ByteString | connection string |
| -> Path (Migration p) db0 db1 | migrations |
| -> IO () |
mainMigrate creates a simple executable
from a connection string and a Path of Migrations.
migrateDown :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (IsoQ (Indexed PQ IO ())) => Path (Migration def) db0 db1 -> PQ db1 db0 IO () #
Rewind migrations.
migrateUp :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (IsoQ (Indexed PQ IO ())) => Path (Migration def) db0 db1 -> PQ db0 db1 IO () #
Run rewindable migrations.
migrate :: forall (def :: SchemasType -> SchemasType -> Type) (db0 :: SchemasType) (db1 :: SchemasType). Migratory def (Indexed PQ IO ()) => Path (Migration def) db0 db1 -> PQ db0 db1 IO () #
Run migrations.
data Migration (def :: k -> k1 -> Type) (db0 :: k) (db1 :: k1) #
A Migration consists of a name and a migration definition.
Constructors
| Migration | |
Fields
| |
Instances
| QFunctor (Migration :: (k2 -> k3 -> Type) -> k2 -> k3 -> Type) | |
Defined in Squeal.PostgreSQL.Session.Migration | |
| Generic (Migration def db0 db1) | |
| type Rep (Migration def db0 db1) | |
Defined in Squeal.PostgreSQL.Session.Migration type Rep (Migration def db0 db1) = D1 ('MetaData "Migration" "Squeal.PostgreSQL.Session.Migration" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'False) (C1 ('MetaCons "Migration" 'PrefixI 'True) (S1 ('MetaSel ('Just "migrationName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "migrationDef") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (def db0 db1)))) | |
class (Category def, Category run) => Migratory (def :: k -> k -> Type) (run :: k -> k -> Type) | def -> run where #
Methods
runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration def) db0 db1 -> run db0 db1 #
Instances
| Migratory Definition (Indexed PQ IO ()) | pure migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 # | |
| Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ())) | impure rewindable migrations |
| Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ())) | pure rewindable migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 # | |
| Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ())) | impure rewinds |
| Migratory (OpQ Definition) (OpQ (Indexed PQ IO ())) | pure rewinds |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 # | |
| Migratory (Indexed PQ IO ()) (Indexed PQ IO ()) | impure migrations |
type MigrationsTable = '["migrations_unique_name" ::: 'Unique '["name"]] :=> '["name" ::: ('NoDef :=> 'NotNull 'PGtext), "executed_at" ::: ('Def :=> 'NotNull 'PGtimestamptz)] #
The TableType for a Squeal migration.
alterType :: forall (db :: SchemasType) (ty :: ColumnType) (ty0 :: ColumnType). ColumnTypeExpression db ty -> AlterColumn db ty0 ty #
An alterType converts a column to a different data type.
This will succeed only if each existing entry in the column can be
converted to the new type by an implicit cast.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGnumeric])]] definition = alterTable #tab (alterColumn #col (alterType (numeric & notNullable))) in printSQL definition :} ALTER TABLE "tab" ALTER COLUMN "col" TYPE numeric NOT NULL;
dropNotNull :: forall (db :: SchemasType) (constraint :: Optionality) (ty :: PGType). AlterColumn db (constraint :=> 'NotNull ty) (constraint :=> 'Null ty) #
A dropNotNull drops a NOT NULL constraint from a column.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]] definition = alterTable #tab (alterColumn #col dropNotNull) in printSQL definition :} ALTER TABLE "tab" ALTER COLUMN "col" DROP NOT NULL;
setNotNull :: forall (db :: SchemasType) (constraint :: Optionality) (ty :: PGType). AlterColumn db (constraint :=> 'Null ty) (constraint :=> 'NotNull ty) #
A setNotNull adds a NOT NULL constraint to a column.
The constraint will be checked immediately, so the table data must satisfy
the constraint before it can be added.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] definition = alterTable #tab (alterColumn #col setNotNull) in printSQL definition :} ALTER TABLE "tab" ALTER COLUMN "col" SET NOT NULL;
dropDefault :: forall (db :: SchemasType) (ty :: NullType). AlterColumn db ('Def :=> ty) ('NoDef :=> ty) #
A dropDefault removes any default value for a column.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]] definition = alterTable #tab (alterColumn #col dropDefault) in printSQL definition :} ALTER TABLE "tab" ALTER COLUMN "col" DROP DEFAULT;
Arguments
| :: forall (db :: SchemasType) (ty :: NullType) (constraint :: Optionality). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, RowType)]) ty | default value to set |
| -> AlterColumn db (constraint :=> ty) ('Def :=> ty) |
A setDefault sets a new default for a column. Note that this doesn't
affect any existing rows in the table, it just changes the default for
future insert and update commands.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]] definition = alterTable #tab (alterColumn #col (setDefault 5)) in printSQL definition :} ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT (5 :: int4);
Arguments
| :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType) (ty0 :: ColumnType) (ty1 :: ColumnType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns)), Has column columns ty0) | |
| => Alias column | column to alter |
| -> AlterColumn db ty0 ty1 | alteration to perform |
| -> AlterTable sch tab db (constraints :=> Alter column ty1 columns) |
An alterColumn alters a single column.
Arguments
| :: forall (column0 :: Symbol) (column1 :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column0, KnownSymbol column1, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) | |
| => Alias column0 | column to rename |
| -> Alias column1 | what to rename the column |
| -> AlterTable sch tab db (constraints :=> Rename column0 column1 columns) |
A renameColumn renames a column.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["foo" ::: 'NoDef :=> 'Null 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["bar" ::: 'NoDef :=> 'Null 'PGint4])]] definition = alterTable #tab (renameColumn #foo #bar) in printSQL definition :} ALTER TABLE "tab" RENAME COLUMN "foo" TO "bar";
Arguments
| :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) | |
| => Alias column | column to remove |
| -> AlterTable sch tab db (constraints :=> Drop column columns) |
A dropColumn removes a column. Whatever data was in the column
disappears. Table constraints involving the column are dropped, too.
However, if the column is referenced by a foreign key constraint of
another table, PostgreSQL will not silently drop that constraint.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '[ "col1" ::: 'NoDef :=> 'Null 'PGint4 , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]] definition = alterTable #tab (dropColumn #col2) in printSQL definition :} ALTER TABLE "tab" DROP COLUMN "col2";
Arguments
| :: forall (constraint :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol constraint, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) | |
| => Alias constraint | constraint to drop |
| -> AlterTable sch tab db (Drop constraint constraints :=> columns) |
A dropConstraint drops a table constraint.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] definition = alterTable #tab (dropConstraint #positive) in printSQL definition :} ALTER TABLE "tab" DROP CONSTRAINT "positive";
Arguments
| :: forall (alias :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType) (constraint :: TableConstraint). (KnownSymbol alias, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) | |
| => Alias alias | |
| -> TableConstraintExpression sch tab db constraint | constraint to add |
| -> AlterTable sch tab db (Create alias constraint constraints :=> columns) |
An addConstraint adds a table constraint.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('["positive" ::: 'Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]] definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0))) in printSQL definition :} ALTER TABLE "tab" ADD CONSTRAINT "positive" CHECK (("col" > (0 :: int4)));
Arguments
| :: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has tab schema0 ('Table table), Has sch1 db schema1) | |
| => QualifiedAlias sch0 tab | table to move |
| -> Alias sch1 | where to move it |
| -> Definition db (SetSchema sch0 sch1 schema0 schema1 tab 'Table table db) |
This form moves the table into another schema.
>>>type DB0 = '[ "sch0" ::: '[ "tab" ::: 'Table ('[] :=> '[]) ], "sch1" ::: '[] ]>>>type DB1 = '[ "sch0" ::: '[], "sch1" ::: '[ "tab" ::: 'Table ('[] :=> '[]) ] ]>>>:{let def :: Definition DB0 DB1 def = alterTableSetSchema (#sch0 ! #tab) #sch1 in printSQL def :} ALTER TABLE "sch0"."tab" SET SCHEMA "sch1";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab0 :: Symbol) (tab1 :: Symbol). (Has sch db schema, KnownSymbol tab0, KnownSymbol tab1) | |
| => QualifiedAlias sch tab0 | table to rename |
| -> Alias tab1 | what to rename it |
| -> Definition db (Alter sch (RenameIfExists tab0 tab1 schema) db) |
alterTableIfExistsRename changes the name of a table from the schema if it exists.
>>>type Schemas = '[ "public" ::: '[ "foo" ::: 'Table ('[] :=> '[]) ] ]>>>:{let migration :: Definition Schemas Schemas migration = alterTableIfExistsRename #goo #gar in printSQL migration :} ALTER TABLE IF EXISTS "goo" RENAME TO "gar";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab1 :: Symbol) (tab0 :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab1, Has tab0 schema ('Table table)) | |
| => QualifiedAlias sch tab0 | table to rename |
| -> Alias tab1 | what to rename it |
| -> Definition db (Alter sch (Rename tab0 tab1 schema) db) |
alterTableRename changes the name of a table from the schema.
>>>type Schemas = '[ "public" ::: '[ "foo" ::: 'Table ('[] :=> '[]) ] ]>>>:{let migration :: Definition Schemas '["public" ::: '["bar" ::: 'Table ('[] :=> '[]) ] ] migration = alterTableRename #foo #bar in printSQL migration :} ALTER TABLE "foo" RENAME TO "bar";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab) | |
| => QualifiedAlias sch tab | table to alter |
| -> AlterTable sch tab db table | alteration to perform |
| -> Definition db (Alter sch (AlterIfExists tab ('Table table) schema) db) |
alterTable changes the definition of a table from the schema.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol) (table :: TableType). (Has sch db schema, KnownSymbol tab) | |
| => QualifiedAlias sch tab | table to alter |
| -> AlterTable sch tab db table | alteration to perform |
| -> Definition db (Alter sch (Alter tab ('Table table) schema) db) |
alterTable changes the definition of a table from the schema.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol). (Has sch db schema, KnownSymbol tab) | |
| => QualifiedAlias sch tab | table to remove |
| -> Definition db (Alter sch (DropSchemumIfExists tab 'Table schema) db) |
Drop a table if it exists.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (tab :: Symbol). (Has sch db schema, KnownSymbol tab) | |
| => QualifiedAlias sch tab | table to remove |
| -> Definition db (Alter sch (DropSchemum tab 'Table schema) db) |
dropTable removes a table from the schema.
>>>:{let definition :: Definition '["public" ::: '["muh_table" ::: 'Table t]] (Public '[]) definition = dropTable #muh_table :}
>>>printSQL definitionDROP TABLE "muh_table";
Arguments
| :: forall (sch :: Symbol) (tab :: Symbol) (columns :: [(Symbol, ColumnType)]) (col :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (constraints :: [(Symbol, TableConstraint)]) (db0 :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (db1 :: [(Symbol, [(Symbol, SchemumType)])]). (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch db0 schema0, db1 ~ Alter sch (CreateIfNotExists tab ('Table (constraints :=> columns)) schema0) db0) | |
| => QualifiedAlias sch tab | the name of the table to add |
| -> NP (Aliased (ColumnTypeExpression db0)) columns | the names and datatype of each column |
| -> NP (Aliased (TableConstraintExpression sch tab db1)) constraints | constraints that must hold for the table |
| -> Definition db0 db1 |
createTableIfNotExists creates a table if it doesn't exist, but does not add it to the schema.
Instead, the schema already has the table so if the table did not yet exist, the schema was wrong.
createTableIfNotExists fixes this. Interestingly, this property makes it an idempotent in
the Category of Definitions.
>>>:set -XOverloadedLabels -XTypeApplications>>>:{type Table = '[] :=> '[ "a" ::: 'NoDef :=> 'Null 'PGint4 , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ] :}
>>>type Schemas = Public '["tab" ::: 'Table Table]
>>>:{let setup :: Definition Schemas Schemas setup = createTableIfNotExists #tab (nullable int `as` #a :* nullable real `as` #b) Nil in printSQL setup :} CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);
Arguments
| :: forall (sch :: Symbol) (tab :: Symbol) (columns :: [(Symbol, ColumnType)]) (col :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (constraints :: [(Symbol, TableConstraint)]) (db0 :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (db1 :: [(Symbol, [(Symbol, SchemumType)])]). (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch db0 schema0, db1 ~ Alter sch (Create tab ('Table (constraints :=> columns)) schema0) db0) | |
| => QualifiedAlias sch tab | the name of the table to add |
| -> NP (Aliased (ColumnTypeExpression db0)) columns | the names and datatype of each column |
| -> NP (Aliased (TableConstraintExpression sch tab db1)) constraints | constraints that must hold for the table |
| -> Definition db0 db1 |
createTable adds a table to the schema.
>>>:set -XOverloadedLabels>>>:{type Table = '[] :=> '[ "a" ::: 'NoDef :=> 'Null 'PGint4 , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ] :}
>>>:{let setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table]) setup = createTable #tab (nullable int `as` #a :* nullable real `as` #b) Nil in printSQL setup :} CREATE TABLE "tab" ("a" int NULL, "b" real NULL);
newtype AlterTable (sch :: Symbol) (tab :: Symbol) (db :: SchemasType) (table :: TableType) #
An AlterTable describes the alteration to perform on the columns
of a table.
Constructors
| UnsafeAlterTable | |
Fields | |
Instances
| Eq (AlterTable sch tab db table) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods (==) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool # (/=) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool # | |
| Ord (AlterTable sch tab db table) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods compare :: AlterTable sch tab db table -> AlterTable sch tab db table -> Ordering # (<) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool # (<=) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool # (>) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool # (>=) :: AlterTable sch tab db table -> AlterTable sch tab db table -> Bool # max :: AlterTable sch tab db table -> AlterTable sch tab db table -> AlterTable sch tab db table # min :: AlterTable sch tab db table -> AlterTable sch tab db table -> AlterTable sch tab db table # | |
| Show (AlterTable sch tab db table) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods showsPrec :: Int -> AlterTable sch tab db table -> ShowS # show :: AlterTable sch tab db table -> String # showList :: [AlterTable sch tab db table] -> ShowS # | |
| Generic (AlterTable sch tab db table) | |
Defined in Squeal.PostgreSQL.Definition.Table Associated Types type Rep (AlterTable sch tab db table) :: Type -> Type # Methods from :: AlterTable sch tab db table -> Rep (AlterTable sch tab db table) x # to :: Rep (AlterTable sch tab db table) x -> AlterTable sch tab db table # | |
| NFData (AlterTable sch tab db table) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods rnf :: AlterTable sch tab db table -> () # | |
| type Rep (AlterTable sch tab db table) | |
Defined in Squeal.PostgreSQL.Definition.Table type Rep (AlterTable sch tab db table) = D1 ('MetaData "AlterTable" "Squeal.PostgreSQL.Definition.Table" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeAlterTable" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderAlterTable") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
class AddColumn (ty :: ColumnType) where #
An AddColumn is either NULL or has DEFAULT.
Minimal complete definition
Nothing
Methods
Arguments
| :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) | |
| => Alias column | column to add |
| -> ColumnTypeExpression db ty | type of the new column |
| -> AlterTable sch tab db (constraints :=> Create column ty columns) |
addColumn adds a new column, initially filled with whatever
default value is given or with NULL.
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '[ "col1" ::: 'NoDef :=> 'Null 'PGint4 , "col2" ::: 'Def :=> 'Null 'PGtext ])]] definition = alterTable #tab (addColumn #col2 (text & nullable & default_ "foo")) in printSQL definition :} ALTER TABLE "tab" ADD COLUMN "col2" text NULL DEFAULT (E'foo' :: text);
>>>:{let definition :: Definition '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]] '["public" ::: '["tab" ::: 'Table ('[] :=> '[ "col1" ::: 'NoDef :=> 'Null 'PGint4 , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]] definition = alterTable #tab (addColumn #col2 (text & nullable)) in printSQL definition :} ALTER TABLE "tab" ADD COLUMN "col2" text NULL;
Instances
| AddColumn ('NoDef :=> 'Null ty) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('NoDef :=> 'Null ty) -> AlterTable sch tab db (constraints :=> Create column ('NoDef :=> 'Null ty) columns) # | |
| AddColumn ('Def :=> ty) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('Def :=> ty) -> AlterTable sch tab db (constraints :=> Create column ('Def :=> ty) columns) # | |
newtype AlterColumn (db :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) #
An AlterColumn describes the alteration to perform on a single column.
Constructors
| UnsafeAlterColumn | |
Fields | |
Instances
| Eq (AlterColumn db ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods (==) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool # (/=) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool # | |
| Ord (AlterColumn db ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods compare :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Ordering # (<) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool # (<=) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool # (>) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool # (>=) :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> Bool # max :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 # min :: AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 -> AlterColumn db ty0 ty1 # | |
| Show (AlterColumn db ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods showsPrec :: Int -> AlterColumn db ty0 ty1 -> ShowS # show :: AlterColumn db ty0 ty1 -> String # showList :: [AlterColumn db ty0 ty1] -> ShowS # | |
| Generic (AlterColumn db ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition.Table Associated Types type Rep (AlterColumn db ty0 ty1) :: Type -> Type # Methods from :: AlterColumn db ty0 ty1 -> Rep (AlterColumn db ty0 ty1) x # to :: Rep (AlterColumn db ty0 ty1) x -> AlterColumn db ty0 ty1 # | |
| NFData (AlterColumn db ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods rnf :: AlterColumn db ty0 ty1 -> () # | |
| type Rep (AlterColumn db ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition.Table type Rep (AlterColumn db ty0 ty1) = D1 ('MetaData "AlterColumn" "Squeal.PostgreSQL.Definition.Table" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeAlterColumn" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderAlterColumn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
Arguments
| :: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (ty :: Symbol) (td :: PGType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has ty schema0 ('Typedef td), Has sch1 db schema1) | |
| => QualifiedAlias sch0 ty | type to move |
| -> Alias sch1 | where to move it |
| -> Definition db (SetSchema sch0 sch1 schema0 schema1 ty 'Typedef td db) |
This form moves the type into another schema.
>>>type DB0 = '[ "sch0" ::: '[ "ty" ::: 'Typedef 'PGfloat8 ], "sch1" ::: '[] ]>>>type DB1 = '[ "sch0" ::: '[], "sch1" ::: '[ "ty" ::: 'Typedef 'PGfloat8 ] ]>>>:{let def :: Definition DB0 DB1 def = alterTypeSetSchema (#sch0 ! #ty) #sch1 in printSQL def :} ALTER TYPE "sch0"."ty" SET SCHEMA "sch1";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (ty1 :: Symbol) (ty0 :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol ty1, Has ty0 schema ('Typedef ty)) | |
| => QualifiedAlias sch ty0 | type to rename |
| -> Alias ty1 | what to rename it |
| -> Definition db (Alter sch (Rename ty0 ty1 schema) db) |
alterTypeRename changes the name of a type from the schema.
>>>type DB = '[ "public" ::: '[ "foo" ::: 'Typedef 'PGbool ] ]>>>:{let def :: Definition DB '["public" ::: '["bar" ::: 'Typedef 'PGbool ] ] def = alterTypeRename #foo #bar in printSQL def :} ALTER TYPE "foo" RENAME TO "bar";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (td :: Symbol). (Has sch db schema, KnownSymbol td) | |
| => QualifiedAlias sch td | name of the user defined type |
| -> Definition db (Alter sch (DropSchemumIfExists td 'Typedef schema) db) |
Drop a type if it exists.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (td :: Symbol). (Has sch db schema, KnownSymbol td) | |
| => QualifiedAlias sch td | name of the user defined type |
| -> Definition db (Alter sch (DropSchemum td 'Typedef schema) db) |
Drop a type.
>>>data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic>>>instance SOP.Generic Schwarma>>>instance SOP.HasDatatypeInfo Schwarma>>>printSQL (dropType #schwarma :: Definition '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]] (Public '[]))DROP TYPE "schwarma";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (range :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol range) | |
| => QualifiedAlias sch range | range alias |
| -> (forall (null :: PGType -> NullType). TypeExpression db (null ty)) | underlying type |
| -> Definition db (Alter sch (Create range ('Typedef ('PGrange ty)) schema) db) |
Range types are data types representing a range of values of some element type (called the range's subtype). The subtype must have a total order so that it is well-defined whether element values are within, before, or after a range of values.
Range types are useful because they represent many element values in a single range value, and because concepts such as overlapping ranges can be expressed clearly. The use of time and date ranges for scheduling purposes is the clearest example; but price ranges, measurement ranges from an instrument, and so forth can also be useful.
>>>:{let createSmallIntRange :: Definition (Public '[]) (Public '["int2range" ::: 'Typedef ('PGrange 'PGint2)]) createSmallIntRange = createTypeRange #int2range int2 in printSQL createSmallIntRange :} CREATE TYPE "int2range" AS RANGE (subtype = int2);
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (dom :: Symbol) (ty :: PGType). (Has sch db schema, KnownSymbol dom) | |
| => QualifiedAlias sch dom | domain alias |
| -> (forall (null :: PGType -> NullType). TypeExpression db (null ty)) | underlying type |
| -> (forall (tab :: Symbol). Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[tab ::: '["value" ::: 'Null ty]]) | constraint on type |
| -> Definition db (Alter sch (Create dom ('Typedef ty) schema) db) |
createDomain creates a new domain. A domain is essentially a data type
with constraints (restrictions on the allowed set of values).
Domains are useful for abstracting common constraints on fields
into a single location for maintenance. For example, several tables might
contain email address columns, all requiring the same
check constraint
to verify the address syntax. Define a domain rather than setting up
each table's constraint individually.
>>>:{let createPositive :: Definition (Public '[]) (Public '["positive" ::: 'Typedef 'PGfloat4]) createPositive = createDomain #positive real (#value .> 0) in printSQL createPositive :} CREATE DOMAIN "positive" AS real CHECK (("value" > (0.0 :: float4)));
Arguments
| :: forall hask (sch :: Symbol) (ty :: Symbol) (db :: SchemasType) (schema :: SchemaType). (All (FieldTyped db) (RowPG hask), KnownSymbol ty, Has sch db schema) | |
| => QualifiedAlias sch ty | name of the user defined composite type |
| -> Definition db (Alter sch (Create ty ('Typedef (PG (Composite hask))) schema) db) |
Composite types can also be generated from a Haskell type, for example
>>>data Complex = Complex {real :: Double, imaginary :: Double} deriving GHC.Generic>>>instance SOP.Generic Complex>>>instance SOP.HasDatatypeInfo Complex>>>type Schema = '["complex" ::: 'Typedef (PG (Composite Complex))]>>>:{let createComplex :: Definition (Public '[]) (Public Schema) createComplex = createTypeCompositeFrom @Complex #complex in printSQL createComplex :} CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
Arguments
| :: forall (ty :: Symbol) (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (fields :: [(Symbol, NullType)]). (KnownSymbol ty, Has sch db schema, SListI fields) | |
| => QualifiedAlias sch ty | name of the user defined composite type |
| -> NP (Aliased (TypeExpression db)) fields | list of attribute names and data types |
| -> Definition db (Alter sch (Create ty ('Typedef ('PGcomposite fields)) schema) db) |
createTypeComposite creates a composite type. The composite type is
specified by a list of attribute names and data types.
>>>:{type PGcomplex = 'PGcomposite '[ "real" ::: 'NotNull 'PGfloat8 , "imaginary" ::: 'NotNull 'PGfloat8 ] :}
>>>:{let setup :: Definition (Public '[]) '["public" ::: '["complex" ::: 'Typedef PGcomplex]] setup = createTypeComposite #complex (float8 `as` #real :* float8 `as` #imaginary) in printSQL setup :} CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);
Arguments
| :: forall hask (sch :: Symbol) (enum :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType). (Generic hask, All KnownSymbol (LabelsPG hask), KnownSymbol enum, Has sch db schema) | |
| => QualifiedAlias sch enum | name of the user defined enumerated type |
| -> Definition db (Alter sch (Create enum ('Typedef (PG (Enumerated hask))) schema) db) |
Enumerated types can also be generated from a Haskell type, for example
>>>data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic>>>instance SOP.Generic Schwarma>>>instance SOP.HasDatatypeInfo Schwarma>>>:{let createSchwarma :: Definition (Public '[]) '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]] createSchwarma = createTypeEnumFrom @Schwarma #schwarma in printSQL createSchwarma :} CREATE TYPE "schwarma" AS ENUM ('Beef', 'Lamb', 'Chicken');
Arguments
| :: forall (enum :: Symbol) (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (labels :: [Symbol]). (KnownSymbol enum, Has sch db schema, All KnownSymbol labels) | |
| => QualifiedAlias sch enum | name of the user defined enumerated type |
| -> NP PGlabel labels | labels of the enumerated type |
| -> Definition db (Alter sch (Create enum ('Typedef ('PGenum labels)) schema) db) |
Enumerated types are created using the createTypeEnum command, for example
>>>printSQL $ (createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy") :: Definition (Public '[]) '["public" ::: '["mood" ::: 'Typedef ('PGenum '["sad","ok","happy"])]])CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');
Arguments
| :: forall (sch0 :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema0 :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (sch1 :: Symbol) (schema1 :: [(Symbol, SchemumType)]). (Has sch0 db schema0, Has vw schema0 ('View view), Has sch1 db schema1) | |
| => QualifiedAlias sch0 vw | view to move |
| -> Alias sch1 | where to move it |
| -> Definition db (SetSchema sch0 sch1 schema0 schema1 vw 'View view db) |
This form moves the view into another schema.
>>>type DB0 = '[ "sch0" ::: '[ "vw" ::: 'View '[] ], "sch1" ::: '[] ]>>>type DB1 = '[ "sch0" ::: '[], "sch1" ::: '[ "vw" ::: 'View '[] ] ]>>>:{let def :: Definition DB0 DB1 def = alterViewSetSchema (#sch0 ! #vw) #sch1 in printSQL def :} ALTER VIEW "sch0"."vw" SET SCHEMA "sch1";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (ty1 :: Symbol) (ty0 :: Symbol) (vw :: RowType). (Has sch db schema, KnownSymbol ty1, Has ty0 schema ('View vw)) | |
| => QualifiedAlias sch ty0 | view to rename |
| -> Alias ty1 | what to rename it |
| -> Definition db (Alter sch (Rename ty0 ty1 schema) db) |
alterViewRename changes the name of a view from the schema.
>>>type DB = '[ "public" ::: '[ "foo" ::: 'View '[] ] ]>>>:{let def :: Definition DB '["public" ::: '["bar" ::: 'View '[] ] ] def = alterViewRename #foo #bar in printSQL def :} ALTER VIEW "foo" RENAME TO "bar";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol). (Has sch db schema, KnownSymbol vw) | |
| => QualifiedAlias sch vw | view to remove |
| -> Definition db (Alter sch (DropIfExists vw schema) db) |
Drop a view if it exists.
>>>:{let definition :: Definition '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4]) , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]] '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]] definition = dropViewIfExists #bc in printSQL definition :} DROP VIEW IF EXISTS "bc";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol). (Has sch db schema, KnownSymbol vw) | |
| => QualifiedAlias sch vw | view to remove |
| -> Definition db (Alter sch (DropSchemum vw 'View schema) db) |
Drop a view.
>>>:{let definition :: Definition '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4]) , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]] '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]] definition = dropView #bc in printSQL definition :} DROP VIEW "bc";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol) (view :: RowType). (Has sch db schema, KnownSymbol vw) | |
| => QualifiedAlias sch vw | the name of the view to add |
| -> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) view | query |
| -> Definition db (Alter sch (CreateOrReplace vw ('View view) schema) db) |
Create or replace a view.
>>>type ABC = '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4]>>>type BC = '["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4]>>>:{let definition :: Definition '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC)]] '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC), "bc" ::: 'View BC]] definition = createOrReplaceView #bc (select_ (#b :* #c) (from (table #abc))) in printSQL definition :} CREATE OR REPLACE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, SchemaType)]) (schema :: SchemaType) (vw :: Symbol) (view :: RowType). (Has sch db schema, KnownSymbol vw) | |
| => QualifiedAlias sch vw | the name of the view to add |
| -> Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) view | query |
| -> Definition db (Alter sch (Create vw ('View view) schema) db) |
Create a view.
>>>type ABC = '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4]>>>type BC = '["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4]>>>:{let definition :: Definition '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC)]] '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC), "bc" ::: 'View BC]] definition = createView #bc (select_ (#b :* #c) (from (table #abc))) in printSQL definition :} CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
Arguments
| :: forall k io (db :: k). MonadUnliftIO io | |
| => Pool (K Connection db) | pool |
| -> io () |
Destroy all connections in all stripes in the pool. Note that this will ignore any exceptions in the destroy function.
This function is useful when you detect that all connections
in the pool are broken. For example after a database has been
restarted all connections opened before the restart will be broken.
In that case it's better to close those connections so that
usingConnectionPool won't take a broken connection from the pool
but will open a new connection instead.
Another use-case for this function is that when you know you are done with the pool you can destroy all idle connections immediately instead of waiting on the garbage collector to destroy them, thus freeing up those connections sooner.
Arguments
| :: forall io (db :: SchemasType) x. MonadUnliftIO io | |
| => Pool (K Connection db) | pool |
| -> PQ db db io x | session |
| -> io x |
Temporarily take a connection from a Pool, perform an action with it,
and return it to the pool afterwards.
If the pool has an idle connection available, it is used immediately. Otherwise, if the maximum number of connections has not yet been reached, a new connection is created and used. If the maximum number of connections has been reached, this function blocks until a connection becomes available.
Arguments
| :: forall (db :: SchemasType) io. MonadUnliftIO io | |
| => ByteString | The passed string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., ' and . |
| -> Int | The number of stripes (distinct sub-pools) to maintain. The smallest acceptable value is 1. |
| -> NominalDiffTime | Amount of time for which an unused connection is kept open. The smallest acceptable value is 0.5 seconds. The elapsed time before destroying a connection may be a little longer than requested, as the reaper thread wakes at 1-second intervals. |
| -> Int | Maximum number of connections to keep open per stripe. The smallest acceptable value is 1. Requests for connections will block if this limit is reached on a single stripe, even if other stripes have idle connections available. |
| -> io (Pool (K Connection db)) |
Create a striped pool of connections.
Although the garbage collector will destroy all idle connections when the pool is garbage collected it's recommended to manually destroyAllResources when you're done with the pool so that the connections are freed up as soon as possible.
withConnection :: forall (db0 :: SchemasType) (db1 :: SchemasType) io x. MonadUnliftIO io => ByteString -> PQ db0 db1 io x -> io x #
evalPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m x #
Evaluate a PQ and discard the Connection but keep the result.
execPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m (K Connection db1) #
Execute a PQ and discard the result but keep the Connection.
runPQ :: forall m (db0 :: SchemasType) (db1 :: SchemasType) x. Functor m => PQ db0 db1 m x -> K Connection db0 -> m (x, K Connection db1) #
Run a PQ and keep the result and the Connection.
newtype PQ (db0 :: SchemasType) (db1 :: SchemasType) (m :: Type -> Type) x #
We keep track of the schema via an Atkey indexed state monad transformer,
PQ.
Constructors
| PQ | |
Fields
| |
Instances
| IndexedMonadTransPQ PQ | |
Defined in Squeal.PostgreSQL.Session Methods define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> PQ db0 db1 io () # | |
| IndexedMonadTrans PQ | |
Defined in Squeal.PostgreSQL.Session Methods pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => PQ i j m (x -> y) -> PQ j k1 m x -> PQ i k1 m y # pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => PQ i j m (PQ j k1 m y) -> PQ i k1 m y # pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> PQ j k1 m y) -> PQ i j m x -> PQ i k1 m y # pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => PQ j k1 m y -> PQ i j m x -> PQ i k1 m y # pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> PQ j k1 m z) -> (x -> PQ i j m y) -> x -> PQ i k1 m z # | |
| Migratory Definition (Indexed PQ IO ()) | pure migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 # | |
| db0 ~ db1 => MFunctor (PQ db0 db1 :: (Type -> Type) -> Type -> Type) | |
| Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ())) | impure rewindable migrations |
| Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ())) | pure rewindable migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 # | |
| MonadBase b m => MonadBase b (PQ schema schema m) | |
Defined in Squeal.PostgreSQL.Session | |
| (MonadBaseControl b m, schema0 ~ schema1) => MonadBaseControl b (PQ schema0 schema1 m) | |
| (MonadIO io, db0 ~ db, db1 ~ db) => MonadPQ db (PQ db0 db1 io) | |
Defined in Squeal.PostgreSQL.Session Methods executeParams :: Statement db x y -> x -> PQ db0 db1 io (Result y) # executeParams_ :: Statement db x () -> x -> PQ db0 db1 io () # execute :: Statement db () y -> PQ db0 db1 io (Result y) # execute_ :: Statement db () () -> PQ db0 db1 io () # executePrepared :: Traversable list => Statement db x y -> list x -> PQ db0 db1 io (list (Result y)) # executePrepared_ :: Foldable list => Statement db x () -> list x -> PQ db0 db1 io () # | |
| Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ())) | impure rewinds |
| Migratory (OpQ Definition) (OpQ (Indexed PQ IO ())) | pure rewinds |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 # | |
| Migratory (Indexed PQ IO ()) (Indexed PQ IO ()) | impure migrations |
| db0 ~ db1 => MonadTrans (PQ db0 db1) | |
Defined in Squeal.PostgreSQL.Session | |
| db0 ~ db1 => MMonad (PQ db0 db1) | |
| db0 ~ db1 => MonadTransControl (PQ db0 db1) | |
| (Monad m, db0 ~ db1) => Monad (PQ db0 db1 m) | |
| Monad m => Functor (PQ db0 db1 m) | |
| (Monad m, db0 ~ db1) => MonadFail (PQ db0 db1 m) | |
Defined in Squeal.PostgreSQL.Session | |
| (Monad m, db0 ~ db1) => Applicative (PQ db0 db1 m) | |
Defined in Squeal.PostgreSQL.Session | |
| (MonadIO m, schema0 ~ schema1) => MonadIO (PQ schema0 schema1 m) | |
Defined in Squeal.PostgreSQL.Session | |
| (MonadThrow m, db0 ~ db1) => MonadThrow (PQ db0 db1 m) | |
Defined in Squeal.PostgreSQL.Session | |
| (MonadCatch m, db0 ~ db1) => MonadCatch (PQ db0 db1 m) | |
| (MonadMask m, db0 ~ db1) => MonadMask (PQ db0 db1 m) | |
Defined in Squeal.PostgreSQL.Session Methods mask :: ((forall a. PQ db0 db1 m a -> PQ db0 db1 m a) -> PQ db0 db1 m b) -> PQ db0 db1 m b # uninterruptibleMask :: ((forall a. PQ db0 db1 m a -> PQ db0 db1 m a) -> PQ db0 db1 m b) -> PQ db0 db1 m b # generalBracket :: PQ db0 db1 m a -> (a -> ExitCase b -> PQ db0 db1 m c) -> (a -> PQ db0 db1 m b) -> PQ db0 db1 m (b, c) # | |
| (MonadUnliftIO m, db0 ~ db1) => MonadUnliftIO (PQ db0 db1 m) | |
Defined in Squeal.PostgreSQL.Session | |
| (Monad m, Semigroup r, db0 ~ db1) => Semigroup (PQ db0 db1 m r) | |
| (Monad m, Monoid r, db0 ~ db1) => Monoid (PQ db0 db1 m r) | |
| type StT (PQ db0 db1) a | |
Defined in Squeal.PostgreSQL.Session | |
| type StM (PQ schema0 schema1 m) x | |
Defined in Squeal.PostgreSQL.Session | |
indexedDefine :: forall (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). (IndexedMonadTransPQ pq, MonadIO io) => Definition db0 db1 -> Indexed pq io () db0 db1 #
Run a pure SQL Definition functorially in effect
indexedDefine id = id
indexedDefine (def1 >>> def2) = indexedDefine def1 >>> indexedDefine def2
class (forall (i :: k) (j :: k) (m :: Type -> Type). Monad m => Functor (t i j m), forall (i :: k) (j :: k) (m :: Type -> Type). (i ~ j, Monad m) => Monad (t i j m), forall (i :: k) (j :: k). i ~ j => MonadTrans (t i j)) => IndexedMonadTrans (t :: k -> k -> (Type -> Type) -> Type -> Type) where #
An Atkey indexed monad
is a Functor enriched category.
An indexed monad transformer transforms a Monad into an indexed monad,
and is a monad transformer when its source and target are the same,
enabling use of standard do notation for endo-index operations.
Methods
pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => t i j m (x -> y) -> t j k1 m x -> t i k1 m y #
indexed analog of <*>
pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => t i j m (t j k1 m y) -> t i k1 m y #
indexed analog of join
pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> t j k1 m y) -> t i j m x -> t i k1 m y #
indexed analog of =<<
pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => t j k1 m y -> t i j m x -> t i k1 m y #
indexed analog of flipped >>
pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> t j k1 m z) -> (x -> t i j m y) -> x -> t i k1 m z #
indexed analog of <=<
Instances
| IndexedMonadTrans PQ | |
Defined in Squeal.PostgreSQL.Session Methods pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => PQ i j m (x -> y) -> PQ j k1 m x -> PQ i k1 m y # pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => PQ i j m (PQ j k1 m y) -> PQ i k1 m y # pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> PQ j k1 m y) -> PQ i j m x -> PQ i k1 m y # pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => PQ j k1 m y -> PQ i j m x -> PQ i k1 m y # pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> PQ j k1 m z) -> (x -> PQ i j m y) -> x -> PQ i k1 m z # | |
newtype Indexed (t :: k -> k1 -> k2 -> k3 -> Type) (m :: k2) (r :: k3) (i :: k) (j :: k1) #
Indexed reshuffles the type parameters of an IndexedMonadTrans,
exposing its Category instance.
Constructors
| Indexed | |
Fields
| |
Instances
class IndexedMonadTrans pq => IndexedMonadTransPQ (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) where #
IndexedMonadTransPQ is a class for indexed monad transformers
that support running Definitions using define which acts functorially in effect.
define id = return ()
define (statement1 >>> statement2) = define statement1 & pqThen (define statement2)
Methods
define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> pq db0 db1 io () #
Instances
| IndexedMonadTransPQ PQ | |
Defined in Squeal.PostgreSQL.Session Methods define :: forall (io :: Type -> Type) (db0 :: SchemasType) (db1 :: SchemasType). MonadIO io => Definition db0 db1 -> PQ db0 db1 io () # | |
Arguments
| :: forall (db :: SchemasType). Manipulation ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, NullType)]) | no input or output |
| -> Definition db db |
A Manipulation without input or output can be run as a statement
along with other Definitions, by embedding it using manipulation_.
newtype Definition (db0 :: SchemasType) (db1 :: SchemasType) #
A Definition is a statement that changes the schemas of the
database, like a createTable,
dropTable,
or alterTable command.
Definitions may be composed using the >>> operator.
Constructors
| UnsafeDefinition | |
Fields | |
Instances
Arguments
| :: forall (db :: [(Symbol, [(Symbol, SchemumType)])]) (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, SchemumType)]) (schema1 :: [(Symbol, SchemumType)]) (child :: Symbol) (parent :: Symbol) (table :: TableType) (reftable :: TableType) (columns :: [Symbol]) (refcolumns :: [Symbol]) (constraints :: TableConstraints) (cols :: ColumnsType) (reftys :: [(Symbol, ColumnType)]) (tys :: [(Symbol, ColumnType)]). ForeignKeyed db sch0 sch1 schema0 schema1 child parent table reftable columns refcolumns constraints cols reftys tys | |
| => NP Alias columns | column or columns in the table |
| -> QualifiedAlias sch0 parent | reference table |
| -> NP Alias refcolumns | reference column or columns in the reference table |
| -> OnDeleteClause | what to do when reference is deleted |
| -> OnUpdateClause | what to do when reference is updated |
| -> TableConstraintExpression sch1 child db ('ForeignKey columns sch0 parent refcolumns) |
A foreignKey specifies that the values in a column
(or a group of columns) must match the values appearing in some row of
another table. We say this maintains the referential integrity
between two related tables.
>>>:{type Schema = '[ "users" ::: 'Table ( '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4 , "name" ::: 'NoDef :=> 'NotNull 'PGtext ]) , "emails" ::: 'Table ( '[ "pk_emails" ::: 'PrimaryKey '["id"] , "fk_user_id" ::: 'ForeignKey '["user_id"] "public" "users" '["id"] ] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4 , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4 , "email" ::: 'NoDef :=> 'Null 'PGtext ]) ] :}
>>>:{let setup :: Definition (Public '[]) (Public Schema) setup = createTable #users ( serial `as` #id :* (text & notNullable) `as` #name ) ( primaryKey #id `as` #pk_users ) >>> createTable #emails ( serial `as` #id :* (int & notNullable) `as` #user_id :* (text & nullable) `as` #email ) ( primaryKey #id `as` #pk_emails :* foreignKey #user_id #users #id (OnDelete Cascade) (OnUpdate Cascade) `as` #fk_user_id ) in printSQL setup :} CREATE TABLE "users" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_users" PRIMARY KEY ("id")); CREATE TABLE "emails" ("id" serial, "user_id" int NOT NULL, "email" text NULL, CONSTRAINT "pk_emails" PRIMARY KEY ("id"), CONSTRAINT "fk_user_id" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE);
A foreignKey can even be a table self-reference.
>>>:{type Schema = '[ "employees" ::: 'Table ( '[ "employees_pk" ::: 'PrimaryKey '["id"] , "employees_employer_fk" ::: 'ForeignKey '["employer_id"] "public" "employees" '["id"] ] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4 , "name" ::: 'NoDef :=> 'NotNull 'PGtext , "employer_id" ::: 'NoDef :=> 'Null 'PGint4 ]) ] :}
>>>:{let setup :: Definition (Public '[]) (Public Schema) setup = createTable #employees ( serial `as` #id :* (text & notNullable) `as` #name :* (integer & nullable) `as` #employer_id ) ( primaryKey #id `as` #employees_pk :* foreignKey #employer_id #employees #id (OnDelete Cascade) (OnUpdate Cascade) `as` #employees_employer_fk ) in printSQL setup :} CREATE TABLE "employees" ("id" serial, "name" text NOT NULL, "employer_id" integer NULL, CONSTRAINT "employees_pk" PRIMARY KEY ("id"), CONSTRAINT "employees_employer_fk" FOREIGN KEY ("employer_id") REFERENCES "employees" ("id") ON DELETE CASCADE ON UPDATE CASCADE);
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, ColumnType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToColumns table) subcolumns, AllNotNull subcolumns) | |
| => NP Alias aliases | specify the subcolumns which together form a primary key. |
| -> TableConstraintExpression sch tab db ('PrimaryKey aliases) |
A primaryKey constraint indicates that a column, or group of columns,
can be used as a unique identifier for rows in the table.
This requires that the values be both unique and not null.
>>>:{type Schema = '[ "tab" ::: 'Table ('[ "pk_id" ::: 'PrimaryKey '["id"]] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4, "name" ::: 'NoDef :=> 'NotNull 'PGtext ])] :}
>>>:{let definition :: Definition (Public '[]) (Public Schema) definition = createTable #tab ( serial `as` #id :* (text & notNullable) `as` #name ) ( primaryKey #id `as` #pk_id ) :}
>>>printSQL definitionCREATE TABLE "tab" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_id" PRIMARY KEY ("id"));
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, NullType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToRow table) subcolumns) | |
| => NP Alias aliases | specify subcolumns which together are unique for each row |
| -> TableConstraintExpression sch tab db ('Unique aliases) |
A unique constraint ensure that the data contained in a column,
or a group of columns, is unique among all the rows in the table.
>>>:{type Schema = '[ "tab" ::: 'Table( '[ "uq_a_b" ::: 'Unique '["a","b"]] :=> '[ "a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4 ])] :}
>>>:{let definition :: Definition (Public '[]) (Public Schema) definition = createTable #tab ( (int & nullable) `as` #a :* (int & nullable) `as` #b ) ( unique (#a :* #b) `as` #uq_a_b ) :}
>>>printSQL definitionCREATE TABLE "tab" ("a" int NULL, "b" int NULL, CONSTRAINT "uq_a_b" UNIQUE ("a", "b"));
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (aliases :: [Symbol]) (subcolumns :: [(Symbol, NullType)]). (Has sch db schema, Has tab schema ('Table table), HasAll aliases (TableToRow table) subcolumns) | |
| => NP Alias aliases | specify the subcolumns which are getting checked |
| -> (forall (t :: Symbol). Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) '[t ::: subcolumns]) | a closed |
| -> TableConstraintExpression sch tab db ('Check aliases) |
A check constraint is the most generic TableConstraint type.
It allows you to specify that the value in a certain column must satisfy
a Boolean (truth-value) expression.
>>>:{type Schema = '[ "tab" ::: 'Table ('[ "inequality" ::: 'Check '["a","b"]] :=> '[ "a" ::: 'NoDef :=> 'NotNull 'PGint4, "b" ::: 'NoDef :=> 'NotNull 'PGint4 ])] :}
>>>:{let definition :: Definition (Public '[]) (Public Schema) definition = createTable #tab ( (int & notNullable) `as` #a :* (int & notNullable) `as` #b ) ( check (#a :* #b) (#a .> #b) `as` #inequality ) :}
>>>printSQL definitionCREATE TABLE "tab" ("a" int NOT NULL, "b" int NOT NULL, CONSTRAINT "inequality" CHECK (("a" > "b")));
newtype TableConstraintExpression (sch :: Symbol) (tab :: Symbol) (db :: SchemasType) (constraint :: TableConstraint) #
Data types are a way to limit the kind of data that can be stored in a
table. For many applications, however, the constraint they provide is
too coarse. For example, a column containing a product price should
probably only accept positive values. But there is no standard data type
that accepts only positive numbers. Another issue is that you might want
to constrain column data with respect to other columns or rows.
For example, in a table containing product information,
there should be only one row for each product number.
TableConstraints give you as much control over the data in your tables
as you wish. If a user attempts to store data in a column that would
violate a constraint, an error is raised. This applies
even if the value came from the default value definition.
Constructors
| UnsafeTableConstraintExpression | |
Instances
type ForeignKeyed (db :: [(Symbol, [(Symbol, SchemumType)])]) (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, SchemumType)]) (schema1 :: [(Symbol, SchemumType)]) (child :: Symbol) (parent :: Symbol) (table :: TableType) (reftable :: TableType) (columns :: [Symbol]) (refcolumns :: [Symbol]) (constraints :: TableConstraints) (cols :: ColumnsType) (reftys :: [(Symbol, ColumnType)]) (tys :: [(Symbol, ColumnType)]) = (Has sch0 db schema0, Has sch1 db schema1, Has parent schema0 ('Table reftable), Has child schema1 ('Table table), HasAll columns (TableToColumns table) tys, reftable ~ (constraints :=> cols), HasAll refcolumns cols reftys, AllZip SamePGType tys reftys, Uniquely refcolumns constraints) #
A constraint synonym between types involved in a foreign key constraint.
newtype OnDeleteClause #
OnDeleteClause indicates what to do with rows that reference a deleted row.
Constructors
| OnDelete ReferentialAction |
Instances
newtype OnUpdateClause #
Analagous to OnDeleteClause there is also OnUpdateClause which is invoked
when a referenced column is changed (updated).
Constructors
| OnUpdate ReferentialAction |
Instances
data ReferentialAction #
When the data in the referenced columns is changed, certain actions are performed on the data in this table's columns.
Constructors
| NoAction | Produce an error indicating that the deletion or update would create a foreign key constraint violation. If the constraint is deferred, this error will be produced at constraint check time if there still exist any referencing rows. |
| Restrict | Produce an error indicating that the deletion or update
would create a foreign key constraint violation.
This is the same as |
| Cascade | Delete any rows referencing the deleted row, or update the value of the referencing column to the new value of the referenced column, respectively. |
| SetNull | Set the referencing column(s) to null. |
| SetDefault | Set the referencing column(s) to their default values. |
Instances
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (xs :: [NullType]) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has pro schema ('Procedure xs), SListI xs) | |
| => QualifiedAlias sch pro | procedure to call |
| -> NP (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])) xs | arguments |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
Call a user defined procedure.
>>>type Schema = '[ "p" ::: 'Procedure '[ 'NotNull 'PGint4, 'NotNull 'PGtext ] ]>>>:{let p :: Manipulation '[] (Public Schema) '[] '[] p = callN #p (1 *: "hi") in printSQL p :} CALL "p"((1 :: int4), (E'hi' :: text))
Arguments
| :: forall (xs :: [NullType]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI xs | |
| => ByteString | procedure to call |
| -> NP (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])) xs | arguments |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
>>>printSQL $ unsafeCallN "p" (true *: false)CALL p(TRUE, FALSE)
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (pro :: Symbol) (x :: NullType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has pro schema ('Procedure '[x])) | |
| => QualifiedAlias sch pro | procedure to call |
| -> Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]) x | arguments |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
Call a user defined procedure of one variable.
>>>type Schema = '[ "p" ::: 'Procedure '[ 'NotNull 'PGint4 ] ]>>>:{let p :: Manipulation '[] (Public Schema) '[] '[] p = call #p 1 in printSQL p :} CALL "p"((1 :: int4))
Arguments
| :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (x :: NullType). ByteString | procedure to call |
| -> Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]) x | arguments |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
>>>printSQL $ unsafeCall "p" trueCALL p(TRUE)
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table)) | |
| => Aliased (QualifiedAlias sch) (tab ::: tab0) | table to delete from |
| -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table] | condition under which to delete a row |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
Delete rows returning Nil.
>>>type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[ 'NotNull 'PGint4] '[] manp = deleteFrom_ (#tab `as` #t) (#t ! #col1 .== param @1) in printSQL manp :} DELETE FROM "tab" AS "t" WHERE ("t"."col1" = ($1 :: int4))
Arguments
| :: forall (row :: [(Symbol, NullType)]) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI row, Has sch db schema, Has tab0 schema ('Table table)) | |
| => Aliased (QualifiedAlias sch) (tab ::: tab0) | table to delete from |
| -> UsingClause with db params from | |
| -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from) | condition under which to delete a row |
| -> ReturningClause with db params ((tab ::: TableToRow table) ': from) row | results to return |
| -> Manipulation with db params row |
Delete rows from a table.
>>>type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab1" ::: 'Table ('[] :=> Columns), "tab2" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] manp = deleteFrom #tab1 (Using (table #tab2)) (#tab1 ! #col1 .== #tab2 ! #col2) (Returning (#tab1 & DotStar)) in printSQL manp :} DELETE FROM "tab1" AS "tab1" USING "tab2" AS "tab2" WHERE ("tab1"."col1" = "tab2"."col2") RETURNING "tab1".*
Arguments
| :: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) | |
| => hask | record |
| -> [hask] | more |
| -> QueryClause with db params columns |
inlineValues Haskell records in insertInto.
Arguments
| :: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) | |
| => hask | record |
| -> QueryClause with db params columns |
inlineValues_ a Haskell record in insertInto.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), SListI (TableToColumns table)) | |
| => Aliased (QualifiedAlias sch) (tab ::: tab0) | table |
| -> QueryClause with db params (TableToColumns table) | what to insert |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
Like insertInto but with OnConflictDoRaise and no ReturningClause.
>>>type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint4, "col2" ::: 'Def :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[] '[] manp = insertInto_ #tab (Values_ (Set 2 `as` #col1 :* Default `as` #col2)) in printSQL manp :} INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES ((2 :: int4), DEFAULT)
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (row :: [(Symbol, NullType)]) (tab :: Symbol) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), SListI (TableToColumns table), SListI row) | |
| => Aliased (QualifiedAlias sch) (tab ::: tab0) | table |
| -> QueryClause with db params (TableToColumns table) | what to insert |
| -> ConflictClause tab with db params table | what to do in case of conflict |
| -> ReturningClause with db params '[tab ::: TableToRow table] row | what to return |
| -> Manipulation with db params row |
When a table is created, it contains no data. The first thing to do before a database can be of much use is to insert data. Data is conceptually inserted one row at a time. Of course you can also insert more than one row, but there is no way to insert less than one row. Even if you know only some column values, a complete row must be created.
>>>type CustomersColumns = '["name" ::: 'NoDef :=> 'NotNull 'PGtext, "email" ::: 'NoDef :=> 'NotNull 'PGtext]>>>type CustomersConstraints = '["uq" ::: 'Unique '["name"]]>>>type CustomersSchema = '["customers" ::: 'Table (CustomersConstraints :=> CustomersColumns)]>>>:{let manp :: Manipulation with (Public CustomersSchema) '[] '[] manp = insertInto #customers (Values_ (Set "John Smith" `as` #name :* Set "[email protected]" `as` #email)) (OnConflict (OnConstraint #uq) (DoUpdate (Set (#excluded ! #email <> "; " <> #customers ! #email) `as` #email) [])) (Returning_ Nil) in printSQL manp :} INSERT INTO "customers" AS "customers" ("name", "email") VALUES ((E'John Smith' :: text), (E'[email protected]' :: text)) ON CONFLICT ON CONSTRAINT "uq" DO UPDATE SET "email" = ("excluded"."email" || ((E'; ' :: text) || "customers"."email"))
Arguments
| :: forall columns with db params (from :: FromType). SListI columns | |
| => NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from))) columns | row of values |
| -> QueryClause with db params columns |
Values_ describes a single NP list of Aliased Optional Expressions
whose ColumnsType must match the tables'.
data QueryClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: [(Symbol, (Optionality, NullType))]) where #
A QueryClause describes what to insertInto a table.
Constructors
| Values | |
Fields
| |
| Select | |
Fields
| |
| Subquery | |
Fields
| |
Instances
| RenderSQL (QueryClause with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation.Insert Methods renderSQL :: QueryClause with db params columns -> ByteString # | |
data ConflictClause (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: ([(Symbol, TableConstraint)], ColumnsType)) where #
A ConflictClause specifies an action to perform upon a constraint
violation. OnConflictDoRaise will raise an error.
OnConflict DoNothing simply avoids inserting a row.
OnConflict DoUpdate updates the existing row that conflicts with the row
proposed for insertion.
Constructors
| OnConflictDoRaise :: forall (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: ([(Symbol, TableConstraint)], ColumnsType)). ConflictClause tab with db params table | |
| OnConflict | |
Fields
| |
Instances
| SListI (TableToColumns table) => RenderSQL (ConflictClause tab with db params table) | Render a |
Defined in Squeal.PostgreSQL.Manipulation.Insert Methods renderSQL :: ConflictClause tab with db params table -> ByteString # | |
data ConflictAction (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: TableType) where #
ConflictAction specifies an alternative OnConflict action.
It can be either DoNothing, or a DoUpdate clause specifying
the exact details of the update action to be performed in case of a conflict.
The Set and WHERE Conditions in OnConflict DoUpdate have access to the
existing row using the table's name, and to rows proposed
for insertion using the special #excluded row.
OnConflict DoNothing simply avoids inserting a row as its alternative action.
OnConflict DoUpdate updates the existing row that conflicts
with the row proposed for insertion as its alternative action.
Constructors
| DoNothing :: forall (tab :: Symbol) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (table :: TableType). ConflictAction tab with db params table | |
| DoUpdate | |
Fields
| |
Instances
| RenderSQL (ConflictAction tab with db params table) | |
Defined in Squeal.PostgreSQL.Manipulation.Insert Methods renderSQL :: ConflictAction tab with db params table -> ByteString # | |
data ConflictTarget (table :: ([(Symbol, kind)], k)) where #
A ConflictTarget specifies the constraint violation that triggers a
ConflictAction.
Constructors
| OnConstraint :: forall kind k (con :: Symbol) (constraints :: [(Symbol, kind)]) (constraint :: kind) (columns :: k). Has con constraints constraint => Alias con -> ConflictTarget '(constraints, columns) |
Instances
| RenderSQL (ConflictTarget constraints) | Render a |
Defined in Squeal.PostgreSQL.Manipulation.Insert Methods renderSQL :: ConflictTarget constraints -> ByteString # | |
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (tab :: Symbol) (updates :: [(Symbol, (Optionality, NullType))]) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab0 schema ('Table table), KnownSymbol tab, Updatable table updates) | |
| => Aliased (QualifiedAlias sch) (tab ::: tab0) | table to update |
| -> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table]))) updates | modified values to replace old values |
| -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params '[tab ::: TableToRow table] | condition under which to perform update on a row |
| -> Manipulation with db params ('[] :: [(Symbol, NullType)]) |
Update a row returning Nil.
>>>type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[] '[] manp = update_ #tab (Set 2 `as` #col1) (#col1 ./= #col2) in printSQL manp :} UPDATE "tab" AS "tab" SET "col1" = (2 :: int4) WHERE ("col1" <> "col2")
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab0 :: Symbol) (table :: TableType) (updates :: [(Symbol, (Optionality, NullType))]) (row :: [(Symbol, NullType)]) (tab :: Symbol) (with :: FromType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (Has sch db schema, Has tab0 schema ('Table table), Updatable table updates, SListI row) | |
| => Aliased (QualifiedAlias sch) (tab ::: tab0) | table to update |
| -> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from)))) updates | update expressions, modified values to replace old values |
| -> UsingClause with db params from | FROM A table expression allowing columns from other tables to appear in the WHERE condition and update expressions. |
| -> Condition 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ((tab ::: TableToRow table) ': from) | WHERE condition under which to perform update on a row |
| -> ReturningClause with db params ((tab ::: TableToRow table) ': from) row | results to return |
| -> Manipulation with db params row |
An update command changes the values of the specified columns
in all rows that satisfy the condition.
>>>type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab1" ::: 'Table ('[] :=> Columns), "tab2" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] manp = update (#tab1 `as` #t1) (Set (2 + #t2 ! #col2) `as` #col1) (Using (table (#tab2 `as` #t2))) (#t1 ! #col1 ./= #t2 ! #col2) (Returning (#t1 & DotStar)) in printSQL manp :} UPDATE "tab1" AS "t1" SET "col1" = ((2 :: int4) + "t2"."col2") FROM "tab2" AS "t2" WHERE ("t1"."col1" <> "t2"."col2") RETURNING "t1".*
longRunningMode :: TransactionMode #
TransactionMode with a Serializable IsolationLevel,
ReadOnly AccessMode and Deferrable DeferrableMode.
This mode is well suited for long-running reports or backups.
rollback :: forall (db :: SchemasType). Manipulation_ db () () #
ROLLBACK a transaction.
commit :: forall (db :: SchemasType). Manipulation_ db () () #
COMMIT a transaction.
begin :: forall (db :: SchemasType). TransactionMode -> Manipulation_ db () () #
BEGIN a transaction.
data TransactionMode #
The available transaction characteristics are the transaction IsolationLevel,
the transaction AccessMode (ReadWrite or ReadOnly), and the DeferrableMode.
Constructors
| TransactionMode | |
Fields | |
Instances
| Eq TransactionMode | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods (==) :: TransactionMode -> TransactionMode -> Bool # (/=) :: TransactionMode -> TransactionMode -> Bool # | |
| Show TransactionMode | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods showsPrec :: Int -> TransactionMode -> ShowS # show :: TransactionMode -> String # showList :: [TransactionMode] -> ShowS # | |
| RenderSQL TransactionMode | Render a |
Defined in Squeal.PostgreSQL.Session.Transaction Methods renderSQL :: TransactionMode -> ByteString # | |
data IsolationLevel #
The SQL standard defines four levels of transaction isolation.
The most strict is Serializable, which is defined by the standard in a paragraph
which says that any concurrent execution of a set of Serializable transactions is
guaranteed to produce the same effect as running them one at a time in some order.
The other three levels are defined in terms of phenomena, resulting from interaction
between concurrent transactions, which must not occur at each level.
The phenomena which are prohibited at various levels are:
Dirty read: A transaction reads data written by a concurrent uncommitted transaction.
Nonrepeatable read: A transaction re-reads data it has previously read and finds that data has been modified by another transaction (that committed since the initial read).
Phantom read: A transaction re-executes a query returning a set of rows that satisfy a search condition and finds that the set of rows satisfying the condition has changed due to another recently-committed transaction.
Serialization anomaly: The result of successfully committing a group of transactions is inconsistent with all possible orderings of running those transactions one at a time.
In PostgreSQL, you can request any of the four standard transaction
isolation levels, but internally only three distinct isolation levels are implemented,
i.e. PostgreSQL's ReadUncommitted mode behaves like ReadCommitted.
This is because it is the only sensible way to map the standard isolation levels to
PostgreSQL's multiversion concurrency control architecture.
Constructors
| Serializable | Dirty read is not possible. Nonrepeatable read is not possible. Phantom read is not possible. Serialization anomaly is not possible. |
| RepeatableRead | Dirty read is not possible. Nonrepeatable read is not possible. Phantom read is not possible. Serialization anomaly is possible. |
| ReadCommitted | Dirty read is not possible. Nonrepeatable read is possible. Phantom read is possible. Serialization anomaly is possible. |
| ReadUncommitted | Dirty read is not possible. Nonrepeatable read is possible. Phantom read is possible. Serialization anomaly is possible. |
Instances
| Eq IsolationLevel | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods (==) :: IsolationLevel -> IsolationLevel -> Bool # (/=) :: IsolationLevel -> IsolationLevel -> Bool # | |
| Show IsolationLevel | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods showsPrec :: Int -> IsolationLevel -> ShowS # show :: IsolationLevel -> String # showList :: [IsolationLevel] -> ShowS # | |
| RenderSQL IsolationLevel | Render an |
Defined in Squeal.PostgreSQL.Session.Transaction Methods renderSQL :: IsolationLevel -> ByteString # | |
data AccessMode #
The transaction access mode determines whether the transaction is ReadWrite or ReadOnly.
ReadWrite is the default. When a transaction is ReadOnly,
the following SQL commands are disallowed:
INSERT, UPDATE, DELETE, and COPY FROM
if the table they would write to is not a temporary table;
all CREATE, ALTER, and DROP commands;
COMMENT, GRANT, REVOKE, TRUNCATE;
and EXPLAIN ANALYZE and EXECUTE if the command they would execute is among those listed.
This is a high-level notion of ReadOnly that does not prevent all writes to disk.
Instances
| Eq AccessMode | |
Defined in Squeal.PostgreSQL.Session.Transaction | |
| Show AccessMode | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods showsPrec :: Int -> AccessMode -> ShowS # show :: AccessMode -> String # showList :: [AccessMode] -> ShowS # | |
| RenderSQL AccessMode | Render an |
Defined in Squeal.PostgreSQL.Session.Transaction Methods renderSQL :: AccessMode -> ByteString # | |
data DeferrableMode #
The Deferrable transaction property has no effect
unless the transaction is also Serializable and ReadOnly.
When all three of these properties are selected for a transaction,
the transaction may block when first acquiring its snapshot,
after which it is able to run without the normal overhead of a
Serializable transaction and without any risk of contributing
to or being canceled by a serialization failure.
This longRunningMode is well suited for long-running reports or backups.
Constructors
| Deferrable | |
| NotDeferrable |
Instances
| Eq DeferrableMode | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods (==) :: DeferrableMode -> DeferrableMode -> Bool # (/=) :: DeferrableMode -> DeferrableMode -> Bool # | |
| Show DeferrableMode | |
Defined in Squeal.PostgreSQL.Session.Transaction Methods showsPrec :: Int -> DeferrableMode -> ShowS # show :: DeferrableMode -> String # showList :: [DeferrableMode] -> ShowS # | |
| RenderSQL DeferrableMode | Render a |
Defined in Squeal.PostgreSQL.Session.Transaction Methods renderSQL :: DeferrableMode -> ByteString # | |
class Monad pq => MonadPQ (db :: SchemasType) (pq :: Type -> Type) | pq -> db #
MonadPQ is an mtl style constraint, similar to
MonadState, for using LibPQ
to run Statements.
Instances
Arguments
| :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (GenericParams db params x xs, GenericRow row y ys) | |
| => Manipulation ('[] :: [(Symbol, RowType)]) db params row |
|
| -> Statement db x y |
Smart constructor for a data manipulation language statement
Arguments
| :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (GenericParams db params x xs, GenericRow row y ys) | |
| => Query ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db params row | |
| -> Statement db x y |
Smart constructor for a structured query language statement
data Statement (db :: SchemasType) x y where #
A Statement consists of a Manipulation
or a Query that can be run
in a MonadPQ.
Constructors
| Manipulation | Constructor for a data manipulation language statement |
Fields
| |
| Query | Constructor for a structured query language statement |
Fields
| |
Instances
| Profunctor (Statement db) | |
Defined in Squeal.PostgreSQL.Session.Statement Methods dimap :: (a -> b) -> (c -> d) -> Statement db b c -> Statement db a d # lmap :: (a -> b) -> Statement db b c -> Statement db a c # rmap :: (b -> c) -> Statement db a b -> Statement db a c # (#.) :: forall a b c q. Coercible c b => q b c -> Statement db a b -> Statement db a c # (.#) :: forall a b c q. Coercible b a => Statement db b c -> q a b -> Statement db a c # | |
| Functor (Statement db x) | |
| RenderSQL (Statement db x y) | |
Defined in Squeal.PostgreSQL.Session.Statement Methods renderSQL :: Statement db x y -> ByteString # | |
type GenericParams (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]) = (All (OidOfNull db) params, IsProductType x xs, AllZip (ToParam db) params xs) #
A GenericParams constraint to ensure that
a Haskell type is a product type,
all its terms have known Oids,
and can be encoded to corresponding
Postgres types.
type GenericRow (row :: [(Symbol, NullType)]) y (ys :: RecordCode) = (IsRecord y ys, AllZip FromField row ys) #
A GenericRow constraint to ensure that
a Haskell type is a record type,
and all its fields and can be decoded from corresponding
Postgres fields.
Arguments
| :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query ('[] :: [(Symbol, RowType)]) with db params columns |
|
| -> Manipulation with db params columns |
Convert a Query into a Manipulation.
pattern Returning_ #
Arguments
| :: SListI row | |
| => NP (Aliased (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params from)) row | row of values |
| -> ReturningClause with db params from row |
newtype Manipulation (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType) #
A Manipulation is a statement which may modify data in the database,
but does not alter its schemas. Examples are
insertIntos,
updates and
deleteFroms.
A queryStatement is also considered a Manipulation even though it does not modify data.
The general Manipulation type is parameterized by
with :: FromType- scope for allcommontable expressions,db :: SchemasType- scope for alltables andviews,params :: [NullType]- scope for allparameters,row :: RowType- return type of theManipulation.
Let's see some examples of Manipulations.
simple insert:
>>>type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint4, "col2" ::: 'Def :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[] '[] manp = insertInto_ #tab (Values_ (Set 2 `as` #col1 :* Default `as` #col2)) in printSQL manp :} INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES ((2 :: int4), DEFAULT)
out-of-line parameterized insert:
>>>type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manp :: Manipulation with (Public Schema) '[ 'NotNull 'PGint4] '[] manp = insertInto_ #tab $ Values_ (Default `as` #col1 :* Set (param @1) `as` #col2) in printSQL manp :} INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES (DEFAULT, ($1 :: int4))
in-line parameterized insert:
>>>type Columns = '["col1" ::: 'Def :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{data Row = Row { col1 :: Optional SOP.I ('Def :=> Int32), col2 :: Int32 } deriving stock (GHC.Generic) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) :}
>>>:{let manp :: Row -> Row -> Manipulation with (Public Schema) '[] '[] manp row1 row2 = insertInto_ #tab $ inlineValues row1 [row2] row1 = Row {col1 = Default, col2 = 2 :: Int32} row2 = Row {col1 = NotDefault (3 :: Int32), col2 = 4 :: Int32} in printSQL (manp row1 row2) :} INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES (DEFAULT, (2 :: int4)), ((3 :: int4), (4 :: int4))
returning insert:
>>>:{let manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4] manp = insertInto #tab (Values_ (Set 2 `as` #col1 :* Set 3 `as` #col2)) OnConflictDoRaise (Returning #col1) in printSQL manp :} INSERT INTO "tab" AS "tab" ("col1", "col2") VALUES ((2 :: int4), (3 :: int4)) RETURNING "col1" AS "col1"
upsert:
>>>type CustomersColumns = '["name" ::: 'NoDef :=> 'NotNull 'PGtext, "email" ::: 'NoDef :=> 'NotNull 'PGtext]>>>type CustomersConstraints = '["uq" ::: 'Unique '["name"]]>>>type CustomersSchema = '["customers" ::: 'Table (CustomersConstraints :=> CustomersColumns)]>>>:{let manp :: Manipulation with (Public CustomersSchema) '[] '[] manp = insertInto #customers (Values_ (Set "John Smith" `as` #name :* Set "[email protected]" `as` #email)) (OnConflict (OnConstraint #uq) (DoUpdate (Set (#excluded ! #email <> "; " <> #customers ! #email) `as` #email) [])) (Returning_ Nil) in printSQL manp :} INSERT INTO "customers" AS "customers" ("name", "email") VALUES ((E'John Smith' :: text), (E'[email protected]' :: text)) ON CONFLICT ON CONSTRAINT "uq" DO UPDATE SET "email" = ("excluded"."email" || ((E'; ' :: text) || "customers"."email"))
query insert:
>>>:{let manp :: Manipulation with (Public Schema) '[] '[] manp = insertInto_ #tab (Subquery (select Star (from (table #tab)))) in printSQL manp :} INSERT INTO "tab" AS "tab" SELECT * FROM "tab" AS "tab"
update:
>>>:{let manp :: Manipulation with (Public Schema) '[] '[] manp = update_ #tab (Set 2 `as` #col1) (#col1 ./= #col2) in printSQL manp :} UPDATE "tab" AS "tab" SET "col1" = (2 :: int4) WHERE ("col1" <> "col2")
delete:
>>>:{let manp :: Manipulation with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] manp = deleteFrom #tab NoUsing (#col1 .== #col2) (Returning Star) in printSQL manp :} DELETE FROM "tab" AS "tab" WHERE ("col1" = "col2") RETURNING *
delete and using clause:
>>>:{type Schema3 = '[ "tab" ::: 'Table ('[] :=> Columns) , "other_tab" ::: 'Table ('[] :=> Columns) , "third_tab" ::: 'Table ('[] :=> Columns) ] :}
>>>:{let manp :: Manipulation with (Public Schema3) '[] '[] manp = deleteFrom #tab (Using (table #other_tab & also (table #third_tab))) ( (#tab ! #col2 .== #other_tab ! #col2) .&& (#tab ! #col2 .== #third_tab ! #col2) ) (Returning_ Nil) in printSQL manp :} DELETE FROM "tab" AS "tab" USING "other_tab" AS "other_tab", "third_tab" AS "third_tab" WHERE (("tab"."col2" = "other_tab"."col2") AND ("tab"."col2" = "third_tab"."col2"))
with manipulation:
>>>type ProductsColumns = '["product" ::: 'NoDef :=> 'NotNull 'PGtext, "date" ::: 'Def :=> 'NotNull 'PGdate]>>>type ProductsSchema = '["products" ::: 'Table ('[] :=> ProductsColumns), "products_deleted" ::: 'Table ('[] :=> ProductsColumns)]>>>:{let manp :: Manipulation with (Public ProductsSchema) '[ 'NotNull 'PGdate] '[] manp = with (deleteFrom #products NoUsing (#date .< param @1) (Returning Star) `as` #del) (insertInto_ #products_deleted (Subquery (select Star (from (common #del))))) in printSQL manp :} WITH "del" AS (DELETE FROM "products" AS "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" AS "products_deleted" SELECT * FROM "del" AS "del"
Constructors
| UnsafeManipulation | |
Fields | |
Instances
| With Manipulation | |
Defined in Squeal.PostgreSQL.Manipulation Methods with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression Manipulation db params) with0 with1 -> Manipulation with1 db params row -> Manipulation with0 db params row # | |
| Eq (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods (==) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool # (/=) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool # | |
| Ord (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods compare :: Manipulation with db params columns -> Manipulation with db params columns -> Ordering # (<) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool # (<=) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool # (>) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool # (>=) :: Manipulation with db params columns -> Manipulation with db params columns -> Bool # max :: Manipulation with db params columns -> Manipulation with db params columns -> Manipulation with db params columns # min :: Manipulation with db params columns -> Manipulation with db params columns -> Manipulation with db params columns # | |
| Show (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods showsPrec :: Int -> Manipulation with db params columns -> ShowS # show :: Manipulation with db params columns -> String # showList :: [Manipulation with db params columns] -> ShowS # | |
| Generic (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Associated Types type Rep (Manipulation with db params columns) :: Type -> Type # Methods from :: Manipulation with db params columns -> Rep (Manipulation with db params columns) x # to :: Rep (Manipulation with db params columns) x -> Manipulation with db params columns # | |
| NFData (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods rnf :: Manipulation with db params columns -> () # | |
| RenderSQL (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: Manipulation with db params columns -> ByteString # | |
| type Rep (Manipulation with db params columns) | |
Defined in Squeal.PostgreSQL.Manipulation type Rep (Manipulation with db params columns) = D1 ('MetaData "Manipulation" "Squeal.PostgreSQL.Manipulation" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeManipulation" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderManipulation") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
type family Manipulation_ (db :: SchemasType) params row where ... #
The Manipulation_ type is parameterized by a db SchemasType,
against which it is type-checked, an input params Haskell Type,
and an ouput row Haskell Type.
Generally, params will be a Haskell tuple or record whose entries
may be referenced using positional
params and row will be a
Haskell record, whose entries will be targeted using overloaded labels.
A Manipulation_ can be run
using manipulateParams, or if params = ()
using manipulate.
Manipulation_ is a type family which resolves into a Manipulation,
so don't be fooled by the input params and output row Haskell Types,
which are converted into appropriate
Postgres [NullType] params and RowType rows.
Use manipulation to
fix actual Haskell input params and output rows.
>>>:set -XDeriveAnyClass -XDerivingStrategies>>>type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint8, "col2" ::: 'Def :=> 'NotNull 'PGtext]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{data Row = Row { col1 :: Maybe Int64, col2 :: String } deriving stock (GHC.Generic) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) :}
>>>:{let manp :: Manipulation_ (Public Schema) (Int64, Int64) Row manp = deleteFrom #tab NoUsing (#col1 .== param @1 + param @2) (Returning Star) stmt :: Statement (Public Schema) (Int64, Int64) Row stmt = manipulation manp :}
>>>:type manpmanp :: Manipulation '[] '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]] '[ 'NotNull 'PGint8, 'NotNull 'PGint8] '["col1" ::: 'Null 'PGint8, "col2" ::: 'NotNull 'PGtext]>>>:type stmtstmt :: Statement '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]] (Int64, Int64) Row
Equations
| Manipulation_ db params row = Manipulation ('[] :: [(Symbol, RowType)]) db (TuplePG params) (RowPG row) |
newtype ReturningClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (row :: RowType) #
A ReturningClause computes and returns value(s) based
on each row actually inserted, updated or deleted. This is primarily
useful for obtaining values that were supplied by defaults, such as a
serial sequence number. However, any expression using the table's columns
is allowed. Only rows that were successfully inserted or updated or
deleted will be returned. For example, if a row was locked
but not updated because an OnConflict
DoUpdate condition was not satisfied,
the row will not be returned. Returning Star will return all columns
in the row. Use Returning_ Nil in the common case where no return
values are desired.
Instances
| RenderSQL (ReturningClause with db params from row) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: ReturningClause with db params from row -> ByteString # | |
data UsingClause (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) where #
Specify additional tables with Using
an also list of table expressions, allowing columns
from other tables to appear in the WHERE condition.
This is similar to the list of tables that can be specified
in the FROM Clause of a SELECT statement;
for example, an alias for the table name can be specified.
Do not repeat the target table in the Using list,
unless you wish to set up a self-join.
NoUsing if no additional tables are to be used.
Constructors
| NoUsing :: forall (with :: FromType) (db :: SchemasType) (params :: [NullType]). UsingClause with db params ('[] :: [(Symbol, RowType)]) | |
| Using | |
Fields
| |
Arguments
| :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) | |
| => [SortExpression grp lat with db params from] | distinct on and return the first row in ordering |
| -> NP (Aliased (Expression grp lat with db params from)) columns | selection |
| -> TableExpression grp lat with db params from | intermediate virtual table |
| -> Query lat with db params columns |
Like selectDistinctOn but takes an NP list of Expressions instead
of a general Selection.
Arguments
| :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) | |
| => [SortExpression grp lat with db params from] | DISTINCT ON expression(s) and prepended to ORDER BY clause |
| -> Selection grp lat with db params from columns | selection |
| -> TableExpression grp lat with db params from | intermediate virtual table |
| -> Query lat with db params columns |
selectDistinctOn keeps only the first row of each set of rows where
the given expressions evaluate to equal. The DISTINCT ON expressions are
interpreted using the same rules as for ORDER BY. ORDER BY is used to
ensure that the desired row appears first.
The DISTINCT ON expression(s) must match the leftmost ORDER BY expression(s). The ORDER BY clause will normally contain additional expression(s) that determine the desired precedence of rows within each DISTINCT ON group.
In order to guarantee they match and reduce redundancy, this function will prepend the The DISTINCT ON expressions to the ORDER BY clause.
Arguments
| :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI columns, columns ~ (col ': cols)) | |
| => NP (Aliased (Expression grp lat with db params from)) columns | select list |
| -> TableExpression grp lat with db params from | intermediate virtual table |
| -> Query lat with db params columns |
Like selectDistinct but takes an NP list of Expressions instead
of a general Selection.
Arguments
| :: forall (columns :: [(Symbol, NullType)]) (col :: (Symbol, NullType)) (cols :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI columns, columns ~ (col ': cols)) | |
| => Selection grp lat with db params from columns | selection |
| -> TableExpression grp lat with db params from | intermediate virtual table |
| -> Query lat with db params columns |
After the select list has been processed, the result table can
be subject to the elimination of duplicate rows using selectDistinct.
Arguments
| :: forall (row :: [(Symbol, NullType)]) (x :: (Symbol, NullType)) (xs :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). (SListI row, row ~ (x ': xs)) | |
| => NP (Aliased (Expression grp lat with db params from)) row | select list |
| -> TableExpression grp lat with db params from | intermediate virtual table |
| -> Query lat with db params row |
Like select but takes an NP list of Expressions instead
of a general Selection.
Arguments
| :: forall (row :: [(Symbol, NullType)]) (x :: (Symbol, NullType)) (xs :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]). (SListI row, row ~ (x ': xs)) | |
| => Selection grp lat with db params from row | selection |
| -> TableExpression grp lat with db params from | intermediate virtual table |
| -> Query lat with db params row |
the TableExpression in the select command constructs an intermediate
virtual table by possibly combining tables, views, eliminating rows,
grouping, etc. This table is finally passed on to processing by
the select list. The Selection determines which columns of
the intermediate table are actually output.
data Selection (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: [(Symbol, RowType)]) (row :: RowType) where #
The simplest kinds of Selection are Star and DotStar which
emits all columns that a TableExpression produces. A select List
is a list of Expressions. A Selection could be a list of
WindowFunctions Over WindowDefinition. Additional Selections can
be selected with Also.
Constructors
| Star | |
| DotStar | |
| List | |
Fields
| |
| Over | |
Fields
| |
| Also | |
Fields
| |
Instances
| (Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsQualified tab col (Selection 'Ungrouped lat with db params from row1) | |
| (Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsQualified tab col (Selection ('Grouped bys) lat with db params from row1) | |
| (HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsLabel col (Selection 'Ungrouped lat with db params from row1) | |
Defined in Squeal.PostgreSQL.Query.Select | |
| (HasUnique tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsLabel col (Selection ('Grouped bys) lat with db params from row1) | |
Defined in Squeal.PostgreSQL.Query.Select | |
| (KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) | |
Defined in Squeal.PostgreSQL.Query.Select Methods as :: Expression grp lat with db params from ty -> Alias col -> Selection grp lat with db params from row # | |
| Additional (Selection grp lat with db params from :: RowType -> Type) | |
| IsString (Selection grp lat with db params from '["fromOnly" ::: 'NotNull 'PGtext]) | |
Defined in Squeal.PostgreSQL.Query.Select | |
| RenderSQL (Selection grp lat with db params from row) | |
Defined in Squeal.PostgreSQL.Query.Select Methods renderSQL :: Selection grp lat with db params from row -> ByteString # | |
nthValue :: forall (null :: PGType -> NullType) (ty :: PGType). '[null ty, 'NotNull 'PGint4] --#-> 'Null ty #
returns value evaluated at the row that is the nth row of the window frame (counting from 1); null if no such row
lastValue :: forall (ty :: NullType). ty -#-> ty #
returns value evaluated at the row that is the last row of the window frame
firstValue :: forall (ty :: NullType). ty -#-> ty #
returns value evaluated at the row that is the first row of the window frame
lead :: forall (ty :: NullType). '[ty, 'NotNull 'PGint4, ty] --#-> ty #
returns value evaluated at the row that is offset rows after the current row within the partition; if there is no such row, instead return default (which must be of the same type as value). Both offset and default are evaluated with respect to the current row.
lag :: forall (ty :: NullType). '[ty, 'NotNull 'PGint4, ty] --#-> ty #
returns value evaluated at the row that is offset rows before the current row within the partition; if there is no such row, instead return default (which must be of the same type as value). Both offset and default are evaluated with respect to the current row.
ntile :: 'NotNull 'PGint4 -#-> 'NotNull 'PGint4 #
integer ranging from 1 to the argument value, dividing the partition as equally as possible
>>>printSQL $ ntile (Window 5)ntile((5 :: int4))
cumeDist :: WinFun0 ('NotNull 'PGfloat8) #
cumulative distribution: (number of partition rows preceding or peer with current row) / total partition rows
>>>printSQL cumeDistcume_dist()
percentRank :: WinFun0 ('NotNull 'PGfloat8) #
relative rank of the current row: (rank - 1) / (total partition rows - 1)
>>>printSQL percentRankpercent_rank()
denseRank :: WinFun0 ('NotNull 'PGint8) #
rank of the current row without gaps; this function counts peer groups
>>>printSQL denseRankdense_rank()
rowNumber :: WinFun0 ('NotNull 'PGint8) #
number of the current row within its partition, counting from 1
>>>printSQL rowNumberrow_number()
rank :: WinFun0 ('NotNull 'PGint8) #
rank of the current row with gaps; same as rowNumber of its first peer
>>>printSQL rankrank()
unsafeWindowFunctionN :: forall (xs :: [NullType]) (y :: NullType). SListI xs => ByteString -> xs --#-> y #
escape hatch for defining multi-argument window functions
unsafeWindowFunction1 :: forall (x :: NullType) (y :: NullType). ByteString -> x -#-> y #
escape hatch for defining window functions
Arguments
| :: forall (bys :: [NullType]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). SListI bys | |
| => NP (Expression grp lat with db params from) bys | partitions |
| -> WindowDefinition grp lat with db params from |
The partitionBy clause within Over divides the rows into groups,
or partitions, that share the same values of the partitionBy Expression(s).
For each row, the window function is computed across the rows that fall into
the same partition as the current row.
Arguments
| :: forall grp lat with db params from (arg :: NullType). Expression grp lat with db params from arg | argument |
| -> WindowArg grp '[arg] lat with db params from |
Window invokes a WindowFunction on a single argument.
Arguments
| :: NP (Expression grp lat with db params from) args | arguments |
| -> WindowArg grp args lat with db params from |
Windows invokes a WindowFunction on multiple argument.
data WindowDefinition (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where #
A WindowDefinition is a set of table rows that are somehow related
to the current row
Constructors
| WindowDefinition | |
Fields
| |
Instances
| OrderBy (WindowDefinition grp) grp | |
Defined in Squeal.PostgreSQL.Expression.Window Methods orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> WindowDefinition grp lat with db params from -> WindowDefinition grp lat with db params from # | |
| RenderSQL (WindowDefinition grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods renderSQL :: WindowDefinition grp lat with db params from -> ByteString # | |
newtype WindowFunction (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) #
A window function performs a calculation across a set of table rows that are somehow related to the current row. This is comparable to the type of calculation that can be done with an aggregate function. However, window functions do not cause rows to become grouped into a single output row like non-window aggregate calls would. Instead, the rows retain their separate identities. Behind the scenes, the window function is able to access more than just the current row of the query result.
Constructors
| UnsafeWindowFunction | |
Fields | |
Instances
| Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # | |
| Eq (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods (==) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool # (/=) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool # | |
| Ord (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods compare :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Ordering # (<) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool # (<=) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool # (>) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool # (>=) :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> Bool # max :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty # min :: WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty -> WindowFunction grp lat with db params from ty # | |
| Show (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods showsPrec :: Int -> WindowFunction grp lat with db params from ty -> ShowS # show :: WindowFunction grp lat with db params from ty -> String # showList :: [WindowFunction grp lat with db params from ty] -> ShowS # | |
| Generic (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Associated Types type Rep (WindowFunction grp lat with db params from ty) :: Type -> Type # Methods from :: WindowFunction grp lat with db params from ty -> Rep (WindowFunction grp lat with db params from ty) x # to :: Rep (WindowFunction grp lat with db params from ty) x -> WindowFunction grp lat with db params from ty # | |
| NFData (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods rnf :: WindowFunction grp lat with db params from ty -> () # | |
| RenderSQL (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods renderSQL :: WindowFunction grp lat with db params from ty -> ByteString # | |
| type Rep (WindowFunction grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window type Rep (WindowFunction grp lat with db params from ty) = D1 ('MetaData "WindowFunction" "Squeal.PostgreSQL.Expression.Window" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeWindowFunction" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderWindowFunction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
data WindowArg (grp :: Grouping) (args :: [NullType]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #
WindowArgs are used for the input of WindowFunctions.
Constructors
| WindowArg | |
Fields
| |
Instances
| Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # | |
| FilterWhere (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) grp | |
Defined in Squeal.PostgreSQL.Expression.Window Methods filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> WindowArg grp xs lat with db params from -> WindowArg grp xs lat with db params from # | |
| Generic (WindowArg grp args lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Window | |
| SListI args => RenderSQL (WindowArg grp args lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods renderSQL :: WindowArg grp args lat with db params from -> ByteString # | |
| type Rep (WindowArg grp args lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Window type Rep (WindowArg grp args lat with db params from) = D1 ('MetaData "WindowArg" "Squeal.PostgreSQL.Expression.Window" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'False) (C1 ('MetaCons "WindowArg" 'PrefixI 'True) (S1 ('MetaSel ('Just "windowArgs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NP (Expression grp lat with db params from) args)) :*: S1 ('MetaSel ('Just "windowFilter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Condition grp lat with db params from]))) | |
type WinFun0 (x :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowFunction grp lat with db params from x | cannot reference aliases |
A RankNType for window functions with no arguments.
type (-#->) (x :: NullType) (y :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowArg grp '[x] lat with db params from | input |
| -> WindowFunction grp lat with db params from y | output |
A RankNType for window functions with 1 argument.
type (--#->) (xs :: [NullType]) (y :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). WindowArg grp xs lat with db params from | inputs |
| -> WindowFunction grp lat with db params from y | output |
A RankNType for window functions with a fixed-length
list of heterogeneous arguments.
Use the *: operator to end your argument lists.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (x :: PGType). Expression 'Ungrouped lat with db params from ('Null x) | argument |
| -> AggregateArg '['NotNull x] lat with db params from |
distinctNotNull invokes the aggregate once for each
distinct, not null value of the expression found in the input.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (x :: PGType). Expression 'Ungrouped lat with db params from ('Null x) | argument |
| -> AggregateArg '['NotNull x] lat with db params from |
allNotNull invokes the aggregate on a single
argument once for each input row where the argument
is not null
Arguments
| :: forall lat with db params from (x :: NullType). Expression 'Ungrouped lat with db params from x | argument |
| -> AggregateArg '[x] lat with db params from |
All invokes the aggregate on a single
argument once for each input row.
Arguments
| :: NP (Expression 'Ungrouped lat with db params from) xs | arguments |
| -> AggregateArg xs lat with db params from |
All invokes the aggregate on multiple
arguments once for each input row.
Arguments
| :: forall lat with db params from (x :: NullType). Expression 'Ungrouped lat with db params from x | argument |
| -> AggregateArg '[x] lat with db params from |
Distinct invokes the aggregate once for each
distinct value of the expression found in the input.
Arguments
| :: NP (Expression 'Ungrouped lat with db params from) xs | arguments |
| -> AggregateArg xs lat with db params from |
Distincts invokes the aggregate once for each
distinct set of values, for multiple expressions, found in the input.
class Aggregate (arg :: [NullType] -> k -> k1 -> k2 -> k3 -> k4 -> Type) (expr :: k -> k1 -> k2 -> k3 -> k4 -> NullType -> Type) | expr -> arg where #
Aggregate functions compute a single result from a set of input values.
Aggregate functions can be used as Grouped Expressions as well
as WindowFunctions.
Methods
countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). expr lat with db params from ('NotNull 'PGint8) #
A special aggregation that does not require an input
>>>:{let expression :: Expression ('Grouped bys) '[] with db params from ('NotNull 'PGint8) expression = countStar in printSQL expression :} count(*)
Arguments
| :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from | argument |
| -> expr lat with db params from ('NotNull 'PGint8) |
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8) expression = count (All #col) in printSQL expression :} count(ALL "col")
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGSum ty)) |
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric) expression = sum_ (Distinct #col & filterWhere (#col .< 100)) in printSQL expression :} sum(DISTINCT "col") FILTER (WHERE ("col" < (100.0 :: numeric)))
Arguments
| :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from | argument |
| -> expr lat with db params from ('Null ('PGvararray ty)) |
input values, including nulls, concatenated into an array
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null ('PGvararray ('Null 'PGnumeric))) expression = arrayAgg (All #col & orderBy [AscNullsFirst #col] & filterWhere (#col .< 100)) in printSQL expression :} array_agg(ALL "col" ORDER BY "col" ASC NULLS FIRST) FILTER (WHERE ("col" < (100.0 :: numeric)))
Arguments
| :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from | argument |
| -> expr lat with db params from ('Null 'PGjson) |
aggregates values as a JSON array
Arguments
| :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[ty] lat with db params from | argument |
| -> expr lat with db params from ('Null 'PGjsonb) |
aggregates values as a JSON array
Arguments
| :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral | |
| => arg '[null int] lat with db params from | argument |
| -> expr lat with db params from ('Null int) |
the bitwise AND of all non-null input values, or null if none
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4) expression = bitAnd (Distinct #col) in printSQL expression :} bit_and(DISTINCT "col")
Arguments
| :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral | |
| => arg '[null int] lat with db params from | argument |
| -> expr lat with db params from ('Null int) |
the bitwise OR of all non-null input values, or null if none
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4) expression = bitOr (All #col) in printSQL expression :} bit_or(ALL "col")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from | argument |
| -> expr lat with db params from ('Null 'PGbool) |
true if all input values are true, otherwise false
>>>:{let winFun :: WindowFunction 'Ungrouped '[] with db params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool) winFun = boolAnd (Window #col) in printSQL winFun :} bool_and("col")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from | argument |
| -> expr lat with db params from ('Null 'PGbool) |
true if at least one input value is true, otherwise false
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool) expression = boolOr (All #col) in printSQL expression :} bool_or(ALL "col")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGbool] lat with db params from | argument |
| -> expr lat with db params from ('Null 'PGbool) |
equivalent to boolAnd
>>>:{let expression :: Expression ('Grouped bys) '[] with db params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool) expression = every (Distinct #col) in printSQL expression :} every(DISTINCT "col")
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null ty) |
maximum value of expression across all input values
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null ty) |
minimum value of expression across all input values
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
the average (arithmetic mean) of all input values
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
correlation coefficient
>>>:{let expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = corr (Alls (#y *: #x)) in printSQL expression :} corr(ALL "y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
population covariance
>>>:{let expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = covarPop (Alls (#y *: #x)) in printSQL expression :} covar_pop(ALL "y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
sample covariance
>>>:{let winFun :: WindowFunction 'Ungrouped '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) winFun = covarSamp (Windows (#y *: #x)) in printSQL winFun :} covar_samp("y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
average of the independent variable (sum(X)/N)
>>>:{let expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = regrAvgX (Alls (#y *: #x)) in printSQL expression :} regr_avgx(ALL "y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
average of the dependent variable (sum(Y)/N)
>>>:{let winFun :: WindowFunction 'Ungrouped '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) winFun = regrAvgY (Windows (#y *: #x)) in printSQL winFun :} regr_avgy("y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGint8) |
number of input rows in which both expressions are nonnull
>>>:{let winFun :: WindowFunction 'Ungrouped '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8) winFun = regrCount (Windows (#y *: #x)) in printSQL winFun :} regr_count("y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs
>>>:{let expression :: Expression ('Grouped g) '[] c s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = regrIntercept (Alls (#y *: #x)) in printSQL expression :} regr_intercept(ALL "y", "x")
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
regr_r2(Y, X), square of the correlation coefficient
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
regr_slope(Y, X), slope of the least-squares-fit linear equation
determined by the (X, Y) pairs
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
regr_sxx(Y, X), sum(X^2) - sum(X)^2/N
(“sum of squares” of the independent variable)
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
regr_sxy(Y, X), sum(X*Y) - sum(X) * sum(Y)/N
(“sum of products” of independent times dependent variable)
Arguments
| :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null 'PGfloat8, null 'PGfloat8] lat with db params from | arguments |
| -> expr lat with db params from ('Null 'PGfloat8) |
regr_syy(Y, X), sum(Y^2) - sum(Y)^2/N
(“sum of squares” of the dependent variable)
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
historical alias for stddevSamp
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
population standard deviation of the input values
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
sample standard deviation of the input values
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
historical alias for varSamp
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
population variance of the input values (square of the population standard deviation)
Arguments
| :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). arg '[null ty] lat with db params from | argument |
| -> expr lat with db params from ('Null (PGAvg ty)) |
sample variance of the input values (square of the sample standard deviation)
Instances
| Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # | |
| Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # | |
data AggregateArg (xs :: [NullType]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #
AggregateArgs are used for the input of Aggregate Expressions.
Constructors
| AggregateAll | |
Fields
| |
| AggregateDistinct | |
Fields
| |
Instances
| Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # | |
| OrderBy (AggregateArg xs) 'Ungrouped | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression 'Ungrouped lat with db params from] -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from # | |
| FilterWhere AggregateArg 'Ungrouped | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition 'Ungrouped lat with db params from -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from # | |
| SListI xs => RenderSQL (AggregateArg xs lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: AggregateArg xs lat with db params from -> ByteString # | |
class FilterWhere (arg :: k -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (grp :: Grouping) | arg -> grp where #
Permits filtering
WindowArgs and AggregateArgs
Methods
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from | include rows which evaluate to true |
| -> arg xs lat with db params from | |
| -> arg xs lat with db params from |
If filterWhere is specified, then only the input rows for which
the Condition evaluates to true are fed to the aggregate function;
other rows are discarded.
Instances
| FilterWhere AggregateArg 'Ungrouped | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition 'Ungrouped lat with db params from -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from # | |
| FilterWhere (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) grp | |
Defined in Squeal.PostgreSQL.Expression.Window Methods filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> WindowArg grp xs lat with db params from -> WindowArg grp xs lat with db params from # | |
type family PGSum (ty :: PGType) :: PGType where ... #
Equations
| PGSum 'PGint2 = 'PGint8 | |
| PGSum 'PGint4 = 'PGint8 | |
| PGSum 'PGint8 = 'PGnumeric | |
| PGSum 'PGfloat4 = 'PGfloat4 | |
| PGSum 'PGfloat8 = 'PGfloat8 | |
| PGSum 'PGnumeric = 'PGnumeric | |
| PGSum 'PGinterval = 'PGinterval | |
| PGSum 'PGmoney = 'PGmoney | |
| PGSum pg = TypeError ('Text "Squeal type error: Cannot sum with argument type " :<>: 'ShowType pg) :: PGType |
type family PGAvg (ty :: PGType) :: PGType where ... #
Equations
| PGAvg 'PGint2 = 'PGnumeric | |
| PGAvg 'PGint4 = 'PGnumeric | |
| PGAvg 'PGint8 = 'PGnumeric | |
| PGAvg 'PGnumeric = 'PGnumeric | |
| PGAvg 'PGfloat4 = 'PGfloat8 | |
| PGAvg 'PGfloat8 = 'PGfloat8 | |
| PGAvg 'PGinterval = 'PGinterval | |
| PGAvg pg = TypeError ('Text "Squeal type error: No average for " :<>: 'ShowType pg) :: PGType |
Arguments
| :: forall hask (xs :: RecordCode) (columns :: [(Symbol, ColumnType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask xs, AllZip InlineColumn xs columns) | |
| => hask | record |
| -> NP (Aliased (Optional (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)])))) columns |
Inline a Haskell record as a list of columns.
Arguments
| :: forall hask (fields :: RecordCode) (row :: [(Symbol, NullType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]). (IsRecord hask fields, AllZip InlineField fields row) | |
| => hask | record |
| -> NP (Aliased (Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) with db params ('[] :: [(Symbol, RowType)]))) row |
Inline a Haskell record as a row of expressions.
The Inline class allows embedding a Haskell value directly
as an Expression using inline.
>>>printSQL (inline 'a')(E'a' :: char(1))
>>>printSQL (inline (1 :: Double))(1.0 :: float8)
>>>printSQL (inline (Json ([1, 2] :: [Double])))('[1.0,2.0]' :: json)
>>>printSQL (inline (Enumerated GT))'GT'
Instances
class InlineParam x (ty :: NullType) where #
Methods
inlineParam :: x -> Expr ty #
Instances
| (Inline x, pg ~ PG x) => InlineParam x ('NotNull pg) | |
Defined in Squeal.PostgreSQL.Expression.Inline Methods inlineParam :: x -> Expr ('NotNull pg) # | |
| (Inline x, pg ~ PG x) => InlineParam (Maybe x) ('Null pg) | |
Defined in Squeal.PostgreSQL.Expression.Inline Methods inlineParam :: Maybe x -> Expr ('Null pg) # | |
class InlineField (field :: (Symbol, Type)) (fieldpg :: (Symbol, NullType)) where #
Lifts Inline to fields.
Methods
inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P field -> Aliased (Expression grp lat with db params from) fieldpg #
Instances
| (KnownSymbol alias, InlineParam x ty) => InlineField (alias ::: x) (alias ::: ty) | |
Defined in Squeal.PostgreSQL.Expression.Inline Methods inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (alias ::: x) -> Aliased (Expression grp lat with db params from) (alias ::: ty) # | |
class InlineColumn (field :: (Symbol, Type)) (column :: (Symbol, ColumnType)) where #
Lifts Inline to a column entry
Methods
inlineColumn :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P field -> Aliased (Optional (Expression grp lat with db params from)) column #
Haskell record field as a inline column
Instances
| (KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: x) (col ::: ('NoDef :=> ty)) | |
Defined in Squeal.PostgreSQL.Expression.Inline | |
| (KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) | |
Defined in Squeal.PostgreSQL.Expression.Inline | |
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType). Expression grp lat with db params from ty1 | expression |
| -> Operator ty1 ty2 ('Null 'PGbool) | operator |
| -> Expression grp lat with db params from ('Null ('PGvararray ty2)) | array |
| -> Condition grp lat with db params from |
The right-hand side is a parenthesized expression, which must yield an array
value. The left-hand expression is evaluated and compared to each element of
the array using the given Operator, which must yield a Boolean result. The
result of arrAny is true if any true result is obtained. The result is
false if no true result is found (including the case where the array
has zero elements).
If the array expression yields a null array, the result of arrAny will
be null. If the left-hand expression yields null, the result of arrAny is
ordinarily null (though a non-strict comparison Operator could possibly
yield a different result). Also, if the right-hand array contains any
null elements and no true comparison result is obtained, the result of
arrAny will be null, not false
(again, assuming a strict comparison Operator).
This is in accordance with SQL's normal rules for
Boolean combinations of null values.
>>>printSQL $ arrAny true (.==) (array [true, false, null_])(TRUE = ANY (ARRAY[TRUE, FALSE, NULL]))>>>printSQL $ arrAny "hi" like (array ["bi","hi"])((E'hi' :: text) LIKE ANY (ARRAY[(E'bi' :: text), (E'hi' :: text)]))
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType). Expression grp lat with db params from ty1 | expression |
| -> Operator ty1 ty2 ('Null 'PGbool) | operator |
| -> Expression grp lat with db params from ('Null ('PGvararray ty2)) | array |
| -> Condition grp lat with db params from |
The right-hand side is a parenthesized expression,
which must yield an array value. The left-hand expression
is evaluated and compared to each element of the array using
the given Operator, which must yield a Boolean result.
The result of arrAll is true if all comparisons yield true
(including the case where the array has zero elements).
The result is false if any false result is found.
If the array expression yields a null array,
the result of arrAll will be null. If the left-hand expression yields null,
the result of arrAll is ordinarily null
(though a non-strict comparison Operator
could possibly yield a different result).
Also, if the right-hand array contains any null
elements and no false comparison result is obtained,
the result of arrAll will be null, not true
(again, assuming a strict comparison Operator).
This is in accordance with SQL's normal rules for Boolean
combinations of null values.
>>>printSQL $ arrAll true (.==) (array [true, false, null_])(TRUE = ALL (ARRAY[TRUE, FALSE, NULL]))>>>printSQL $ arrAll "hi" like (array ["bi","hi"])((E'hi' :: text) LIKE ALL (ARRAY[(E'bi' :: text), (E'hi' :: text)]))
unnest :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) -|-> ("unnest" ::: '["unnest" ::: ty]) #
Expand an array to a set of rows
>>>printSQL $ unnest (array [null_, false, true])unnest(ARRAY[NULL, FALSE, TRUE])
Arguments
| :: forall (i :: Nat) (j :: Nat) (m :: Nat) (n :: Nat) (ty :: NullType). (1 <= i, i <= m, KnownNat i, 1 <= j, j <= n, KnownNat j) | |
| => 'NotNull ('PGfixarray '[m, n] ty) --> ty | matrix index |
Typesafe indexing of fixed size matrices.
>>>printSQL $ array2 ((true *: false) *: (false *: true)) & index2 @1 @2(ARRAY[[TRUE, FALSE], [FALSE, TRUE]])[1][2]
Arguments
| :: forall (i :: Nat) (n :: Nat) (ty :: NullType). (1 <= i, i <= n, KnownNat i) | |
| => 'NotNull ('PGfixarray '[n] ty) --> ty | vector index |
Typesafe indexing of fixed length arrays.
>>>printSQL $ array1 (true *: false) & index1 @1(ARRAY[TRUE, FALSE])[1]
Arguments
| :: forall (null :: PGType -> NullType) (ty :: NullType). Word64 | index |
| -> null ('PGvararray ty) --> NullifyType ty |
>>>printSQL $ array [null_, false, true] & index 2(ARRAY[NULL, FALSE, TRUE])[2]
cardinality :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) --> null 'PGint8 #
>>>printSQL $ cardinality (array [null_, false, true])cardinality(ARRAY[NULL, FALSE, TRUE])
Arguments
| :: forall (tys :: [NullType]) (tyss :: [[NullType]]) (n1 :: Nat) (ty :: NullType) (n2 :: Nat) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). (All ([NullType] ~ tys) tyss, All (SListI :: [NullType] -> Constraint) tyss, Length tyss ~ n1, All (NullType ~ ty) tys, Length tys ~ n2) | |
| => NP (NP (Expression grp lat with db params from)) tyss | matrix elements |
| -> Expression grp lat with db params from (null ('PGfixarray '[n1, n2] ty)) |
Construct a fixed size matrix.
>>>printSQL $ array2 ((null_ :* false *: true) *: (false :* null_ *: true))ARRAY[[NULL, FALSE, TRUE], [FALSE, NULL, TRUE]]
>>>:type array2 ((null_ :* false *: true) *: (false :* null_ *: true))array2 ((null_ :* false *: true) *: (false :* null_ *: true)) :: Expression grp lat with db params from (null ('PGfixarray '[2, 3] ('Null 'PGbool)))
Arguments
| :: forall (n :: Nat) (tys :: [NullType]) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). (n ~ Length tys, All (NullType ~ ty) tys) | |
| => NP (Expression grp lat with db params from) tys | array elements |
| -> Expression grp lat with db params from (null ('PGfixarray '[n] ty)) |
Construct a fixed length array.
>>>printSQL $ array1 (null_ :* false *: true)ARRAY[NULL, FALSE, TRUE]
>>>:type array1 (null_ :* false *: true)array1 (null_ :* false *: true) :: Expression grp lat with db params from (null ('PGfixarray '[3] ('Null 'PGbool)))
array0 :: forall (db :: SchemasType) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). TypeExpression db ty -> Expression grp lat with db params from (null ('PGvararray ty)) #
Safely construct an empty array.
>>>printSQL $ array0 text(ARRAY[] :: text[])
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). [Expression grp lat with db params from ty] | array elements |
| -> Expression grp lat with db params from (null ('PGvararray ty)) |
Construct an array.
>>>printSQL $ array [null_, false, true]ARRAY[NULL, FALSE, TRUE]
isNotUnknown :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #
is true or false
>>>printSQL $ true & isNotUnknown(TRUE IS NOT UNKNOWN)
isUnknown :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #
is unknown
>>>printSQL $ true & isUnknown(TRUE IS UNKNOWN)
isNotFalse :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #
is true or unknown
>>>printSQL $ true & isNotFalse(TRUE IS NOT FALSE)
isFalse :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #
is false
>>>printSQL $ true & isFalse(TRUE IS FALSE)
isNotTrue :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #
is false or unknown
>>>printSQL $ true & isNotTrue(TRUE IS NOT TRUE)
isTrue :: forall (null0 :: PGType -> NullType) (null1 :: PGType -> NullType). null0 'PGbool --> null1 'PGbool #
is true
>>>printSQL $ true & isTrue(TRUE IS TRUE)
isNotDistinctFrom :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('NotNull 'PGbool) #
equal, treating null like an ordinary value
>>>printSQL $ true `isNotDistinctFrom` null_(TRUE IS NOT DISTINCT FROM NULL)
isDistinctFrom :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #
not equal, treating null like an ordinary value
>>>printSQL $ true `isDistinctFrom` null_(TRUE IS DISTINCT FROM NULL)
notBetweenSymmetric :: BetweenExpr #
not between, after sorting the comparison values
>>>printSQL $ true `notBetweenSymmetric` (null_, false)TRUE NOT BETWEEN SYMMETRIC NULL AND FALSE
betweenSymmetric :: BetweenExpr #
between, after sorting the comparison values
>>>printSQL $ true `betweenSymmetric` (null_, false)TRUE BETWEEN SYMMETRIC NULL AND FALSE
>>>printSQL $ true `notBetween` (null_, false)TRUE NOT BETWEEN NULL AND FALSE
between :: BetweenExpr #
>>>printSQL $ true `between` (null_, false)TRUE BETWEEN NULL AND FALSE
least :: forall (ty :: NullType). FunctionVar ty ty ty #
>>>printSQL $ least [null_] currentTimestampLEAST(NULL, CURRENT_TIMESTAMP)
greatest :: forall (ty :: NullType). FunctionVar ty ty ty #
>>>let expr = greatest [param @1] currentTimestamp>>>printSQL exprGREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)
(.>) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #
>>>printSQL $ true .> null_(TRUE > NULL)
(.<=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #
>>>printSQL $ true .<= null_(TRUE <= NULL)
(.<) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #
>>>printSQL $ true .< null_(TRUE < NULL)
(.>=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #
>>>printSQL $ true .>= null_(TRUE >= NULL)
(./=) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #
>>>printSQL $ true ./= null_(TRUE <> NULL)
(.==) :: forall k (null0 :: k -> NullType) (ty :: k) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) infix 4 #
type BetweenExpr #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). Expression grp lat with db params from ty | |
| -> (Expression grp lat with db params from ty, Expression grp lat with db params from ty) | bounds |
| -> Condition grp lat with db params from |
A RankNType for comparison expressions like between.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tydef :: Symbol) (row :: RowType) (field :: Symbol) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). (Has sch db schema, Has tydef schema ('Typedef ('PGcomposite row)), Has field row ty) | |
| => QualifiedAlias sch tydef | row type |
| -> Alias field | field name |
| -> Expression grp lat with db params from ('NotNull ('PGcomposite row)) | |
| -> Expression grp lat with db params from ty |
>>>:{type Complex = 'PGcomposite '[ "real" ::: 'NotNull 'PGfloat8 , "imaginary" ::: 'NotNull 'PGfloat8 ] type Schema = '["complex" ::: 'Typedef Complex] :}
>>>let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression lat '[] grp (Public Schema) from params ('NotNull Complex)>>>printSQL $ i & field #complex #imaginary(ROW((0.0 :: float8), (1.0 :: float8))::"complex")."imaginary"
rowStar :: forall (tab :: Symbol) (from :: [(Symbol, RowType)]) (row :: RowType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (null :: PGType -> NullType). Has tab from row => Alias tab -> Expression grp lat with db params from (null ('PGcomposite row)) #
A row constructor on all columns in a table expression.
Arguments
| :: forall (row :: [(Symbol, NullType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (null :: PGType -> NullType). SListI row | |
| => NP (Aliased (Expression grp lat with db params from)) row | zero or more expressions for the row field values |
| -> Expression grp lat with db params from (null ('PGcomposite row)) |
A row constructor is an expression that builds a row value (also called a composite value) using values for its member fields.
>>>:{type Complex = 'PGcomposite '[ "real" ::: 'NotNull 'PGfloat8 , "imaginary" ::: 'NotNull 'PGfloat8 ] :}
>>>let i = row (0 `as` #real :* 1 `as` #imaginary) :: Expression grp lat with db params from ('NotNull Complex)>>>printSQL iROW((0.0 :: float8), (1.0 :: float8))
jsonbToRecordSet :: JsonToRecordFunction 'PGjsonb #
Builds an arbitrary set of records from a binary JSON array of objects.
jsonToRecordSet :: JsonToRecordFunction 'PGjson #
Builds an arbitrary set of records from a JSON array of objects.
jsonbToRecord :: JsonToRecordFunction 'PGjsonb #
Builds an arbitrary record from a binary JSON object.
jsonToRecord :: JsonToRecordFunction 'PGjson #
Builds an arbitrary record from a JSON object.
jsonbPopulateRecordSet :: JsonPopulateFunction "jsonb_populate_record_set" 'PGjsonb #
Expands the outermost array of objects in the given binary JSON expression to a set of rows whose columns match the record type defined by the given table.
jsonPopulateRecordSet :: JsonPopulateFunction "json_populate_record_set" 'PGjson #
Expands the outermost array of objects in the given JSON expression to a set of rows whose columns match the record type defined by the given table.
jsonbPopulateRecord :: JsonPopulateFunction "jsonb_populate_record" 'PGjsonb #
Expands the binary JSON expression to a row whose columns match the record type defined by the given table.
jsonPopulateRecord :: JsonPopulateFunction "json_populate_record" 'PGjson #
Expands the JSON expression to a row whose columns match the record type defined by the given table.
jsonbObjectKeys :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_object_keys" ::: '["jsonb_object_keys" ::: 'NotNull 'PGtext]) #
Returns set of keys in the outermost JSON object.
>>>printSQL (jsonbObjectKeys (inline (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))
jsonObjectKeys :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_object_keys" ::: '["json_object_keys" ::: 'NotNull 'PGtext]) #
Returns set of keys in the outermost JSON object.
>>>printSQL (jsonObjectKeys (inline (Json (object ["a" .= "foo", "b" .= "bar"]))))json_object_keys(('{"a":"foo","b":"bar"}' :: json))
jsonbEachText :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_each_text" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]) #
Expands the outermost binary JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonbEachText (inline (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))
jsonEachText :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_each_text" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGtext]) #
Expands the outermost JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonEachText (inline (Json (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))
jsonbEach :: forall (null :: PGType -> NullType). null 'PGjsonb -|-> ("jsonb_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]) #
Expands the outermost binary JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonbEach (inline (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))
jsonEach :: forall (null :: PGType -> NullType). null 'PGjson -|-> ("json_each" ::: '["key" ::: 'NotNull 'PGtext, "value" ::: 'NotNull 'PGjson]) #
Expands the outermost JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonEach (inline (Json (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))
jsonbPretty :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGtext #
Returns its argument as indented JSON text.
jsonbInsert :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext)), null 'PGjsonb, null 'PGbool] ---> null 'PGjsonb #
jsonbInsert target path new_value insert_after
Returns target with new_value inserted. If target section designated by
path is in a JSONB array, new_value will be inserted before target or after
if insert_after is true.
If target section designated by
path is in JSONB object, new_value will be inserted only if target does not
exist. As with the path orientated operators, negative integers that appear
in path count from the end of JSON arrays.
jsonbSet :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null ('PGvararray ('NotNull 'PGtext)), null 'PGjsonb, null 'PGbool] ---> null 'PGjsonb #
jsonbSet target path new_value create_missing
Returns target with the section designated by path replaced by new_value,
or with new_value added if create_missing is
true and the
item designated by path does not exist. As with the path orientated
operators, negative integers that appear in path count from the end of JSON
arrays.
jsonbStripNulls :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGjsonb #
Returns its argument with all object fields that have null values omitted. Other null values are untouched.
jsonStripNulls :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGjson #
Returns its argument with all object fields that have null values omitted. Other null values are untouched.
jsonbTypeof :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGtext #
Returns the type of the outermost binary JSON value as a text string. Possible types are object, array, string, number, boolean, and null.
jsonTypeof :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGtext #
Returns the type of the outermost JSON value as a text string. Possible types are object, array, string, number, boolean, and null.
jsonbArrayLength :: forall (null :: PGType -> NullType). null 'PGjsonb --> null 'PGint4 #
Returns the number of elements in the outermost binary JSON array.
jsonArrayLength :: forall (null :: PGType -> NullType). null 'PGjson --> null 'PGint4 #
Returns the number of elements in the outermost JSON array.
jsonbZipObject :: forall (null :: PGType -> NullType). '[null ('PGvararray ('NotNull 'PGtext)), null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGjsonb #
This is an alternate form of jsonbObject that takes two arrays; one for
keys and one for values, that are zipped pairwise to create a binary JSON
object.
jsonZipObject :: forall (null :: PGType -> NullType). '[null ('PGvararray ('NotNull 'PGtext)), null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGjson #
This is an alternate form of jsonObject that takes two arrays; one for
keys and one for values, that are zipped pairwise to create a JSON object.
jsonbObject :: forall (null :: PGType -> NullType) (n :: Nat). null ('PGfixarray '[n, 2] ('NotNull 'PGtext)) --> null 'PGjsonb #
Builds a binary JSON object out of a text array. The array must have two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair.
jsonObject :: forall (null :: PGType -> NullType) (n :: Nat). null ('PGfixarray '[n, 2] ('NotNull 'PGtext)) --> null 'PGjson #
Builds a JSON object out of a text array. The array must have two dimensions such that each inner array has exactly two elements, which are taken as a key/value pair.
jsonbBuildArray :: forall (tuple :: [NullType]) (null :: PGType -> NullType). SListI tuple => tuple ---> null 'PGjsonb #
Builds a possibly-heterogeneously-typed (binary) JSON array out of a variadic argument list.
jsonBuildArray :: forall (tuple :: [NullType]) (null :: PGType -> NullType). SListI tuple => tuple ---> null 'PGjson #
Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list.
rowToJson :: forall (null :: PGType -> NullType) (ty :: RowType). null ('PGcomposite ty) --> null 'PGjson #
Returns the row as a JSON object.
arrayToJson :: forall (null :: PGType -> NullType) (ty :: NullType). null ('PGvararray ty) --> null 'PGjson #
Returns the array as a JSON array. A PostgreSQL multidimensional array becomes a JSON array of arrays.
toJsonb :: forall (null :: PGType -> NullType) (ty :: PGType). null ty --> null 'PGjsonb #
Returns the value as jsonb. Arrays and composites are converted (recursively) to arrays and objects; otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion; otherwise, a scalar value is produced. For any scalar type other than a number, a Boolean, or a null value, the text representation will be used, in such a fashion that it is a valid jsonb value.
toJson :: forall (null :: PGType -> NullType) (ty :: PGType). null ty --> null 'PGjson #
Returns the value as json. Arrays and composites are converted (recursively) to arrays and objects; otherwise, if there is a cast from the type to json, the cast function will be used to perform the conversion; otherwise, a scalar value is produced. For any scalar type other than a number, a Boolean, or a null value, the text representation will be used, in such a fashion that it is a valid json value.
(#-.) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) (null 'PGjsonb) infixl 6 #
Delete the field or element with specified path (for JSON arrays, negative integers count from the end)
(.-.) :: forall (key :: PGType) (null :: PGType -> NullType). In key '['PGtext, 'PGvararray ('NotNull 'PGtext), 'PGint4, 'PGint2] => Operator (null 'PGjsonb) (null key) (null 'PGjsonb) infixl 6 #
Delete a key or keys from a JSON object, or remove an array element.
If the right operand is
text : Delete key / value pair or string element from left operand.
Key / value pairs are matched based on their key value,
text[] : Delete multiple key / value pairs or string elements
from left operand. Key / value pairs are matched based on their key value,
integer : Delete the array element with specified index (Negative integers
count from the end). Throws an error if top level container is not an array.
(.?&) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGbool) infixl 9 #
Do all of these array strings exist as top-level keys?
(.?|) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGbool) infixl 9 #
Do any of these array strings exist as top-level keys?
(.?) :: forall (null :: PGType -> NullType). Operator (null 'PGjsonb) (null 'PGtext) ('Null 'PGbool) infixl 9 #
Does the string exist as a top-level key within the JSON value?
(.#>>) :: forall (json :: PGType) (null :: PGType -> NullType). In json PGJsonType => Operator (null json) (null ('PGvararray ('NotNull 'PGtext))) ('Null 'PGtext) infixl 8 #
Get JSON value at a specified path as text.
(.#>) :: forall (json :: PGType) (null :: PGType -> NullType). In json PGJsonType => Operator (null json) (null ('PGvararray ('NotNull 'PGtext))) ('Null json) infixl 8 #
Get JSON value at a specified path.
(.->>) :: forall (json :: PGType) (key :: PGType) (null :: PGType -> NullType). (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) ('Null 'PGtext) infixl 8 #
Get JSON value (object field or array element) at a key, as text.
(.->) :: forall (json :: PGType) (key :: PGType) (null :: PGType -> NullType). (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) ('Null json) infixl 8 #
Get JSON value (object field or array element) at a key.
class SListI tys => JsonBuildObject (tys :: [NullType]) where #
Builds a possibly-heterogeneously-typed JSON object out of a variadic argument list. The elements of the argument list must alternate between text and values.
Minimal complete definition
Nothing
Methods
jsonBuildObject :: forall (null :: PGType -> NullType). tys ---> null 'PGjson #
jsonbBuildObject :: forall (null :: PGType -> NullType). tys ---> null 'PGjsonb #
Instances
| JsonBuildObject ('[] :: [NullType]) | |
Defined in Squeal.PostgreSQL.Expression.Json | |
| (JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject ('NotNull key ': (value ': tys)) | |
Defined in Squeal.PostgreSQL.Expression.Json | |
type JsonPopulateFunction (fun :: Symbol) (json :: PGType) #
Arguments
| = forall (db :: SchemasType) (row :: RowType) (lat :: FromType) (with :: FromType) (params :: [NullType]). In json PGJsonType | |
| => TypeExpression db ('NotNull ('PGcomposite row)) | row type |
| -> Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) ('NotNull json) | json type |
| -> FromClause lat with db params '[fun ::: row] |
Build rows from Json types.
type JsonToRecordFunction (json :: PGType) #
Arguments
| = forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (tab :: Symbol) (row :: [(Symbol, NullType)]). (SListI row, In json PGJsonType) | |
| => Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) ('NotNull json) | json type |
| -> Aliased (NP (Aliased (TypeExpression db))) (tab ::: row) | row type |
| -> FromClause lat with db params '[tab ::: row] |
Build rows from Json types.
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (nullty :: NullType) (ty :: PGType). Expression grp lat with db params from nullty | what to convert |
| -> (Expression grp lat with db params from ('NotNull ty) -> Expression grp lat with db params from nullty) | function to perform when |
| -> Expression grp lat with db params from ('Null ty) | |
| -> Expression grp lat with db params from nullty |
analagous to maybe using IS NULL
>>>printSQL $ matchNull true not_ null_CASE WHEN NULL IS NULL THEN TRUE ELSE (NOT NULL) END
isNotNull :: forall (ty :: PGType) (null :: PGType -> NullType). 'Null ty --> null 'PGbool #
>>>printSQL $ null_ & isNotNullNULL IS NOT NULL
isNull :: forall (ty :: PGType) (null :: PGType -> NullType). 'Null ty --> null 'PGbool #
>>>printSQL $ null_ & isNullNULL IS NULL
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). Expression grp lat with db params from ('NotNull ty) | what to convert |
| -> Expression grp lat with db params from ('Null ty) | |
| -> Expression grp lat with db params from ('NotNull ty) |
analagous to fromMaybe using COALESCE
>>>printSQL $ fromNull true null_COALESCE(NULL, TRUE)
coalesce :: forall (ty :: PGType) (null :: PGType -> NullType). FunctionVar ('Null ty) (null ty) (null ty) #
return the leftmost value which is not NULL
>>>printSQL $ coalesce [null_, true] falseCOALESCE(NULL, TRUE, FALSE)
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: PGType). (forall (null :: PGType -> NullType). Expression grp lat with db params from (null ty)) | null polymorphic |
| -> Expression grp lat with db params from ('NotNull ty) |
Some expressions are null polymorphic which may raise
inference issues. Use monoNotNull to fix their
nullity as NotNull.
unsafeNotNull :: forall (ty :: PGType). 'Null ty --> 'NotNull ty #
Analagous to fromJust inverse to notNull,
useful when you know an Expression is NotNull,
because, for instance, you've filtered out NULL
values in a column.
notNull :: forall (ty :: PGType). 'NotNull ty --> 'Null ty #
analagous to Just
>>>printSQL $ notNull trueTRUE
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). Expression grp lat with db params from ty | expression |
| -> [Expression grp lat with db params from ty] | |
| -> Expression grp lat with db params from (null 'PGbool) |
The result is true if the left-hand expression's result is not equal
to any of the right-hand expressions.
>>>printSQL $ true `notIn` [false, null_]TRUE NOT IN (FALSE, NULL)
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) (null :: PGType -> NullType). Expression grp lat with db params from ty | expression |
| -> [Expression grp lat with db params from ty] | |
| -> Expression grp lat with db params from (null 'PGbool) |
The result is true if the left-hand expression's result is equal
to any of the right-hand expressions.
>>>printSQL $ true `in_` [true, false, null_]TRUE IN (TRUE, FALSE, NULL)
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType) (col :: Symbol). Expression grp lat with db params from ty1 | expression |
| -> Operator ty1 ty2 ('Null 'PGbool) | operator |
| -> Query (Join lat from) with db params '[col ::: ty2] | subquery |
| -> Condition grp lat with db params from |
The right-hand side is a parenthesized subquery, which must return exactly one column.
The left-hand expression is evaluated and compared to each row of the subquery result
using the given Operator, which must yield a Boolean result. The result of subAny is true
if any true result is obtained. The result is false if no true result is found
(including the case where the subquery returns no rows).
>>>printSQL $ subAny "foo" like (values_ ("foobar" `as` #foo))((E'foo' :: text) LIKE ANY (SELECT * FROM (VALUES ((E'foobar' :: text))) AS t ("foo")))
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty1 :: NullType) (ty2 :: NullType) (col :: Symbol). Expression grp lat with db params from ty1 | expression |
| -> Operator ty1 ty2 ('Null 'PGbool) | operator |
| -> Query (Join lat from) with db params '[col ::: ty2] | subquery |
| -> Condition grp lat with db params from |
The right-hand side is a parenthesized subquery, which must return
exactly one column. The left-hand expression is evaluated and compared to each
row of the subquery result using the given Operator,
which must yield a Boolean result. The result of subAll is true
if all rows yield true (including the case where the subquery returns no rows).
The result is false if any false result is found.
The result is null_ if
no comparison with a subquery row returns false,
and at least one comparison returns null_.
>>>printSQL $ subAll true (.==) (values_ (true `as` #foo))(TRUE = ALL (SELECT * FROM (VALUES (TRUE)) AS t ("foo")))
Arguments
| :: forall (lat :: [(Symbol, RowType)]) (from :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (row :: RowType) (grp :: Grouping) (null :: PGType -> NullType). Query (Join lat from) with db params row | subquery |
| -> Expression grp lat with db params from (null 'PGbool) |
The argument of exists is an arbitrary subquery. The subquery is evaluated
to determine whether it returns any rows. If it returns at least one row,
the result of exists is true; if the subquery returns no rows,
the result of exists is false.
The subquery can refer to variables from the surrounding query, which will act as constants during any one evaluation of the subquery.
The subquery will generally only be executed long enough to determine whether at least one row is returned, not all the way to completion.
Arguments
| :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query | right subquery |
| -> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (NullifyFrom (Join left '[query])) |
Like fullOuterJoin with a subquery but allowed to reference columns provided
by preceding FromClause items.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (NullifyFrom (Join left right)) |
left & fullOuterJoin right on. First, an inner join is performed.
Then, for each row in left that does not satisfy the on condition with
any row in right, a joined row is added with null values in columns of right.
Also, for each row of right that does not satisfy the join condition
with any row in left, a joined row with null values in the columns of left
is added.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (NullifyFrom (Join left right)) |
left & fullOuter (Join right) on. First, an inner join is performed.
Then, for each row in left that does not satisfy the on condition with
any row in right, a joined row is added with null values in columns of right.
Also, for each row of right that does not satisfy the join condition
with any row in left, a joined row with null values in the columns of left
is added.
Arguments
| :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query | right subquery |
| -> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join (NullifyFrom left) '[query]) |
Like rightOuterJoin with a subquery but allowed to reference columns provided
by preceding FromClause items.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join (NullifyFrom left) right) |
left & rightOuterJoin right on. First, an inner join is performed.
Then, for each row in right that does not satisfy the on condition with
any row in left, a joined row is added with null values in columns of left.
This is the converse of a left join: the result table will always
have a row for each row in right.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join (NullifyFrom left) right) |
left & rightOuter (Join right) on. First, an inner join is performed.
Then, for each row in right that does not satisfy the on condition with
any row in left, a joined row is added with null values in columns of left.
This is the converse of a left join: the result table will always
have a row for each row in right.
Arguments
| :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query | right subquery |
| -> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left (NullifyFrom '[query])) |
Like leftOuterJoin with a subquery but allowed to reference columns provided
by preceding FromClause items.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left (NullifyFrom right)) |
left & leftOuterJoin right on. First, an inner join is performed.
Then, for each row in left that does not satisfy the on condition with
any row in right, a joined row is added with null values in columns of right.
Thus, the joined table always has at least one row for each row in left.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left (NullifyFrom right)) |
left & leftOuter (Join right) on. First, an inner join is performed.
Then, for each row in left that does not satisfy the on condition with
any row in right, a joined row is added with null values in columns of right.
Thus, the joined table always has at least one row for each row in left.
Arguments
| :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query | right subquery |
| -> Condition 'Ungrouped lat with db params (Join left '[query]) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left '[query]) |
Like innerJoin with a subquery but allowed to reference columns provided
by preceding FromClause items.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: [(Symbol, RowType)]). FromClause lat with db params right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left right) |
left & innerJoin right on. The joined table is filtered by
the on condition.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right | right |
| -> Condition 'Ungrouped lat with db params (Join left right) |
|
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left right) |
left & inner (Join right) on. The joined table is filtered by
the on condition.
Arguments
| :: forall (lat :: [(Symbol, RowType)]) (left :: [(Symbol, RowType)]) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query (Join lat left) with db params) query | right subquery |
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left '[query]) |
Like crossJoin with a subquery but allowed to reference columns provided
by preceding FromClause items.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (right :: FromType) (left :: FromType). FromClause lat with db params right | right |
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left right) |
left & crossJoin right. For every possible combination of rows from
left and right (i.e., a Cartesian product), the joined table will contain
a row consisting of all columns in left followed by all columns in right.
If the tables have n and m rows respectively, the joined table will
have n * m rows.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType). JoinItem lat with db params left right | right |
| -> FromClause lat with db params left | left |
| -> FromClause lat with db params (Join left right) |
left & cross (Join right). For every possible combination of rows from
left and right (i.e., a Cartesian product), the joined table will contain
a row consisting of all columns in left followed by all columns in right.
If the tables have n and m rows respectively, the joined table will
have n * m rows.
data JoinItem (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (left :: FromType) (right :: FromType) where #
A JoinItem is the right hand side of a cross,
inner, leftOuter, rightOuter, fullOuter join of
FromClauses.
Constructors
| Join | |
Fields
| |
| JoinLateral | |
Fields
| |
| JoinFunction | |
Fields
| |
| JoinFunctionN | |
Fields
| |
Instances
| RenderSQL (JoinItem lat with db params left right) | |
Defined in Squeal.PostgreSQL.Query.From.Join Methods renderSQL :: JoinItem lat with db params left right -> ByteString # | |
Arguments
| :: forall (from :: [(Symbol, RowType)]) (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). LockingClause from | row-level lock |
| -> TableExpression grp lat with db params from | |
| -> TableExpression grp lat with db params from |
Add a LockingClause to a TableExpression.
Multiple LockingClauses can be written if it is necessary
to specify different locking behavior for different tables.
If the same table is mentioned (or implicitly affected)
by more than one locking clause, then it is processed
as if it was only specified by the strongest one.
Similarly, a table is processed as NoWait if that is specified
in any of the clauses affecting it. Otherwise, it is processed
as SkipLocked if that is specified in any of the clauses affecting it.
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Word64 | offset parameter |
| -> TableExpression grp lat with db params from | |
| -> TableExpression grp lat with db params from |
An offset is an endomorphism of TableExpressions which adds to the
offsetClause.
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Word64 | limit parameter |
| -> TableExpression grp lat with db params from | |
| -> TableExpression grp lat with db params from |
A limit is an endomorphism of TableExpressions which adds to the
limitClause.
Arguments
| :: forall (bys :: [(Symbol, Symbol)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Condition ('Grouped bys) lat with db params from | having condition |
| -> TableExpression ('Grouped bys) lat with db params from | |
| -> TableExpression ('Grouped bys) lat with db params from |
A having is an endomorphism of TableExpressions which adds a
search condition to the havingClause.
Arguments
| :: forall (bys :: [(Symbol, Symbol)]) (from :: FromType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI bys | |
| => NP (By from) bys | grouped columns |
| -> TableExpression 'Ungrouped lat with db params from | |
| -> TableExpression ('Grouped bys) lat with db params from |
A groupBy is a transformation of TableExpressions which switches
its Grouping from Ungrouped to Grouped. Use groupBy Nil to perform
a "grand total" aggregation query.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (grp :: Grouping). Condition 'Ungrouped lat with db params from | filtering condition |
| -> TableExpression grp lat with db params from | |
| -> TableExpression grp lat with db params from |
A where_ is an endomorphism of TableExpressions which adds a
search condition to the whereClause.
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). FromClause lat with db params from | table reference |
| -> TableExpression 'Ungrouped lat with db params from |
A from generates a TableExpression from a table reference that can be
a table name, or a derived table such as a subquery, a JOIN construct,
or complex combinations of these. A from may be transformed by where_,
groupBy, having, orderBy, limit and offset,
using the & operator
to match the left-to-right sequencing of their placement in SQL.
data TableExpression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #
A TableExpression computes a table. The table expression contains
a fromClause that is optionally followed by a whereClause,
groupByClause, havingClause, orderByClause, limitClause
offsetClause and lockingClauses. Trivial table expressions simply refer
to a table on disk, a so-called base table, but more complex expressions
can be used to modify or combine base tables in various ways.
Constructors
| TableExpression | |
Fields
| |
Instances
| OrderBy (TableExpression grp) grp | |
Defined in Squeal.PostgreSQL.Query.Table Methods orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from # | |
| Generic (TableExpression grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.Table Associated Types type Rep (TableExpression grp lat with db params from) :: Type -> Type # Methods from :: TableExpression grp lat with db params from -> Rep (TableExpression grp lat with db params from) x # to :: Rep (TableExpression grp lat with db params from) x -> TableExpression grp lat with db params from # | |
| RenderSQL (TableExpression grp lat with db params from) | Render a |
Defined in Squeal.PostgreSQL.Query.Table Methods renderSQL :: TableExpression grp lat with db params from -> ByteString # | |
| type Rep (TableExpression grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.Table type Rep (TableExpression grp lat with db params from) = D1 ('MetaData "TableExpression" "Squeal.PostgreSQL.Query.Table" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'False) (C1 ('MetaCons "TableExpression" 'PrefixI 'True) (((S1 ('MetaSel ('Just "fromClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (FromClause lat with db params from)) :*: S1 ('MetaSel ('Just "whereClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Condition 'Ungrouped lat with db params from])) :*: (S1 ('MetaSel ('Just "groupByClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (GroupByClause grp from)) :*: S1 ('MetaSel ('Just "havingClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HavingClause grp lat with db params from)))) :*: ((S1 ('MetaSel ('Just "orderByClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [SortExpression grp lat with db params from]) :*: S1 ('MetaSel ('Just "limitClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word64])) :*: (S1 ('MetaSel ('Just "offsetClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Word64]) :*: S1 ('MetaSel ('Just "lockingClauses") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [LockingClause from]))))) | |
data By (from :: FromType) (by :: (Symbol, Symbol)) where #
Bys are used in groupBy to reference a list of columns which are then
used to group together those rows in a table that have the same values
in all the columns listed. By #col will reference an unambiguous
column col; otherwise By2 (#tab ! #col) will reference a table
qualified column tab.col.
Constructors
| By1 :: forall (table :: Symbol) (from :: FromType) (columns :: [(Symbol, NullType)]) (column :: Symbol) (ty :: NullType). (HasUnique table from columns, Has column columns ty) => Alias column -> By from '(table, column) | |
| By2 :: forall (table :: Symbol) (from :: FromType) (columns :: [(Symbol, NullType)]) (column :: Symbol) (ty :: NullType). (Has table from columns, Has column columns ty) => Alias table -> Alias column -> By from '(table, column) |
Instances
| (Has rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsQualified rel col (By rels by) | |
| (Has rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsQualified rel col (NP (By rels) bys) | |
| (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsLabel col (By rels by) | |
Defined in Squeal.PostgreSQL.Query.Table | |
| (HasUnique rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsLabel col (NP (By rels) bys) | |
Defined in Squeal.PostgreSQL.Query.Table | |
| Eq (By from by) | |
| Ord (By from by) | |
Defined in Squeal.PostgreSQL.Query.Table | |
| Show (By from by) | |
| RenderSQL (By from by) | |
Defined in Squeal.PostgreSQL.Query.Table Methods renderSQL :: By from by -> ByteString # | |
newtype GroupByClause (grp :: k) (from :: k1) #
A GroupByClause indicates the Grouping of a TableExpression.
Constructors
| UnsafeGroupByClause | |
Fields | |
Instances
data HavingClause (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where #
A HavingClause is used to eliminate groups that are not of interest.
An Ungrouped TableExpression may only use NoHaving while a Grouped
TableExpression must use Having whose conditions are combined with
.&&.
Constructors
| NoHaving :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). HavingClause 'Ungrouped lat with db params from | |
| Having :: forall (bys :: [(Symbol, Symbol)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [Condition ('Grouped bys) lat with db params from] -> HavingClause ('Grouped bys) lat with db params from |
Instances
| Eq (HavingClause grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.Table Methods (==) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool # (/=) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool # | |
| Ord (HavingClause grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.Table Methods compare :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Ordering # (<) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool # (<=) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool # (>) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool # (>=) :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> Bool # max :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> HavingClause grp lat with db params from # min :: HavingClause grp lat with db params from -> HavingClause grp lat with db params from -> HavingClause grp lat with db params from # | |
| Show (HavingClause grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.Table Methods showsPrec :: Int -> HavingClause grp lat with db params from -> ShowS # show :: HavingClause grp lat with db params from -> String # showList :: [HavingClause grp lat with db params from] -> ShowS # | |
| RenderSQL (HavingClause grp lat with db params from) | Render a |
Defined in Squeal.PostgreSQL.Query.Table Methods renderSQL :: HavingClause grp lat with db params from -> ByteString # | |
data LockingClause (from :: [(Symbol, kind)]) where #
If specific tables are named in a locking clause,
then only rows coming from those tables are locked;
any other tables used in the select are simply read as usual.
A locking clause with a Nil table list affects all tables used in the statement.
If a locking clause is applied to a view or subquery,
it affects all tables used in the view or subquery.
However, these clauses do not apply to with queries referenced by the primary query.
If you want row locking to occur within a with query,
specify a LockingClause within the with query.
Constructors
| For | |
Fields
| |
Instances
| RenderSQL (LockingClause from) | |
Defined in Squeal.PostgreSQL.Query.Table Methods renderSQL :: LockingClause from -> ByteString # | |
data LockStrength #
Row-level locks, which are listed as below with the contexts in which they are used automatically by PostgreSQL. Note that a transaction can hold conflicting locks on the same row, even in different subtransactions; but other than that, two transactions can never hold conflicting locks on the same row. Row-level locks do not affect data querying; they block only writers and lockers to the same row. Row-level locks are released at transaction end or during savepoint rollback.
Constructors
| Update |
The |
| NoKeyUpdate | |
| Share | Behaves similarly to |
| KeyShare | Behaves similarly to |
Instances
To prevent the operation from Waiting for other transactions to commit,
use either the NoWait or SkipLocked option.
Constructors
| Wait | wait for other transactions to commit |
| NoWait | reports an error, rather than waiting |
| SkipLocked | any selected rows that cannot be immediately locked are skipped |
Instances
| Enum Waiting | |
| Eq Waiting | |
| Ord Waiting | |
Defined in Squeal.PostgreSQL.Query.Table | |
| Read Waiting | |
| Show Waiting | |
| Generic Waiting | |
| RenderSQL Waiting | |
Defined in Squeal.PostgreSQL.Query.Table Methods renderSQL :: Waiting -> ByteString # | |
| type Rep Waiting | |
Defined in Squeal.PostgreSQL.Query.Table type Rep Waiting = D1 ('MetaData "Waiting" "Squeal.PostgreSQL.Query.Table" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'False) (C1 ('MetaCons "Wait" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "NoWait" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "SkipLocked" 'PrefixI 'False) (U1 :: Type -> Type))) | |
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). Condition grp lat with db params from | |
| -> Expression grp lat with db params from ty | then |
| -> Expression grp lat with db params from ty | else |
| -> Expression grp lat with db params from ty |
>>>:{let expression :: Expression grp lat with db params from (null 'PGint2) expression = ifThenElse true 1 0 in printSQL expression :} CASE WHEN TRUE THEN (1 :: int2) ELSE (0 :: int2) END
Arguments
| :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType). [(Condition grp lat with db params from, Expression grp lat with db params from ty)] | whens and thens |
| -> Expression grp lat with db params from ty | else |
| -> Expression grp lat with db params from ty |
>>>:{let expression :: Expression grp lat with db params from (null 'PGint2) expression = caseWhenThenElse [(true, 1), (false, 2)] 3 in printSQL expression :} CASE WHEN TRUE THEN (1 :: int2) WHEN FALSE THEN (2 :: int2) ELSE (3 :: int2) END
(.||) :: forall (null :: PGType -> NullType). Operator (null 'PGbool) (null 'PGbool) (null 'PGbool) infixr 2 #
>>>printSQL $ true .|| false(TRUE OR FALSE)
(.&&) :: forall (null :: PGType -> NullType). Operator (null 'PGbool) (null 'PGbool) (null 'PGbool) infixr 3 #
>>>printSQL $ true .&& false(TRUE AND FALSE)
not_ :: forall (null :: PGType -> NullType). null 'PGbool --> null 'PGbool #
>>>printSQL $ not_ true(NOT TRUE)
type Condition (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) = Expression grp lat with db params from ('Null 'PGbool) #
A Condition is an Expression, which can evaluate
to true, false or null_. This is because SQL uses
a three valued logic.
ceiling_ :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac #
>>>:{let expression :: Expression grp lat with db params from (null 'PGfloat4) expression = ceiling_ pi in printSQL expression :} ceiling(pi())
round_ :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac #
>>>:{let expression :: Expression grp lat with db params from (null 'PGfloat4) expression = round_ pi in printSQL expression :} round(pi())
trunc :: forall (frac :: PGType) (null :: PGType -> NullType). In frac PGFloating => null frac --> null frac #
>>>:{let expression :: Expression grp lat with db params from (null 'PGfloat4) expression = trunc pi in printSQL expression :} trunc(pi())
rem_ :: forall (int :: PGType) (null :: PGType -> NullType). In int PGIntegral => Operator (null int) (null int) (null int) #
remainder upon integer division
>>>:{let expression :: Expression grp lat with db params from (null 'PGint2) expression = 5 `rem_` 2 in printSQL expression :} ((5 :: int2) % (2 :: int2))
quot_ :: forall (int :: PGType) (null :: PGType -> NullType). In int PGIntegral => Operator (null int) (null int) (null int) #
integer division, truncates the result
>>>:{let expression :: Expression grp lat with db params from (null 'PGint2) expression = 5 `quot_` 2 in printSQL expression :} ((5 :: int2) / (2 :: int2))
atan2_ :: forall (float :: PGType) (null :: PGType -> NullType). In float PGFloating => '[null float, null float] ---> null float #
>>>:{let expression :: Expr (null 'PGfloat4) expression = atan2_ (pi *: 2) in printSQL expression :} atan2(pi(), (2.0 :: float4))
Arguments
| :: forall (n :: Nat) (ty :: NullType) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (grp :: Grouping). (NullTyped db ty, HasParameter n params ty) | |
| => Expression grp lat with db params from ty | param |
param takes a Nat using type application and for basic types,
infers a TypeExpression.
>>>printSQL (param @1 @('Null 'PGint4))($1 :: int4)
class KnownNat n => HasParameter (n :: Nat) (params :: [NullType]) (ty :: NullType) | n params -> ty where #
A HasParameter constraint is used to indicate a value that is
supplied externally to a SQL statement.
manipulateParams,
queryParams and
traversePrepared support specifying data values
separately from the SQL command string, in which case params are used to
refer to the out-of-line data values.
Minimal complete definition
Nothing
Methods
parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db ty -> Expression grp lat with db params from ty #
parameter takes a Nat using type application and a TypeExpression.
>>>printSQL (parameter @1 int4)($1 :: int4)
Instances
| (KnownNat n, HasParameter (n - 1) xs x, params ~ (y ': xs)) => HasParameter n params x | |
Defined in Squeal.PostgreSQL.Expression.Parameter Methods parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db x -> Expression grp lat with db params from x # | |
| params ~ (x ': xs) => HasParameter 1 params x | |
Defined in Squeal.PostgreSQL.Expression.Parameter Methods parameter :: forall (db :: SchemasType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (from :: FromType). TypeExpression db x -> Expression grp lat with db params from x # | |
cmdTuples :: MonadIO io => Result y -> io (Maybe Row) #
Returns the number of rows affected by the SQL command.
This function returns Just the number of
rows affected by the SQL statement that generated the Result.
This function can only be used following the execution of a
SELECT, CREATE TABLE AS, INSERT, UPDATE, DELETE, MOVE, FETCH,
or COPY statement,or an EXECUTE of a prepared query that
contains an INSERT, UPDATE, or DELETE statement.
If the command that generated the PGresult was anything else,
cmdTuples returns Nothing.
cmdStatus :: MonadIO io => Result y -> io Text #
Returns the command status tag from the SQL command
that generated the Result.
Commonly this is just the name of the command,
but it might include additional data such as the number of rows processed.
liftResult :: MonadIO io => (Result -> IO x) -> Result y -> io x #
Lifts actions on results from LibPQ.
enumValue :: forall (labels :: [Symbol]) y. (All KnownSymbol labels, PG y ~ 'PGenum labels) => NP (K y :: Symbol -> Type) labels -> StateT ByteString (Except Text) y #
>>>:{data Dir = North | East | South | West instance IsPG Dir where type PG Dir = 'PGenum '["north", "south", "east", "west"] instance FromPG Dir where fromPG = enumValue $ label @"north" North :* label @"south" South :* label @"east" East :* label @"west" West :}
genericRow :: forall (row :: [(Symbol, NullType)]) y (ys :: RecordCode). (IsRecord y ys, AllZip FromField row ys) => DecodeRow row y #
Row decoder for Generic records.
>>>import qualified GHC.Generics as GHC>>>import qualified Generics.SOP as SOP>>>data Two = Two {frst :: Int16, scnd :: String} deriving (Show, GHC.Generic, SOP.Generic, SOP.HasDatatypeInfo)>>>:{let decode :: DecodeRow '[ "frst" ::: 'NotNull 'PGint2, "scnd" ::: 'NotNull 'PGtext] Two decode = genericRow in runDecodeRow decode (SOP.K (Just "\NUL\STX") :* SOP.K (Just "two") :* Nil) :} Right (Two {frst = 2, scnd = "two"})
decodeRow :: forall (row :: [(Symbol, NullType)]) y. (NP (K (Maybe ByteString) :: (Symbol, NullType) -> Type) row -> Either Text y) -> DecodeRow row y #
Smart constructor for a DecodeRow.
Arguments
| :: forall (head :: NullType) h t z (col :: Symbol) (tail :: RowType). FromValue head h | |
| => (h -> t -> z) | combining function |
| -> Alias col | alias of head |
| -> DecodeRow tail t | tail decoder |
| -> DecodeRow ((col ::: head) ': tail) z |
Cons a column and a row decoder with a combining function.
>>>:{let decode :: DecodeRow '["fst" ::: 'NotNull 'PGtext, "snd" ::: 'NotNull 'PGint2, "thrd" ::: 'NotNull ('PGchar 1)] (String, (Int16, Char)) decode = consRow (,) #fst (consRow (,) #snd #thrd) in runDecodeRow decode (SOP.K (Just "hi") :* SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* Nil) :} Right ("hi",(1,'a'))
Arguments
| :: forall (left :: [(Symbol, NullType)]) l r z (right :: RowType). SListI left | |
| => (l -> r -> z) | combining function |
| -> DecodeRow left l | left decoder |
| -> DecodeRow right r | right decoder |
| -> DecodeRow (Join left right) z |
Append two row decoders with a combining function.
>>>import GHC.Generics as GHC>>>:{data L = L {fst :: Int16, snd :: Char} deriving stock (GHC.Generic, Show) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) data R = R {thrd :: Bool, frth :: Bool} deriving stock (GHC.Generic, Show) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) type Row = '[ "fst" ::: 'NotNull 'PGint2, "snd" ::: 'NotNull ('PGchar 1), "thrd" ::: 'NotNull 'PGbool, "frth" ::: 'NotNull 'PGbool] :}
>>>:{let decode :: DecodeRow Row (L,R) decode = appendRows (,) genericRow genericRow row4 = SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* SOP.K (Just "\NUL") :* SOP.K (Just "\NUL") :* Nil in runDecodeRow decode row4 :} Right (L {fst = 1, snd = 'a'},R {thrd = False, frth = False})
runDecodeRow :: forall (row :: RowType) y. DecodeRow row y -> NP (K (Maybe ByteString) :: (Symbol, NullType) -> Type) row -> Either Text y #
Run a DecodeRow.
rowValue :: forall y (row :: RowType). (PG y ~ 'PGcomposite row, SListI row) => DecodeRow row y -> StateT ByteString (Except Text) y #
>>>:set -XTypeFamilies>>>:{data Complex = Complex { real :: Double , imaginary :: Double } instance IsPG Complex where type PG Complex = 'PGcomposite '[ "re" ::: 'NotNull 'PGfloat8, "im" ::: 'NotNull 'PGfloat8] instance FromPG Complex where fromPG = rowValue $ do re <- #re im <- #im return Complex {real = re, imaginary = im} :}
class IsPG y => FromPG y where #
A FromPG constraint gives a parser from the binary format of
a PostgreSQL PGType into a Haskell Type.
Methods
fromPG :: StateT ByteString (Except Text) y #
>>>:set -XMultiParamTypeClasses -XGeneralizedNewtypeDeriving -XDerivingStrategies -XDerivingVia -XUndecidableInstances>>>import GHC.Generics as GHC>>>:{newtype UserId = UserId { getId :: Int64 } deriving newtype (IsPG, FromPG) :}
>>>:{data Complex = Complex { real :: Double , imaginary :: Double } deriving stock GHC.Generic deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) deriving (IsPG, FromPG) via Composite Complex :}
>>>:{data Direction = North | South | East | West deriving stock GHC.Generic deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) deriving (IsPG, FromPG) via Enumerated Direction :}
Instances
class FromValue (ty :: NullType) y where #
A FromValue constraint lifts the FromPG parser
to a decoding of a NullityType to a Type,
decoding Nulls to Maybes. You should not define instances for
FromValue, just use the provided instances.
class FromField (field :: (Symbol, NullType)) (y :: (Symbol, Type)) where #
class FromArray (dims :: [Nat]) (ty :: NullType) y where #
A FromArray constraint gives a decoding to a Haskell Type
from the binary format of a PostgreSQL fixed-length array.
You should not define instances for
FromArray, just use the provided instances.
Instances
| (FromPG y, pg ~ PG y) => FromArray ('[] :: [Nat]) ('NotNull pg) y | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| (FromPG y, pg ~ PG y) => FromArray ('[] :: [Nat]) ('Null pg) (Maybe y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| (IsProductType product ys, Length ys ~ dim, All (Type ~ y) ys, FromArray dims ty y) => FromArray (dim ': dims) ty product | |
Defined in Squeal.PostgreSQL.Session.Decode | |
newtype DecodeRow (row :: RowType) y #
DecodeRow describes a decoding of a PostgreSQL RowType
into a Haskell Type.
DecodeRow has an interface given by the classes
Functor, Applicative, Alternative, Monad,
MonadPlus, MonadError Text, and IsLabel.
>>>:set -XOverloadedLabels>>>:{let decode :: DecodeRow '[ "fst" ::: 'NotNull 'PGint2, "snd" ::: 'NotNull ('PGchar 1)] (Int16, Char) decode = (,) <$> #fst <*> #snd in runDecodeRow decode (SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* Nil) :} Right (1,'a')
There is also an IsLabel instance for MaybeT DecodeRows, useful
for decoding outer joined rows.
>>>:{let decode :: DecodeRow '[ "fst" ::: 'Null 'PGint2, "snd" ::: 'Null ('PGchar 1)] (Maybe (Int16, Char)) decode = runMaybeT $ (,) <$> #fst <*> #snd in runDecodeRow decode (SOP.K (Just "\NUL\SOH") :* SOP.K (Just "a") :* Nil) :} Right (Just (1,'a'))
Constructors
| DecodeRow | |
Instances
Arguments
| :: forall (db :: SchemasType) (params0 :: [NullType]) x (params1 :: [NullType]). EncodeParams db params0 x | left |
| -> EncodeParams db params1 x | right |
| -> EncodeParams db (Join params0 params1) x |
Append parameter encodings.
>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>:{let encode :: EncodeParams '[] '[ 'NotNull 'PGint4, 'NotNull 'PGint2] (Int32, Int16) encode = contramap fst aParam `appendParams` contramap snd aParam in runReaderT (runEncodeParams encode (1776, 2)) conn :} K (Just "\NUL\NUL\ACK\240") :* K (Just "\NUL\STX") :* Nil
>>>finish conn
aParam :: forall (db :: SchemasType) x. ToParam db (NullPG x) x => EncodeParams db '[NullPG x] x #
Encode 1 parameter.
>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>:{let encode :: EncodeParams '[] '[ 'NotNull 'PGint4] Int32 encode = aParam in runReaderT (runEncodeParams encode 1776) conn :} K (Just "\NUL\NUL\ACK\240") :* Nil
>>>finish conn
Arguments
| :: forall (db :: SchemasType) x x0 (ty0 :: NullType) x1 (ty1 :: NullType). (ToParam db ty0 x0, ToParam db ty1 x1) | |
| => (x -> x0) | second to last |
| -> (x -> x1) | last |
| -> EncodeParams db '[ty0, ty1] x |
End a parameter encoding.
>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>:{let encode :: EncodeParams '[] '[ 'Null 'PGint4, 'NotNull 'PGtext, 'NotNull ('PGchar 1)] (Maybe Int32, String, Char) encode = (\(x,_,_) -> x) .* (\(_,y,_) -> y) *. (\(_,_,z) -> z) in runReaderT (runEncodeParams encode (Nothing, "foo", 'z')) conn :} K Nothing :* K (Just "foo") :* K (Just "z") :* Nil
>>>finish conn
Arguments
| :: forall (db :: SchemasType) x0 (ty :: NullType) x (tys :: [NullType]). ToParam db ty x0 | |
| => (x -> x0) | head |
| -> EncodeParams db tys x | tail |
| -> EncodeParams db (ty ': tys) x |
Cons a parameter encoding.
>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>:{let encode :: EncodeParams '[] '[ 'Null 'PGint4, 'NotNull 'PGtext] (Maybe Int32, String) encode = fst .* snd .* nilParams in runReaderT (runEncodeParams encode (Nothing, "foo")) conn :} K Nothing :* K (Just "foo") :* Nil
>>>finish conn
nilParams :: forall (db :: SchemasType) x. EncodeParams db ('[] :: [NullType]) x #
Encode 0 parameters.
genericParams :: forall (db :: SchemasType) (params :: [NullType]) x (xs :: [Type]). (IsProductType x xs, AllZip (ToParam db) params xs) => EncodeParams db params x #
Parameter encoding for Generic tuples and records.
>>>import qualified GHC.Generics as GHC>>>import qualified Generics.SOP as SOP>>>data Two = Two Int16 String deriving (GHC.Generic, SOP.Generic)>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>:{let encode :: EncodeParams '[] '[ 'NotNull 'PGint2, 'NotNull 'PGtext] Two encode = genericParams in runReaderT (runEncodeParams encode (Two 2 "two")) conn :} K (Just "\NUL\STX") :* K (Just "two") :* Nil
>>>:{let encode :: EncodeParams '[] '[ 'NotNull 'PGint2, 'NotNull 'PGtext] (Int16, String) encode = genericParams in runReaderT (runEncodeParams encode (2, "two")) conn :} K (Just "\NUL\STX") :* K (Just "two") :* Nil
>>>finish conn
class IsPG x => ToPG (db :: SchemasType) x where #
A ToPG constraint gives an encoding of a Haskell Type into
into the binary format of a PostgreSQL PGType.
Methods
toPG :: x -> ReaderT (K Connection db) IO Encoding #
>>>:set -XTypeApplications -XDataKinds>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>runReaderT (toPG @'[] False) conn"\NUL"
>>>runReaderT (toPG @'[] (0 :: Int16)) conn"\NUL\NUL"
>>>runReaderT (toPG @'[] (0 :: Int32)) conn"\NUL\NUL\NUL\NUL"
>>>:set -XMultiParamTypeClasses -XGeneralizedNewtypeDeriving>>>newtype UserId = UserId { getUserId :: Int64 } deriving newtype (IsPG, ToPG db)>>>runReaderT (toPG @'[] (UserId 0)) conn"\NUL\NUL\NUL\NUL\NUL\NUL\NUL\NUL"
>>>finish conn
Instances
class ToParam (db :: SchemasType) (ty :: NullType) x where #
A ToParam constraint gives an encoding of a Haskell Type into
into the binary format of a PostgreSQL NullType.
You should not define instances for ToParam,
just use the provided instances.
class ToField (db :: SchemasType) (field :: (Symbol, NullType)) (x :: (Symbol, Type)) where #
class ToArray (db :: SchemasType) (dims :: [Nat]) (ty :: NullType) x where #
A ToArray constraint gives an encoding of a Haskell Type
into the binary format of a PostgreSQL fixed-length array.
You should not define instances for
ToArray, just use the provided instances.
Instances
| (ToPG db x, pg ~ PG x) => ToArray db ('[] :: [Nat]) ('NotNull pg) x | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| (ToPG db x, pg ~ PG x) => ToArray db ('[] :: [Nat]) ('Null pg) (Maybe x) | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| (IsProductType tuple xs, Length xs ~ dim, All (Type ~ x) xs, ToArray db dims ty x, KnownNat dim) => ToArray db (dim ': dims) ty tuple | |
Defined in Squeal.PostgreSQL.Session.Encode | |
newtype EncodeParams (db :: SchemasType) (tys :: [NullType]) x #
EncodeParams describes an encoding of a Haskell Type
into a list of parameter NullTypes.
>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>:{let encode :: EncodeParams '[] '[ 'NotNull 'PGint2, 'NotNull ('PGchar 1), 'NotNull 'PGtext] (Int16, (Char, String)) encode = fst .* fst.snd *. snd.snd in runReaderT (runEncodeParams encode (1,('a',"foo"))) conn :} K (Just "\NUL\SOH") :* K (Just "a") :* K (Just "foo") :* Nil
>>>finish conn
Constructors
| EncodeParams | |
Instances
| Contravariant (EncodeParams db tys) | |
Defined in Squeal.PostgreSQL.Session.Encode Methods contramap :: (a -> b) -> EncodeParams db tys b -> EncodeParams db tys a # (>$) :: b -> EncodeParams db tys b -> EncodeParams db tys a # | |
rangeMerge :: forall (null :: PGType -> NullType) (ty :: PGType). '[null ('PGrange ty), null ('PGrange ty)] ---> null ('PGrange ty) #
the smallest range which includes both of the given ranges
upperInf :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #
is the upper bound infinite?
upperInc :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #
is the upper bound inclusive?
lowerInf :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #
is the lower bound infinite?
lowerInc :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #
is the lower bound inclusive?
isEmpty :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null 'PGbool #
is the range empty?
upperBound :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null ty #
upper bound of range
lowerBound :: forall (null :: PGType -> NullType) (ty :: PGType). null ('PGrange ty) --> 'Null ty #
lower bound of range
(@-) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty)) #
difference, will fail if the resulting range would need to contain two disjoint sub-ranges
(@*) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty)) #
intersection
(@+) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) (null ('PGrange ty)) #
union, will fail if the resulting range would need to contain two disjoint sub-ranges
(-|-) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #
is adjacent to, return false when an empty range is involved
(&>) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #
does not extend to the left of, return false when an empty range is involved
(&<) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #
does not extend to the right of, return false when an empty range is involved
(@>>) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #
strictly right of, return false when an empty range is involved
(<<@) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) (null ('PGrange ty)) ('Null 'PGbool) #
strictly left of, return false when an empty range is involved
(@>.) :: forall (null :: PGType -> NullType) (ty :: PGType). Operator (null ('PGrange ty)) ('NotNull ty) ('Null 'PGbool) #
contains range
(.<@) :: forall (ty :: PGType) (null :: PGType -> NullType). Operator ('NotNull ty) (null ('PGrange ty)) ('Null 'PGbool) #
range is contained by
Arguments
| :: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). TypeExpression db (null ('PGrange ty)) | range type |
| -> Range (Expression grp lat with db params from ('NotNull ty)) | range of values |
| -> Expression grp lat with db params from (null ('PGrange ty)) |
Construct a range
>>>printSQL $ range tstzrange (atLeast now)tstzrange(now(), NULL, '[)')>>>printSQL $ range numrange (0 <=..< 2*pi)numrange((0.0 :: numeric), ((2.0 :: numeric) * pi()), '[)')>>>printSQL $ range int4range Empty('empty' :: int4range)
Instances
| Functor Bound | |
| Foldable Bound | |
Defined in Squeal.PostgreSQL.Expression.Range Methods fold :: Monoid m => Bound m -> m # foldMap :: Monoid m => (a -> m) -> Bound a -> m # foldMap' :: Monoid m => (a -> m) -> Bound a -> m # foldr :: (a -> b -> b) -> b -> Bound a -> b # foldr' :: (a -> b -> b) -> b -> Bound a -> b # foldl :: (b -> a -> b) -> b -> Bound a -> b # foldl' :: (b -> a -> b) -> b -> Bound a -> b # foldr1 :: (a -> a -> a) -> Bound a -> a # foldl1 :: (a -> a -> a) -> Bound a -> a # elem :: Eq a => a -> Bound a -> Bool # maximum :: Ord a => Bound a -> a # minimum :: Ord a => Bound a -> a # | |
| Traversable Bound | |
| Eq x => Eq (Bound x) | |
| Ord x => Ord (Bound x) | |
Defined in Squeal.PostgreSQL.Expression.Range | |
| Read x => Read (Bound x) | |
| Show x => Show (Bound x) | |
| Generic (Bound x) | |
| type Rep (Bound x) | |
Defined in Squeal.PostgreSQL.Expression.Range type Rep (Bound x) = D1 ('MetaData "Bound" "Squeal.PostgreSQL.Expression.Range" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'False) (C1 ('MetaCons "Infinite" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Closed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 x)) :+: C1 ('MetaCons "Open" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 x)))) | |
A Range datatype that comprises connected subsets of
the real line.
Instances
data SortExpression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) where #
SortExpressions are used by orderBy to optionally sort the results
of a Query. Asc or Desc
set the sort direction of a NotNull result
column to ascending or descending. Ascending order puts smaller values
first, where "smaller" is defined in terms of the
.< operator. Similarly,
descending order is determined with the
.> operator. AscNullsFirst,
AscNullsLast, DescNullsFirst and DescNullsLast options are used to
determine whether nulls appear before or after non-null values in the sort
ordering of a Null result column.
Constructors
| Asc | |
Fields
| |
| Desc | |
Fields
| |
| AscNullsFirst | |
Fields
| |
| AscNullsLast | |
Fields
| |
| DescNullsFirst | |
Fields
| |
| DescNullsLast | |
Fields
| |
Instances
| RenderSQL [SortExpression grp lat with db params from] | |
Defined in Squeal.PostgreSQL.Expression.Sort Methods renderSQL :: [SortExpression grp lat with db params from] -> ByteString # | |
| Show (SortExpression grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Sort Methods showsPrec :: Int -> SortExpression grp lat with db params from -> ShowS # show :: SortExpression grp lat with db params from -> String # showList :: [SortExpression grp lat with db params from] -> ShowS # | |
| RenderSQL (SortExpression grp lat with db params from) | |
Defined in Squeal.PostgreSQL.Expression.Sort Methods renderSQL :: SortExpression grp lat with db params from -> ByteString # | |
class OrderBy (expr :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (grp :: Grouping) | expr -> grp where #
The orderBy clause causes the result rows of a TableExpression
to be sorted according to the specified SortExpression(s).
If two rows are equal according to the leftmost expression,
they are compared according to the next expression and so on.
If they are equal according to all specified expressions,
they are returned in an implementation-dependent order.
You can also control the order in which rows are processed by window functions
using orderBy within Over.
Methods
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] | sorts |
| -> expr lat with db params from | |
| -> expr lat with db params from |
Instances
| OrderBy (WindowDefinition grp) grp | |
Defined in Squeal.PostgreSQL.Expression.Window Methods orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> WindowDefinition grp lat with db params from -> WindowDefinition grp lat with db params from # | |
| OrderBy (AggregateArg xs) 'Ungrouped | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression 'Ungrouped lat with db params from] -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from # | |
| OrderBy (TableExpression grp) grp | |
Defined in Squeal.PostgreSQL.Query.Table Methods orderBy :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [SortExpression grp lat with db params from] -> TableExpression grp lat with db params from -> TableExpression grp lat with db params from # | |
ilike :: forall (null :: PGType -> NullType). Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool) #
The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale.
>>>printSQL $ "abc" `ilike` "a%"((E'abc' :: text) ILIKE (E'a%' :: text))
like :: forall (null :: PGType -> NullType). Operator (null 'PGtext) (null 'PGtext) ('Null 'PGbool) #
The like expression returns true if the string matches
the supplied pattern. If pattern does not contain percent signs
or underscores, then the pattern only represents the string itself;
in that case like acts like the equals operator. An underscore (_)
in pattern stands for (matches) any single character; a percent sign (%)
matches any sequence of zero or more characters.
>>>printSQL $ "abc" `like` "a%"((E'abc' :: text) LIKE (E'a%' :: text))
charLength :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGint4 #
>>>printSQL $ charLength "four"char_length((E'four' :: text))
upper :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtext #
>>>printSQL $ upper "eeee"upper((E'eeee' :: text))
lower :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtext #
>>>printSQL $ lower "ARRRGGG"lower((E'ARRRGGG' :: text))
tsHeadline :: forall (document :: PGType) (null :: PGType -> NullType). In document '['PGtext, 'PGjson, 'PGjsonb] => '[null document, null 'PGtsquery] ---> null 'PGtext #
display a tsquery match
tsFilter :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGvararray ('NotNull ('PGchar 1)))] ---> null 'PGtsvector #
select only elements with given weights from tsvector
tsDelete :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGvararray ('NotNull 'PGtext))] ---> null 'PGtsvector #
remove given lexeme from tsvector
jsonbToTSvector :: forall (null :: PGType -> NullType). '[null 'PGjsonb, null 'PGjsonb] ---> null 'PGtsvector #
jsonbToTSvector (document *: filter)
reduce each value in the document, specified by filter to a tsvector,
and then concatenate those in document order to produce a single tsvector.
filter is a jsonb array, that enumerates what kind of elements
need to be included into the resulting tsvector.
Possible values for filter are "string" (to include all string values),
"numeric" (to include all numeric values in the string format),
"boolean" (to include all Boolean values in the string format "true"/"false"),
"key" (to include all keys) or "all" (to include all above).
These values can be combined together to include, e.g. all string and numeric values.
jsonToTSvector :: forall (null :: PGType -> NullType). '[null 'PGjson, null 'PGjson] ---> null 'PGtsvector #
jsonToTSvector (document *: filter)
reduce each value in the document, specified by filter to a tsvector,
and then concatenate those in document order to produce a single tsvector.
filter is a json array, that enumerates what kind of elements
need to be included into the resulting tsvector.
Possible values for filter are "string" (to include all string values),
"numeric" (to include all numeric values in the string format),
"boolean" (to include all Boolean values in the string format "true"/"false"),
"key" (to include all keys) or "all" (to include all above).
These values can be combined together to include, e.g. all string and numeric values.
strip :: forall (null :: PGType -> NullType). null 'PGtsvector --> null 'PGtsvector #
remove positions and weights from tsvector
setWeight :: forall (null :: PGType -> NullType). '[null 'PGtsvector, null ('PGchar 1)] ---> null 'PGtsvector #
assign weight to each element of tsvector
toTSvector :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGtext, 'PGjson, 'PGjsonb] => null ty --> null 'PGtsvector #
reduce document text to tsvector
toTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #
normalize words and convert to tsquery
queryTree :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGtext #
get indexable part of a tsquery
websearchToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #
produce tsquery from a web search style query
phraseToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #
produce tsquery that searches for a phrase,
ignoring punctuation
plainToTSquery :: forall (null :: PGType -> NullType). null 'PGtext --> null 'PGtsquery #
produce tsquery ignoring punctuation
numnode :: forall (null :: PGType -> NullType). null 'PGtsquery --> null 'PGint4 #
number of lexemes plus operators in tsquery
tsvectorLength :: forall (null :: PGType -> NullType). null 'PGtsvector --> null 'PGint4 #
number of lexemes in tsvector
arrayToTSvector :: forall (null :: PGType -> NullType). null ('PGvararray ('NotNull 'PGtext)) --> null 'PGtsvector #
convert array of lexemes to tsvector
(<->) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery) #
(.|) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery) #
OR tsquerys together
(.&) :: forall (null :: PGType -> NullType). Operator (null 'PGtsquery) (null 'PGtsquery) (null 'PGtsquery) #
AND tsquerys together
(@@) :: forall (null :: PGType -> NullType). Operator (null 'PGtsvector) (null 'PGtsquery) ('Null 'PGbool) #
tsvector matches tsquery ?
interval_ :: forall (null :: PGType -> NullType). Milli -> TimeUnit -> Expr (null 'PGinterval) #
>>>printSQL $ interval_ 7 Days(INTERVAL '7.000 days')
makeTimestamptz :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtimestamptz #
Create timestamp with time zone from year, month, day, hour, minute and seconds fields; the current time zone is used
>>>printSQL (makeTimestamptz (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))make_timestamptz((2013 :: int4), (7 :: int4), (15 :: int4), (8 :: int4), (15 :: int4), (23.5 :: float8))
makeTimestamp :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtimestamp #
Create timestamp from year, month, day, hour, minute and seconds fields
>>>printSQL (makeTimestamp (2013 :* 7 :* 15 :* 8 :* 15 *: 23.5))make_timestamp((2013 :: int4), (7 :: int4), (15 :: int4), (8 :: int4), (15 :: int4), (23.5 :: float8))
makeTime :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGfloat8] ---> null 'PGtime #
Create time from hour, minute and seconds fields
>>>printSQL (makeTime (8 :* 15 *: 23.5))make_time((8 :: int4), (15 :: int4), (23.5 :: float8))
makeDate :: forall (null :: PGType -> NullType). '[null 'PGint4, null 'PGint4, null 'PGint4] ---> null 'PGdate #
Create date from year, month and day fields
>>>printSQL (makeDate (1984 :* 7 *: 3))make_date((1984 :: int4), (7 :: int4), (3 :: int4))
now :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamptz) #
Current date and time (equivalent to currentTimestamp)
>>>printSQL nownow()
localTimestamp :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamp) #
>>>printSQL localTimestampLOCALTIMESTAMP
localTime :: forall (null :: PGType -> NullType). Expr (null 'PGtime) #
>>>printSQL localTimeLOCALTIME
currentTimestamp :: forall (null :: PGType -> NullType). Expr (null 'PGtimestamptz) #
>>>printSQL currentTimestampCURRENT_TIMESTAMP
currentTime :: forall (null :: PGType -> NullType). Expr (null 'PGtimetz) #
>>>printSQL currentTimeCURRENT_TIME
currentDate :: forall (null :: PGType -> NullType). Expr (null 'PGdate) #
>>>printSQL currentDateCURRENT_DATE
class TimeOp (time :: k) (diff :: k) | time -> diff where #
Affine space operations on time types.
Minimal complete definition
Nothing
Methods
(!+) :: forall (null :: k -> NullType). Operator (null time) (null diff) (null time) infixl 6 #
>>>printSQL (makeDate (1984 :* 7 *: 3) !+ 365)(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) + (365 :: int4))
(+!) :: forall (null :: k -> NullType). Operator (null diff) (null time) (null time) infixl 6 #
>>>printSQL (365 +! makeDate (1984 :* 7 *: 3))((365 :: int4) + make_date((1984 :: int4), (7 :: int4), (3 :: int4)))
(!-) :: forall (null :: k -> NullType). Operator (null time) (null diff) (null time) infixl 6 #
>>>printSQL (makeDate (1984 :* 7 *: 3) !- 365)(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) - (365 :: int4))
(!-!) :: forall (null :: k -> NullType). Operator (null time) (null time) (null diff) infixl 6 #
>>>printSQL (makeDate (1984 :* 7 *: 3) !-! currentDate)(make_date((1984 :: int4), (7 :: int4), (3 :: int4)) - CURRENT_DATE)
Instances
Constructors
| Years | |
| Months | |
| Weeks | |
| Days | |
| Hours | |
| Minutes | |
| Seconds | |
| Microseconds | |
| Milliseconds | |
| Decades | |
| Centuries | |
| Millennia |
Instances
columntypeFrom :: forall hask (db :: SchemasType). ColumnTyped db ('NoDef :=> NullPG hask) => ColumnTypeExpression db ('NoDef :=> NullPG hask) #
Specify ColumnTypeExpression from a Haskell type.
>>>printSQL $ columntypeFrom @(Maybe String)text NULL
>>>printSQL $ columntypeFrom @Doublefloat8 NOT NULL
nulltypeFrom :: forall hask (db :: SchemasType). NullTyped db (NullPG hask) => TypeExpression db (NullPG hask) #
Specify null TypeExpression from a Haskell type.
>>>printSQL $ nulltypeFrom @(Maybe String)text
>>>printSQL $ nulltypeFrom @Doublefloat8
bigserial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint8
serial8 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint8) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint8
serial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint4
serial4 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint4) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint4
smallserial :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint2
serial2 :: forall (db :: SchemasType). ColumnTypeExpression db ('Def :=> 'NotNull 'PGint2) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint2
Arguments
| :: forall (db :: SchemasType) (ty :: NullType). Expression 'Ungrouped ('[] :: [(Symbol, RowType)]) ('[] :: [(Symbol, RowType)]) db ('[] :: [NullType]) ('[] :: [(Symbol, RowType)]) ty | default value |
| -> ColumnTypeExpression db ('NoDef :=> ty) | column type |
| -> ColumnTypeExpression db ('Def :=> ty) |
used in createTable
commands as a column constraint to give a default
Arguments
| :: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType). TypeExpression db (null ty) | type |
| -> ColumnTypeExpression db ('NoDef :=> 'NotNull ty) |
used in createTable
commands as a column constraint to ensure
NULL is not present in a column
Arguments
| :: forall (db :: SchemasType) (null :: PGType -> NullType) (ty :: PGType). TypeExpression db (null ty) | type |
| -> ColumnTypeExpression db ('NoDef :=> 'Null ty) |
used in createTable
commands as a column constraint to note that
NULL may be present in a column
pgtypeFrom :: forall hask (db :: SchemasType) (null :: PGType -> NullType). PGTyped db (PG hask) => TypeExpression db (null (PG hask)) #
Specify TypeExpression from a Haskell type.
>>>printSQL $ pgtypeFrom @Stringtext
>>>printSQL $ pgtypeFrom @Doublefloat8
record :: forall (db :: SchemasType) (null :: PGType -> NullType) (record :: RowType). TypeExpression db (null ('PGcomposite record)) #
Anonymous composite record
daterange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGdate)) #
Range of date
tstzrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamptz)) #
Range of timestamp with time zone
tsrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGtimestamp)) #
Range of timestamp without time zone
numrange :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGnumeric)) #
Range of numeric
int8range :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint8)) #
Range of bigint
int4range :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null ('PGrange 'PGint4)) #
Range of integer
oid :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGoid) #
Object identifiers (OIDs) are used internally by PostgreSQL as primary keys for various system tables.
tsquery :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtsquery) #
text search document
tsvector :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtsvector) #
text search query
fixarray :: forall (dims :: [Nat]) (db :: SchemasType) (null :: PGType -> NullType) (pg :: NullType). All KnownNat dims => TypeExpression db pg -> TypeExpression db (null ('PGfixarray dims pg)) #
fixed length array
>>>renderSQL (fixarray @'[2] json)"json[2]"
vararray :: forall (db :: SchemasType) (pg :: NullType) (null :: PGType -> NullType). TypeExpression db pg -> TypeExpression db (null ('PGvararray pg)) #
variable length array
jsonb :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGjsonb) #
binary JSON data, decomposed
json :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGjson) #
textual JSON data
inet :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGinet) #
IPv4 or IPv6 host address
uuid :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGuuid) #
universally unique identifier
interval :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGinterval) #
time span
timetz :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz) #
time of day, including time zone
timeWithTimeZone :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimetz) #
time of day, including time zone
time :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtime) #
time of day (no time zone)
date :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGdate) #
calendar date (year, month, day)
timestamptz :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz) #
date and time, including time zone
timestampWithTimeZone :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamptz) #
date and time, including time zone
timestamp :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtimestamp) #
date and time (no time zone)
bytea :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGbytea) #
binary data ("byte array")
characterVarying :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGvarchar n)) #
variable-length character string
varchar :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGvarchar n)) #
variable-length character string
character :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGchar n)) #
fixed-length character string
char :: forall (n :: Nat) (db :: SchemasType) (null :: PGType -> NullType). (KnownNat n, 1 <= n) => TypeExpression db (null ('PGchar n)) #
fixed-length character string
text :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGtext) #
variable-length character string
money :: forall (schema :: SchemasType) (null :: PGType -> NullType). TypeExpression schema (null 'PGmoney) #
currency amount
doublePrecision :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8) #
double precision floating-point number (8 bytes)
float8 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat8) #
double precision floating-point number (8 bytes)
real :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4) #
single precision floating-point number (4 bytes)
float4 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGfloat4) #
single precision floating-point number (4 bytes)
numeric :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGnumeric) #
arbitrary precision numeric type
bigint :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint8) #
signed eight-byte integer
int8 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint8) #
signed eight-byte integer
integer :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #
signed four-byte integer
int :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #
signed four-byte integer
int4 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint4) #
signed four-byte integer
smallint :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint2) #
signed two-byte integer
int2 :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGint2) #
signed two-byte integer
bool :: forall (db :: SchemasType) (null :: PGType -> NullType). TypeExpression db (null 'PGbool) #
logical Boolean (true/false)
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (null :: PGType -> NullType). (Has sch db schema, Has vw schema ('View view)) | |
| => QualifiedAlias sch vw | view alias |
| -> TypeExpression db (null ('PGcomposite view)) |
The composite type corresponding to a View definition can be expressed
by its alias.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (null :: PGType -> NullType). (Has sch db schema, Has tab schema ('Table table)) | |
| => QualifiedAlias sch tab | table alias |
| -> TypeExpression db (null ('PGcomposite (TableToRow table))) |
The composite type corresponding to a Table definition can be expressed
by its alias.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (td :: Symbol) (ty :: PGType) (null :: PGType -> NullType). (Has sch db schema, Has td schema ('Typedef ty)) | |
| => QualifiedAlias sch td | type alias |
| -> TypeExpression db (null ty) |
The enum or composite type in a Typedef can be expressed by its alias.
Arguments
| :: forall (db :: SchemasType) (ty :: NullType) (lat :: Grouping) (common :: FromType) (grp :: FromType) (params :: [NullType]) (from :: FromType). NullTyped db ty | |
| => Expression lat common grp db params from ty | value |
| -> Expression lat common grp db params from ty |
inferredtype will add a type annotation to an Expression
which can be useful for fixing the storage type of a value.
>>>printSQL (inferredtype true)(TRUE :: bool)
Arguments
| :: forall (db :: SchemasType) (ty :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). TypeExpression db ty | type to specify as |
| -> Expression grp lat with db params from ty | value |
| -> Expression grp lat with db params from ty |
A safe version of cast which just matches a value with its type.
>>>printSQL (1 & astype int)((1 :: int4) :: int)
Arguments
| :: forall (db :: SchemasType) (ty1 :: NullType) (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType) (ty0 :: NullType). TypeExpression db ty1 | type to cast as |
| -> Expression grp lat with db params from ty0 | value to convert |
| -> Expression grp lat with db params from ty1 |
>>>printSQL $ true & cast int4(TRUE :: int4)
newtype TypeExpression (db :: SchemasType) (ty :: NullType) #
TypeExpressions are used in casts and
createTable commands.
Constructors
| UnsafeTypeExpression | |
Fields | |
Instances
class PGTyped (db :: SchemasType) (ty :: PGType) where #
Methods
pgtype :: forall (null :: PGType -> NullType). TypeExpression db (null ty) #
Instances
class FieldTyped (db :: SchemasType) (ty :: (Symbol, NullType)) where #
Lift PGTyped to a field
Methods
fieldtype :: Aliased (TypeExpression db) ty #
Instances
| (KnownSymbol alias, NullTyped db ty) => FieldTyped db (alias ::: ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods fieldtype :: Aliased (TypeExpression db) (alias ::: ty) # | |
newtype ColumnTypeExpression (db :: SchemasType) (ty :: ColumnType) #
ColumnTypeExpressions are used in
createTable commands.
Constructors
| UnsafeColumnTypeExpression | |
Fields | |
Instances
class NullTyped (db :: SchemasType) (ty :: NullType) where #
Like PGTyped but also accounts for null.
Methods
nulltype :: TypeExpression db ty #
Instances
| PGTyped db ty => NullTyped db (null ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods nulltype :: TypeExpression db (null ty) # | |
class ColumnTyped (db :: SchemasType) (column :: ColumnType) where #
Like PGTyped but also accounts for null.
Methods
columntype :: ColumnTypeExpression db column #
Instances
| NullTyped db ('Null ty) => ColumnTyped db ('NoDef :=> 'Null ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods columntype :: ColumnTypeExpression db ('NoDef :=> 'Null ty) # | |
| NullTyped db ('NotNull ty) => ColumnTyped db ('NoDef :=> 'NotNull ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods columntype :: ColumnTypeExpression db ('NoDef :=> 'NotNull ty) # | |
Arguments
| :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGtimestamp, 'PGtimestamptz] | |
| => '[null ty, null ty, null 'PGinterval] --|-> ("generate_series" ::: '["generate_series" ::: null ty]) | set returning function |
generateSeriesTimestamp (start :* stop *: step)
Generate a series of timestamps,
from start to stop with a step size of step
>>>:{let start = now stop = now !+ interval_ 10 Years step = interval_ 1 Months in printSQL (generateSeriesTimestamp (start :* stop *: step)) :} generate_series(now(), (now() + (INTERVAL '10.000 years')), (INTERVAL '1.000 months'))
Arguments
| :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGint4, 'PGint8, 'PGnumeric] | |
| => '[null ty, null ty, null ty] --|-> ("generate_series" ::: '["generate_series" ::: null ty]) | set returning function |
generateSeriesStep (start :* stop *: step)
Generate a series of values,
from start to stop with a step size of step
>>>printSQL (generateSeriesStep @'PGint8 (2 :* 100 *: 2))generate_series((2 :: int8), (100 :: int8), (2 :: int8))
Arguments
| :: forall (ty :: PGType) (null :: PGType -> NullType). In ty '['PGint4, 'PGint8, 'PGnumeric] | |
| => '[null ty, null ty] --|-> ("generate_series" ::: '["generate_series" ::: null ty]) | set returning function |
generateSeries (start :* stop)
Generate a series of values,
from start to stop with a step size of one
>>>printSQL (generateSeries @'PGint4 (1 *: 10))generate_series((1 :: int4), (10 :: int4))
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (tys :: [NullType]) (row :: RowType). (Has sch db schema, Has fun schema ('Function (tys :=> 'ReturnsTable row)), SListI tys) | |
| => QualifiedAlias sch fun | function alias |
| -> SetFunN db tys (fun ::: row) |
Call a user defined multivariable set returning function
>>>type Fn = '[ 'Null 'PGbool, 'Null 'PGtext] :=> 'ReturnsTable '["ret" ::: 'NotNull 'PGnumeric]>>>type Schema = '["fn" ::: 'Function Fn]>>>:{let fn :: SetFunN (Public Schema) '[ 'Null 'PGbool, 'Null 'PGtext] ("fn" ::: '["ret" ::: 'NotNull 'PGnumeric]) fn = setFunctionN #fn in printSQL (fn (true *: "hi")) :} "fn"(TRUE, (E'hi' :: text))
Arguments
| :: forall (fun :: Symbol) (tys :: [NullType]) (row :: RowType). (SListI tys, KnownSymbol fun) | |
| => ByteString | |
| -> tys --|-> (fun ::: row) | set returning function |
Escape hatch for a multivariable set returning function
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (ty :: NullType) (row :: RowType). (Has sch db schema, Has fun schema ('Function ('[ty] :=> 'ReturnsTable row))) | |
| => QualifiedAlias sch fun | function alias |
| -> SetFun db ty (fun ::: row) |
Call a user defined set returning function of a single variable
>>>type Fn = '[ 'Null 'PGbool] :=> 'ReturnsTable '["ret" ::: 'NotNull 'PGnumeric]>>>type Schema = '["fn" ::: 'Function Fn]>>>:{let fn :: SetFun (Public Schema) ('Null 'PGbool) ("fn" ::: '["ret" ::: 'NotNull 'PGnumeric]) fn = setFunction #fn in printSQL (fn true) :} "fn"(TRUE)
Arguments
| :: forall (fun :: Symbol) (ty :: NullType) (row :: RowType). KnownSymbol fun | |
| => ByteString | |
| -> ty -|-> (fun ::: row) | set returning function |
Escape hatch for a set returning function of a single variable
type (-|->) (arg :: NullType) (set :: (Symbol, RowType)) = forall (db :: SchemasType). SetFun db arg set #
A RankNType for set returning functions with 1 argument.
type (--|->) (arg :: [NullType]) (set :: (Symbol, RowType)) #
Arguments
| = forall (db :: SchemasType). SetFunN db arg set | output |
A RankNType for set returning functions with multiple argument.
type SetFun (db :: SchemasType) (arg :: NullType) (row :: (Symbol, RowType)) #
Arguments
| = forall (lat :: FromType) (with :: FromType) (params :: [NullType]). Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]) arg | input |
| -> FromClause lat with db params '[row] | output |
Like -|-> but depends on the schemas of the database
type SetFunN (db :: SchemasType) (args :: [NullType]) (set :: (Symbol, RowType)) #
Arguments
| = forall (lat :: FromType) (with :: FromType) (params :: [NullType]). NP (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)])) args | input |
| -> FromClause lat with db params '[set] | output |
Like --|-> but depends on the schemas of the database
Arguments
| :: forall (cols :: [(Symbol, NullType)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI cols | |
| => NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols | one row of values |
| -> Query lat with db params cols |
values_ computes a row value or set of row values
specified by value expressions.
Arguments
| :: forall (cols :: [(Symbol, NullType)]) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]). SListI cols | |
| => NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols | |
| -> [NP (Aliased (Expression 'Ungrouped lat with db params ('[] :: [(Symbol, RowType)]))) cols] | When more than one row is specified, all the rows must must have the same number of elements |
| -> Query lat with db params cols |
values computes a row value or set of row values
specified by value expressions. It is most commonly used
to generate a “constant table” within a larger command,
but it can be used on its own.
>>>type Row = '["a" ::: 'NotNull 'PGint4, "b" ::: 'NotNull 'PGtext]>>>let query = values (1 `as` #a :* "one" `as` #b) [] :: Query lat with db '[] Row>>>printSQL querySELECT * FROM (VALUES ((1 :: int4), (E'one' :: text))) AS t ("a", "b")
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (xs :: [NullType]) (y :: NullType). (Has sch db schema, Has fun schema ('Function (xs :=> 'Returns y)), SListI xs) | |
| => QualifiedAlias sch fun | function alias |
| -> FunN db xs y |
Call a user defined multivariable function
>>>type Fn = '[ 'Null 'PGint4, 'Null 'PGbool] :=> 'Returns ('NotNull 'PGnumeric)>>>type Schema = '["fn" ::: 'Function Fn]>>>:{let fn :: FunN (Public Schema) '[ 'Null 'PGint4, 'Null 'PGbool] ('NotNull 'PGnumeric) fn = functionN #fn in printSQL (fn (1 *: true)) :} "fn"((1 :: int4), TRUE)
unsafeFunctionN :: forall (xs :: [NullType]) (y :: NullType). SListI xs => ByteString -> xs ---> y #
>>>printSQL $ unsafeFunctionN "f" (currentTime :* localTimestamp :* false *: inline 'a')f(CURRENT_TIME, LOCALTIMESTAMP, FALSE, (E'a' :: char(1)))
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (fun :: Symbol) (x :: NullType) (y :: NullType). (Has sch db schema, Has fun schema ('Function ('[x] :=> 'Returns y))) | |
| => QualifiedAlias sch fun | function name |
| -> Fun db x y |
Call a user defined function of a single variable
>>>type Fn = '[ 'Null 'PGint4] :=> 'Returns ('NotNull 'PGnumeric)>>>type Schema = '["fn" ::: 'Function Fn]>>>:{let fn :: Fun (Public Schema) ('Null 'PGint4) ('NotNull 'PGnumeric) fn = function #fn in printSQL (fn 1) :} "fn"((1 :: int4))
unsafeFunction :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y #
>>>printSQL $ unsafeFunction "f" truef(TRUE)
unsafeRightOp :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y #
>>>printSQL $ true & unsafeRightOp "IS NOT TRUE"(TRUE IS NOT TRUE)
unsafeLeftOp :: forall (x :: NullType) (y :: NullType). ByteString -> x --> y #
>>>printSQL $ unsafeLeftOp "NOT" true(NOT TRUE)
unsafeBinaryOp :: forall (ty0 :: NullType) (ty1 :: NullType) (ty2 :: NullType). ByteString -> Operator ty0 ty1 ty2 #
>>>printSQL $ unsafeBinaryOp "OR" true false(TRUE OR FALSE)
unsafeFunctionVar :: forall (x0 :: NullType) (x1 :: NullType) (y :: NullType). ByteString -> FunctionVar x0 x1 y #
>>>printSQL (unsafeFunctionVar "greatest" [true, null_] false)greatest(TRUE, NULL, FALSE)
newtype Expression (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (ty :: NullType) #
Expressions are used in a variety of contexts,
such as in the target List of the
select command,
as new column values in insertInto or
update,
or in search Conditions
in a number of commands.
The expression syntax allows the calculation of values from primitive expression using arithmetic, logical, and other operations.
The type parameters of Expression are
lat ::FromType, thefromclauses of any lat queries in which theExpressionis a correlated subquery expression;with ::FromType, theCommonTableExpressions that are in scope for theExpression;grp ::Grouping, theGroupingof thefromclause which may limit which columns may be referenced by alias;db ::SchemasType, the schemas of your database that are in scope for theExpression;from ::FromType, thefromclause which theExpressionmay use to reference columns by alias;ty ::NullType, the type of theExpression.
Constructors
| UnsafeExpression | |
Fields | |
Instances
| Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # | |
| (Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty) => IsQualified tab col (Expression 'Ungrouped lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (Expression ('Grouped bys) lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column # | |
| (HasUnique tab (Join from lat) row, Has col row ty) => IsLabel col (Expression 'Ungrouped lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression 'Ungrouped lat with db params from ty # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsLabel col (Expression ('Grouped bys) lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression ('Grouped bys) lat with db params from ty # | |
| (KnownSymbol label, In label labels) => IsPGlabel label (Expression grp lat with db params from (null ('PGenum labels))) | |
Defined in Squeal.PostgreSQL.Expression Methods label :: Expression grp lat with db params from (null ('PGenum labels)) # | |
| (KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) | |
Defined in Squeal.PostgreSQL.Query.Select Methods as :: Expression grp lat with db params from ty -> Alias col -> Selection grp lat with db params from row # | |
| Eq (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods (==) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool # (/=) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool # | |
| Floating (Expression grp lat with db params from (null 'PGfloat4)) | |
Defined in Squeal.PostgreSQL.Expression Methods pi :: Expression grp lat with db params from (null 'PGfloat4) # exp :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # log :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # sqrt :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # (**) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # logBase :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # sin :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # cos :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # tan :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # asin :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # acos :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # atan :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # sinh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # cosh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # tanh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # asinh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # acosh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # atanh :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # log1p :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # expm1 :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # log1pexp :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # log1mexp :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # | |
| Floating (Expression grp lat with db params from (null 'PGfloat8)) | |
Defined in Squeal.PostgreSQL.Expression Methods pi :: Expression grp lat with db params from (null 'PGfloat8) # exp :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # log :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # sqrt :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # (**) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # logBase :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # sin :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # cos :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # tan :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # asin :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # acos :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # atan :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # sinh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # cosh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # tanh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # asinh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # acosh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # atanh :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # log1p :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # expm1 :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # log1pexp :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # log1mexp :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # | |
| Floating (Expression grp lat with db params from (null 'PGnumeric)) | |
Defined in Squeal.PostgreSQL.Expression Methods pi :: Expression grp lat with db params from (null 'PGnumeric) # exp :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # log :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # sqrt :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # (**) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # logBase :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # sin :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # cos :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # tan :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # asin :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # acos :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # atan :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # sinh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # cosh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # tanh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # asinh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # acosh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # atanh :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # log1p :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # expm1 :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # log1pexp :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # log1mexp :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # | |
| Fractional (Expression grp lat with db params from (null 'PGfloat4)) | |
Defined in Squeal.PostgreSQL.Expression Methods (/) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # recip :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # fromRational :: Rational -> Expression grp lat with db params from (null 'PGfloat4) # | |
| Fractional (Expression grp lat with db params from (null 'PGfloat8)) | |
Defined in Squeal.PostgreSQL.Expression Methods (/) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # recip :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # fromRational :: Rational -> Expression grp lat with db params from (null 'PGfloat8) # | |
| Fractional (Expression grp lat with db params from (null 'PGnumeric)) | |
Defined in Squeal.PostgreSQL.Expression Methods (/) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # recip :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # fromRational :: Rational -> Expression grp lat with db params from (null 'PGnumeric) # | |
| Num (Expression grp lat with db params from (null 'PGint2)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) # (-) :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) # (*) :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) # negate :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) # abs :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) # signum :: Expression grp lat with db params from (null 'PGint2) -> Expression grp lat with db params from (null 'PGint2) # fromInteger :: Integer -> Expression grp lat with db params from (null 'PGint2) # | |
| Num (Expression grp lat with db params from (null 'PGint4)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) # (-) :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) # (*) :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) # negate :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) # abs :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) # signum :: Expression grp lat with db params from (null 'PGint4) -> Expression grp lat with db params from (null 'PGint4) # fromInteger :: Integer -> Expression grp lat with db params from (null 'PGint4) # | |
| Num (Expression grp lat with db params from (null 'PGint8)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) # (-) :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) # (*) :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) # negate :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) # abs :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) # signum :: Expression grp lat with db params from (null 'PGint8) -> Expression grp lat with db params from (null 'PGint8) # fromInteger :: Integer -> Expression grp lat with db params from (null 'PGint8) # | |
| Num (Expression grp lat with db params from (null 'PGfloat4)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # (-) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # (*) :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # negate :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # abs :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # signum :: Expression grp lat with db params from (null 'PGfloat4) -> Expression grp lat with db params from (null 'PGfloat4) # fromInteger :: Integer -> Expression grp lat with db params from (null 'PGfloat4) # | |
| Num (Expression grp lat with db params from (null 'PGfloat8)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # (-) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # (*) :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # negate :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # abs :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # signum :: Expression grp lat with db params from (null 'PGfloat8) -> Expression grp lat with db params from (null 'PGfloat8) # fromInteger :: Integer -> Expression grp lat with db params from (null 'PGfloat8) # | |
| Num (Expression grp lat with db params from (null 'PGnumeric)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # (-) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # (*) :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # negate :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # abs :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # signum :: Expression grp lat with db params from (null 'PGnumeric) -> Expression grp lat with db params from (null 'PGnumeric) # fromInteger :: Integer -> Expression grp lat with db params from (null 'PGnumeric) # | |
| Ord (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods compare :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Ordering # (<) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool # (<=) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool # (>) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool # (>=) :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Bool # max :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty # min :: Expression grp lat with db params from ty -> Expression grp lat with db params from ty -> Expression grp lat with db params from ty # | |
| Show (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods showsPrec :: Int -> Expression grp lat with db params from ty -> ShowS # show :: Expression grp lat with db params from ty -> String # showList :: [Expression grp lat with db params from ty] -> ShowS # | |
| IsString (Expression grp lat with db params from (null 'PGtext)) | |
Defined in Squeal.PostgreSQL.Expression Methods fromString :: String -> Expression grp lat with db params from (null 'PGtext) # | |
| IsString (Expression grp lat with db params from (null 'PGtsvector)) | |
Defined in Squeal.PostgreSQL.Expression Methods fromString :: String -> Expression grp lat with db params from (null 'PGtsvector) # | |
| IsString (Expression grp lat with db params from (null 'PGtsquery)) | |
Defined in Squeal.PostgreSQL.Expression Methods fromString :: String -> Expression grp lat with db params from (null 'PGtsquery) # | |
| Generic (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Associated Types type Rep (Expression grp lat with db params from ty) :: Type -> Type # Methods from :: Expression grp lat with db params from ty -> Rep (Expression grp lat with db params from ty) x # to :: Rep (Expression grp lat with db params from ty) x -> Expression grp lat with db params from ty # | |
| Semigroup (Expression grp lat with db params from (null ('PGvararray ty))) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression grp lat with db params from (null ('PGvararray ty)) -> Expression grp lat with db params from (null ('PGvararray ty)) -> Expression grp lat with db params from (null ('PGvararray ty)) # sconcat :: NonEmpty (Expression grp lat with db params from (null ('PGvararray ty))) -> Expression grp lat with db params from (null ('PGvararray ty)) # stimes :: Integral b => b -> Expression grp lat with db params from (null ('PGvararray ty)) -> Expression grp lat with db params from (null ('PGvararray ty)) # | |
| Semigroup (Expression grp lat with db params from (null 'PGjsonb)) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression grp lat with db params from (null 'PGjsonb) -> Expression grp lat with db params from (null 'PGjsonb) -> Expression grp lat with db params from (null 'PGjsonb) # sconcat :: NonEmpty (Expression grp lat with db params from (null 'PGjsonb)) -> Expression grp lat with db params from (null 'PGjsonb) # stimes :: Integral b => b -> Expression grp lat with db params from (null 'PGjsonb) -> Expression grp lat with db params from (null 'PGjsonb) # | |
| Semigroup (Expression grp lat with db params from (null 'PGtext)) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) # sconcat :: NonEmpty (Expression grp lat with db params from (null 'PGtext)) -> Expression grp lat with db params from (null 'PGtext) # stimes :: Integral b => b -> Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) # | |
| Semigroup (Expression grp lat with db params from (null 'PGtsvector)) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) # sconcat :: NonEmpty (Expression grp lat with db params from (null 'PGtsvector)) -> Expression grp lat with db params from (null 'PGtsvector) # stimes :: Integral b => b -> Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) # | |
| Monoid (Expression grp lat with db params from (null 'PGtext)) | |
Defined in Squeal.PostgreSQL.Expression Methods mempty :: Expression grp lat with db params from (null 'PGtext) # mappend :: Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) -> Expression grp lat with db params from (null 'PGtext) # mconcat :: [Expression grp lat with db params from (null 'PGtext)] -> Expression grp lat with db params from (null 'PGtext) # | |
| Monoid (Expression grp lat with db params from (null 'PGtsvector)) | |
Defined in Squeal.PostgreSQL.Expression Methods mempty :: Expression grp lat with db params from (null 'PGtsvector) # mappend :: Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) -> Expression grp lat with db params from (null 'PGtsvector) # mconcat :: [Expression grp lat with db params from (null 'PGtsvector)] -> Expression grp lat with db params from (null 'PGtsvector) # | |
| NFData (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods rnf :: Expression grp lat with db params from ty -> () # | |
| RenderSQL (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods renderSQL :: Expression grp lat with db params from ty -> ByteString # | |
| type Rep (Expression grp lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression type Rep (Expression grp lat with db params from ty) = D1 ('MetaData "Expression" "Squeal.PostgreSQL.Expression" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeExpression" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderExpression") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x | cannot reference aliases |
An Expr is a closed Expression.
It is a FRankNType but don't be scared.
Think of it as an expression which sees no
namespaces, so you can't use parameters
or alias references. It can be used as
a simple piece of more complex Expressions.
type Operator (x1 :: NullType) (x2 :: NullType) (y :: NullType) = forall (db :: SchemasType). OperatorDB db x1 x2 y #
A RankNType for binary operators.
type OperatorDB (db :: SchemasType) (x1 :: NullType) (x2 :: NullType) (y :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x1 | left input |
| -> Expression grp lat with db params from x2 | right input |
| -> Expression grp lat with db params from y | output |
Like Operator but depends on the schemas of the database
type Fun (db :: SchemasType) (x :: NullType) (y :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). Expression grp lat with db params from x | input |
| -> Expression grp lat with db params from y | output |
Like --> but depends on the schemas of the database
type (--->) (xs :: [NullType]) (y :: NullType) = forall (db :: SchemasType). FunN db xs y #
A RankNType for functions with a fixed-length list of heterogeneous arguments.
Use the *: operator to end your argument lists, like so.
>>>printSQL (unsafeFunctionN "fun" (true :* false :* localTime *: true))fun(TRUE, FALSE, LOCALTIME, TRUE)
type FunN (db :: SchemasType) (xs :: [NullType]) (y :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (params :: [NullType]) (from :: FromType). NP (Expression grp lat with db params from) xs | inputs |
| -> Expression grp lat with db params from y | output |
Like ---> but depends on the schemas of the database
type FunctionVar (x0 :: NullType) (x1 :: NullType) (y :: NullType) #
Arguments
| = forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). [Expression grp lat with db params from x0] | inputs |
| -> Expression grp lat with db params from x1 | must have at least 1 input |
| -> Expression grp lat with db params from y | output |
A RankNType for functions with a variable-length list of
homogeneous arguments and at least 1 more argument.
class PGSubset (ty :: k) where #
Contained by operators
Minimal complete definition
Nothing
Methods
(@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #
(<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #
Instances
| PGSubset 'PGtsquery | |
Defined in Squeal.PostgreSQL.Expression | |
| PGSubset 'PGjsonb | |
| PGSubset ('PGrange ty :: PGType) | |
Defined in Squeal.PostgreSQL.Expression | |
| PGSubset ('PGvararray ty :: PGType) | |
Defined in Squeal.PostgreSQL.Expression Methods (@>) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) # (<@) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) # | |
class PGIntersect (ty :: k) where #
Intersection operator
Minimal complete definition
Nothing
Methods
(@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ty) (null1 ty) ('Null 'PGbool) #
Instances
| PGIntersect ('PGrange ty :: PGType) | |
| PGIntersect ('PGvararray ty :: PGType) | |
Defined in Squeal.PostgreSQL.Expression Methods (@&&) :: forall (null0 :: k -> NullType) (null1 :: k -> NullType). Operator (null0 ('PGvararray ty)) (null1 ('PGvararray ty)) ('Null 'PGbool) # | |
mapOptional :: forall k expr (x :: k) (y :: k) (def :: Optionality). (expr x -> expr y) -> Optional expr (def :=> x) -> Optional expr (def :=> y) #
Map a function over an Optional expression.
pattern NotDefault :: ty -> Optional I ('Def :=> ty) #
NotDefault pattern analagous to Just.
data Optional (expr :: k -> Type) (ty :: (Optionality, k)) where #
Optional is either Default or Setting of a value,
parameterized by an appropriate Optionality.
Constructors
| Default :: forall k (expr :: k -> Type) (ty1 :: k). Optional expr '('Def, ty1) | Use the |
| Set :: forall k (expr :: k -> Type) (ty1 :: k) (def :: Optionality). expr ty1 -> Optional expr '(def, ty1) |
|
Instances
| (forall (x :: k). RenderSQL (expr x)) => RenderSQL (Optional expr ty) | |
Defined in Squeal.PostgreSQL.Expression.Default Methods renderSQL :: Optional expr ty -> ByteString # | |
| (KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) | |
Defined in Squeal.PostgreSQL.Expression.Inline | |
Arguments
| :: forall (cte :: Symbol) (with :: [(Symbol, RowType)]) (common :: RowType) (alias :: Symbol) (lat :: FromType) (db :: SchemasType) (params :: [NullType]). Has cte with common | |
| => Aliased Alias (alias ::: cte) | (renamable) common table expression alias |
| -> FromClause lat with db params '[alias ::: common] |
common derives a table from a common table expression.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (vw :: Symbol) (view :: RowType) (alias :: Symbol) (lat :: FromType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has vw schema ('View view)) | |
| => Aliased (QualifiedAlias sch) (alias ::: vw) | (renamable) view alias |
| -> FromClause lat with db params '[alias ::: view] |
Arguments
| :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (query :: (Symbol, RowType)). Aliased (Query lat with db params) query | aliased |
| -> FromClause lat with db params '[query] |
subquery derives a table from a Query.
The subquery may not reference columns provided by preceding FromClause items.
Use JoinLateral
if the subquery must reference columns provided by preceding FromClause items.
Arguments
| :: forall (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (table :: TableType) (alias :: Symbol) (lat :: FromType) (with :: FromType) (params :: [NullType]). (Has sch db schema, Has tab schema ('Table table)) | |
| => Aliased (QualifiedAlias sch) (alias ::: tab) | (renamable) table alias |
| -> FromClause lat with db params '[alias ::: TableToRow table] |
A real table is a table from the database.
newtype FromClause (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) #
A FromClause can be a table name, or a derived table such
as a subquery, a JOIN construct, or complex combinations of these.
Constructors
| UnsafeFromClause | |
Fields | |
Instances
| Additional (FromClause lat with db params :: FromType -> Type) | |
Defined in Squeal.PostgreSQL.Query.From Methods also :: forall (ys :: [a]) (xs :: [a]). FromClause lat with db params ys -> FromClause lat with db params xs -> FromClause lat with db params (Join xs ys) # | |
| Eq (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From Methods (==) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool # (/=) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool # | |
| Ord (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From Methods compare :: FromClause lat with db params from -> FromClause lat with db params from -> Ordering # (<) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool # (<=) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool # (>) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool # (>=) :: FromClause lat with db params from -> FromClause lat with db params from -> Bool # max :: FromClause lat with db params from -> FromClause lat with db params from -> FromClause lat with db params from # min :: FromClause lat with db params from -> FromClause lat with db params from -> FromClause lat with db params from # | |
| Show (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From Methods showsPrec :: Int -> FromClause lat with db params from -> ShowS # show :: FromClause lat with db params from -> String # showList :: [FromClause lat with db params from] -> ShowS # | |
| Generic (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From Associated Types type Rep (FromClause lat with db params from) :: Type -> Type # Methods from :: FromClause lat with db params from -> Rep (FromClause lat with db params from) x # to :: Rep (FromClause lat with db params from) x -> FromClause lat with db params from # | |
| NFData (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From Methods rnf :: FromClause lat with db params from -> () # | |
| RenderSQL (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From Methods renderSQL :: FromClause lat with db params from -> ByteString # | |
| type Rep (FromClause lat with db params from) | |
Defined in Squeal.PostgreSQL.Query.From type Rep (FromClause lat with db params from) = D1 ('MetaData "FromClause" "Squeal.PostgreSQL.Query.From" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeFromClause" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderFromClause") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
Arguments
| :: forall (lat :: FromType) (recursive :: (Symbol, RowType)) (with :: [(Symbol, RowType)]) (db :: SchemasType) (params :: [NullType]) (row :: RowType). Aliased (Query lat (recursive ': with) db params) recursive | recursive query |
| -> Query lat (recursive ': with) db params row | larger query |
| -> Query lat with db params row |
A withRecursive Query can refer to its own output.
A very simple example is this query to sum the integers from 1 through 100:
>>>import Data.Monoid (Sum (..))>>>import Data.Int (Int64)>>>:{let sum100 :: Statement db () (Sum Int64) sum100 = query $ withRecursive ( values_ ((1 & astype int) `as` #n) `unionAll` select_ ((#n + 1) `as` #n) (from (common #t) & where_ (#n .< 100)) `as` #t ) ( select_ (fromNull 0 (sum_ (All #n)) `as` #getSum) (from (common #t) & groupBy Nil) ) in printSQL sum100 :} WITH RECURSIVE "t" AS ((SELECT * FROM (VALUES (((1 :: int4) :: int))) AS t ("n")) UNION ALL (SELECT ("n" + (1 :: int4)) AS "n" FROM "t" AS "t" WHERE ("n" < (100 :: int4)))) SELECT COALESCE(sum(ALL "n"), (0 :: int8)) AS "getSum" FROM "t" AS "t"
The general form of a recursive WITH query is always a non-recursive term,
then union (or unionAll), then a recursive term, where
only the recursive term can contain a reference to the query's own output.
class With (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) where #
with provides a way to write auxiliary statements for use in a larger query.
These statements, referred to as CommonTableExpressions, can be thought of as
defining temporary tables that exist just for one query.
with can be used for a Query. Multiple CommonTableExpressions can be
chained together with the Path constructor :>>, and each CommonTableExpression
is constructed via overloaded as.
>>>type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = with ( select Star (from (table #tab)) `as` #cte1 :>> select Star (from (common #cte1)) `as` #cte2 ) (select Star (from (common #cte2))) in printSQL qry :} WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"
You can use data-modifying statements in with. This allows you to perform several
different operations in the same query. An example is:
>>>type ProductsColumns = '["product" ::: 'NoDef :=> 'NotNull 'PGtext, "date" ::: 'Def :=> 'NotNull 'PGdate]>>>type ProductsSchema = '["products" ::: 'Table ('[] :=> ProductsColumns), "products_deleted" ::: 'Table ('[] :=> ProductsColumns)]>>>:{let manp :: Manipulation with (Public ProductsSchema) '[ 'NotNull 'PGdate] '[] manp = with (deleteFrom #products NoUsing (#date .< param @1) (Returning Star) `as` #del) (insertInto_ #products_deleted (Subquery (select Star (from (common #del))))) in printSQL manp :} WITH "del" AS (DELETE FROM "products" AS "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" AS "products_deleted" SELECT * FROM "del" AS "del"
Methods
Arguments
| :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression statement db params) with0 with1 | common table expressions |
| -> statement with1 db params row | larger query |
| -> statement with0 db params row |
Instances
| With Manipulation | |
Defined in Squeal.PostgreSQL.Manipulation Methods with :: forall (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) (row :: RowType). Path (CommonTableExpression Manipulation db params) with0 with1 -> Manipulation with1 db params row -> Manipulation with0 db params row # | |
| With (Query lat) | |
Defined in Squeal.PostgreSQL.Query.With | |
data CommonTableExpression (statement :: FromType -> SchemasType -> [NullType] -> RowType -> Type) (db :: SchemasType) (params :: [NullType]) (with0 :: FromType) (with1 :: FromType) where #
A CommonTableExpression is an auxiliary statement in a with clause.
Constructors
| CommonTableExpression | |
Fields
| |
Instances
| (KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 # | |
| (KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (CommonTableExpression statement db params with with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods as :: statement with db params common -> Alias cte -> CommonTableExpression statement db params with with1 # | |
| (forall (c :: FromType) (s :: SchemasType) (p :: [NullType]) (r :: RowType). RenderSQL (statement c s p r)) => RenderSQL (CommonTableExpression statement db params with0 with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods renderSQL :: CommonTableExpression statement db params with0 with1 -> ByteString # | |
exceptAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #
The results of two queries can be combined using the set operation
exceptAll, the set difference. Duplicate rows are retained.
except :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #
The results of two queries can be combined using the set operation
except, the set difference. Duplicate rows are eliminated.
intersectAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #
The results of two queries can be combined using the set operation
intersectAll, the intersection. Duplicate rows are retained.
intersect :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #
The results of two queries can be combined using the set operation
intersect, the intersection. Duplicate rows are eliminated.
unionAll :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #
The results of two queries can be combined using the set operation
unionAll, the disjoint union. Duplicate rows are retained.
union :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (columns :: RowType). Query lat with db params columns -> Query lat with db params columns -> Query lat with db params columns #
The results of two queries can be combined using the set operation
union. Duplicate rows are eliminated.
newtype Query (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (row :: RowType) #
The process of retrieving or the command to retrieve data from
a database is called a Query.
The general Query type is parameterized by
lat :: FromType- scope forJoinLateraland subquery expressions,with :: FromType- scope for allcommontable expressions,db :: SchemasType- scope for alltables andviews,params :: [NullType]- scope for allparameters,row :: RowType- return type of theQuery.
Let's see some Query examples.
simple query:
>>>type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let qry :: Query lat with (Public Schema) '[] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select Star (from (table #tab)) in printSQL qry :} SELECT * FROM "tab" AS "tab"
restricted query:
>>>:{let qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select_ ((#col1 + #col2) `as` #col1 :* #col1 `as` #col2) ( from (table #tab) & where_ (#col1 .> #col2) & where_ (#col2 .> 0) ) in printSQL qry :} SELECT ("col1" + "col2") AS "col1", "col1" AS "col2" FROM "tab" AS "tab" WHERE (("col1" > "col2") AND ("col2" > (0 :: int4)))
subquery:
>>>:{let qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select Star (from (subquery (select Star (from (table #tab)) `as` #sub))) in printSQL qry :} SELECT * FROM (SELECT * FROM "tab" AS "tab") AS "sub"
limits and offsets:
>>>:{let qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select Star (from (table #tab) & limit 100 & offset 2 & limit 50 & offset 2) in printSQL qry :} SELECT * FROM "tab" AS "tab" LIMIT 50 OFFSET 4
parameterized query:
>>>:{let qry :: Query '[] with (Public Schema) '[ 'NotNull 'PGint4] '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select Star (from (table #tab) & where_ (#col1 .> param @1)) in printSQL qry :} SELECT * FROM "tab" AS "tab" WHERE ("col1" > ($1 :: int4))
aggregation query:
>>>:{let qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint8, "col2" ::: 'NotNull 'PGint4] qry = select_ ((fromNull 0 (sum_ (All #col2))) `as` #col1 :* #col1 `as` #col2) ( from (table (#tab `as` #table1)) & groupBy #col1 & having (sum_ (Distinct #col2) .> 1) ) in printSQL qry :} SELECT COALESCE(sum(ALL "col2"), (0 :: int8)) AS "col1", "col1" AS "col2" FROM "tab" AS "table1" GROUP BY "col1" HAVING (sum(DISTINCT "col2") > (1 :: int8))
sorted query:
>>>:{let qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select Star (from (table #tab) & orderBy [#col1 & Asc]) in printSQL qry :} SELECT * FROM "tab" AS "tab" ORDER BY "col1" ASC
joins:
>>>:{type OrdersColumns = '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4 , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4 , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4 , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4 ] :}
>>>:{type OrdersConstraints = '["pk_orders" ::: PrimaryKey '["id"] ,"fk_customers" ::: ForeignKey '["customer_id"] "public" "customers" '["id"] ,"fk_shippers" ::: ForeignKey '["shipper_id"] "public" "shippers" '["id"] ] :}
>>>type NamesColumns = '["id" ::: 'NoDef :=> 'NotNull 'PGint4, "name" ::: 'NoDef :=> 'NotNull 'PGtext]>>>type CustomersConstraints = '["pk_customers" ::: PrimaryKey '["id"]]>>>type ShippersConstraints = '["pk_shippers" ::: PrimaryKey '["id"]]>>>:{type OrdersSchema = '[ "orders" ::: 'Table (OrdersConstraints :=> OrdersColumns) , "customers" ::: 'Table (CustomersConstraints :=> NamesColumns) , "shippers" ::: 'Table (ShippersConstraints :=> NamesColumns) ] :}
>>>:{type OrderRow = '[ "price" ::: 'NotNull 'PGfloat4 , "customerName" ::: 'NotNull 'PGtext , "shipperName" ::: 'NotNull 'PGtext ] :}
>>>:{let qry :: Query lat with (Public OrdersSchema) params OrderRow qry = select_ ( #o ! #price `as` #price :* #c ! #name `as` #customerName :* #s ! #name `as` #shipperName ) ( from (table (#orders `as` #o) & innerJoin (table (#customers `as` #c)) (#o ! #customer_id .== #c ! #id) & innerJoin (table (#shippers `as` #s)) (#o ! #shipper_id .== #s ! #id)) ) in printSQL qry :} SELECT "o"."price" AS "price", "c"."name" AS "customerName", "s"."name" AS "shipperName" FROM "orders" AS "o" INNER JOIN "customers" AS "c" ON ("o"."customer_id" = "c"."id") INNER JOIN "shippers" AS "s" ON ("o"."shipper_id" = "s"."id")
self-join:
>>>:{let qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select (#t1 & DotStar) (from (table (#tab `as` #t1) & crossJoin (table (#tab `as` #t2)))) in printSQL qry :} SELECT "t1".* FROM "tab" AS "t1" CROSS JOIN "tab" AS "t2"
value queries:
>>>:{let qry :: Query lat with db params '["col1" ::: 'NotNull 'PGtext, "col2" ::: 'NotNull 'PGbool] qry = values ("true" `as` #col1 :* true `as` #col2) ["false" `as` #col1 :* false `as` #col2] in printSQL qry :} SELECT * FROM (VALUES ((E'true' :: text), TRUE), ((E'false' :: text), FALSE)) AS t ("col1", "col2")
set operations:
>>>:{let qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = select Star (from (table #tab)) `unionAll` select Star (from (table #tab)) in printSQL qry :} (SELECT * FROM "tab" AS "tab") UNION ALL (SELECT * FROM "tab" AS "tab")
with query:
>>>:{let qry :: Query lat with (Public Schema) params '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint4] qry = with ( select Star (from (table #tab)) `as` #cte1 :>> select Star (from (common #cte1)) `as` #cte2 ) (select Star (from (common #cte2))) in printSQL qry :} WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"
window functions:
>>>:{let qry :: Query '[] with (Public Schema) db '["col1" ::: 'NotNull 'PGint4, "col2" ::: 'NotNull 'PGint8] qry = select (#col1 & Also (rank `as` #col2 `Over` (partitionBy #col1 & orderBy [#col2 & Asc]))) (from (table #tab)) in printSQL qry :} SELECT "col1" AS "col1", rank() OVER (PARTITION BY "col1" ORDER BY "col2" ASC) AS "col2" FROM "tab" AS "tab"
correlated subqueries:
>>>:{let qry :: Query '[] with (Public Schema) params '["col1" ::: 'NotNull 'PGint4] qry = select #col1 (from (table (#tab `as` #t1)) & where_ (exists ( select Star (from (table (#tab `as` #t2)) & where_ (#t2 ! #col2 .== #t1 ! #col1))))) in printSQL qry :} SELECT "col1" AS "col1" FROM "tab" AS "t1" WHERE EXISTS (SELECT * FROM "tab" AS "t2" WHERE ("t2"."col2" = "t1"."col1"))
Constructors
| UnsafeQuery | |
Fields | |
Instances
| With (Query lat) | |
Defined in Squeal.PostgreSQL.Query.With | |
| Eq (Query lat with db params row) | |
| Ord (Query lat with db params row) | |
Defined in Squeal.PostgreSQL.Query Methods compare :: Query lat with db params row -> Query lat with db params row -> Ordering # (<) :: Query lat with db params row -> Query lat with db params row -> Bool # (<=) :: Query lat with db params row -> Query lat with db params row -> Bool # (>) :: Query lat with db params row -> Query lat with db params row -> Bool # (>=) :: Query lat with db params row -> Query lat with db params row -> Bool # max :: Query lat with db params row -> Query lat with db params row -> Query lat with db params row # min :: Query lat with db params row -> Query lat with db params row -> Query lat with db params row # | |
| Show (Query lat with db params row) | |
| Generic (Query lat with db params row) | |
| NFData (Query lat with db params row) | |
Defined in Squeal.PostgreSQL.Query | |
| RenderSQL (Query lat with db params row) | |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: Query lat with db params row -> ByteString # | |
| type Rep (Query lat with db params row) | |
Defined in Squeal.PostgreSQL.Query type Rep (Query lat with db params row) = D1 ('MetaData "Query" "Squeal.PostgreSQL.Query" "squeal-postgresql-0.7.0.1-LuGIM9nYGrdDFOezqKmY9J" 'True) (C1 ('MetaCons "UnsafeQuery" 'PrefixI 'True) (S1 ('MetaSel ('Just "renderQuery") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) | |
type family Query_ (db :: SchemasType) params row where ... #
The Query_ type is parameterized by a db SchemasType,
against which the query is type-checked, an input params Haskell Type,
and an ouput row Haskell Type.
A Query_ can be run
using runQueryParams, or if params = ()
using runQuery.
Generally, params will be a Haskell tuple or record whose entries
may be referenced using positional
parameters and row will be a
Haskell record, whose entries will be targeted using overloaded labels.
Query_ is a type family which resolves into a Query,
so don't be fooled by the input params and output row Haskell Types,
which are converted into appropriate
Postgres [NullType] params and RowType rows.
Use query to
fix actual Haskell input params and output rows.
>>>:set -XDeriveAnyClass -XDerivingStrategies>>>type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint8, "col2" ::: 'Def :=> 'NotNull 'PGtext]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{data Row = Row { col1 :: Maybe Int64, col2 :: String } deriving stock (GHC.Generic) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) :}
>>>:{let qry :: Query_ (Public Schema) (Int64, Bool) Row qry = select Star (from (table #tab) & where_ (#col1 .> param @1 .&& notNull (param @2))) stmt :: Statement (Public Schema) (Int64, Bool) Row stmt = query qry :}
>>>:type qryqry :: Query '[] '[] '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]] '[ 'NotNull 'PGint8, 'NotNull 'PGbool] '["col1" ::: 'Null 'PGint8, "col2" ::: 'NotNull 'PGtext]>>>:type stmtstmt :: Statement '["public" ::: '["tab" ::: 'Table ('[] :=> Columns)]] (Int64, Bool) Row
lowerConnection :: forall a (schema :: a) (db :: [a]). K Connection (schema ': db) -> K Connection db #
Safely lowerConnection to a smaller schema.
finish :: forall k io (db :: k). MonadIO io => K Connection db -> io () #
Closes the connection to the server.
Arguments
| :: forall (db :: SchemasType) io. MonadIO io | |
| => ByteString | conninfo |
| -> io (K Connection db) |
Makes a new connection to the database server.
This function opens a new database connection using the parameters taken from the string conninfo.
The passed string can be empty to use all default parameters, or it can contain one or more parameter settings separated by whitespace. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value or a value containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., ' and .
To specify the schema you wish to connect with, use type application.
>>>:set -XDataKinds>>>:set -XPolyKinds>>>:set -XTypeOperators>>>type DB = '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint2])]]>>>:set -XTypeApplications>>>:set -XOverloadedStrings>>>conn <- connectdb @DB "host=localhost port=5432 dbname=exampledb user=postgres password=postgres"
Note that, for now, squeal doesn't offer any protection from connecting with the wrong schema!
class OidOf (db :: SchemasType) (pg :: PGType) where #
>>>:set -XTypeApplications>>>conn <- connectdb @'[] "host=localhost port=5432 dbname=exampledb user=postgres password=postgres">>>runReaderT (oidOf @'[] @'PGbool) connOid 16
>>>finish conn
Instances
class OidOfArray (db :: SchemasType) (pg :: PGType) where #
The Oid of an array
Methods
oidOfArray :: ReaderT (K Connection db) IO Oid #
Instances
class OidOfNull (db :: SchemasType) (ty :: NullType) where #
Instances
| OidOf db pg => OidOfNull db (null pg) | |
Defined in Squeal.PostgreSQL.Session.Oid | |
class OidOfField (db :: SchemasType) (field :: (Symbol, NullType)) where #
The Oid of a field
Methods
oidOfField :: ReaderT (K Connection db) IO Oid #
Instances
| OidOfNull db ty => OidOfField db (fld ::: ty) | |
Defined in Squeal.PostgreSQL.Session.Oid Methods oidOfField :: ReaderT (K Connection db) IO Oid # | |
type family PG hask :: PGType #
Instances
The PG type family embeds a subset of Haskell types
as Postgres types. As an open type family, PG is extensible.
>>>:kind! PG LocalTimePG LocalTime :: PGType = 'PGtimestamp
The preferred way to generate PGs of your own type is through
generalized newtype deriving or via deriving.
>>>newtype UserId = UserId {getUserId :: UUID} deriving newtype IsPG
>>>:kind! PG UserIdPG UserId :: PGType = 'PGuuid
>>>:{data Answer = Yes | No deriving stock GHC.Generic deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) deriving IsPG via Enumerated Answer :}
>>>:kind! PG AnswerPG Answer :: PGType = 'PGenum '["Yes", "No"]
>>>:{data Complex = Complex {real :: Double, imaginary :: Double} deriving stock GHC.Generic deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) deriving IsPG via Composite Complex :}
>>>:kind! PG ComplexPG Complex :: PGType = 'PGcomposite '["real" ::: 'NotNull 'PGfloat8, "imaginary" ::: 'NotNull 'PGfloat8]
Instances
type family LabelsPG hask :: [ConstructorName] where ... #
The LabelsPG type family calculates the constructors of a
Haskell enum type.
>>>data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic>>>instance SOP.Generic Schwarma>>>instance SOP.HasDatatypeInfo Schwarma>>>:kind! LabelsPG SchwarmaLabelsPG Schwarma :: [Type.ConstructorName] = '["Beef", "Lamb", "Chicken"]
Equations
| LabelsPG hask = ConstructorNamesOf (ConstructorsOf (DatatypeInfoOf hask)) |
type family RowPG hask :: RowType where ... #
RowPG turns a Haskell Type into a RowType.
RowPG may be applied to normal Haskell record types provided they
have Generic and HasDatatypeInfo instances;
>>>data Person = Person { name :: Strict.Text, age :: Int32 } deriving GHC.Generic>>>instance SOP.Generic Person>>>instance SOP.HasDatatypeInfo Person>>>:kind! RowPG PersonRowPG Person :: [(Symbol, NullType)] = '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]
Equations
| RowPG hask = RowOf (RecordCodeOf hask) |
type family TuplePG hask :: [NullType] where ... #
TuplePG turns a Haskell tuple type (including record types) into
the corresponding list of NullTypes.
>>>:kind! TuplePG (Double, Maybe Char)TuplePG (Double, Maybe Char) :: [NullType] = '[ 'NotNull 'PGfloat8, 'Null ('PGchar 1)]
Equations
| TuplePG hask = TupleOf (TupleCodeOf hask (Code hask)) |
type family TupleCodeOf hask (code :: [[Type]]) :: [Type] where ... #
TupleCodeOf takes the Code of a haskell Type
and if it's a simple product returns it, otherwise giving a TypeError.
Equations
| TupleCodeOf hask '[tuple] = tuple | |
| TupleCodeOf hask ('[] :: [[Type]]) = TypeError ((('Text "The type `" :<>: 'ShowType hask) :<>: 'Text "' is not a tuple type.") :$$: 'Text "It is a void type with no constructors.") :: [Type] | |
| TupleCodeOf hask (_1 ': (_2 ': _3)) = TypeError ((('Text "The type `" :<>: 'ShowType hask) :<>: 'Text "' is not a tuple type.") :$$: 'Text "It is a sum type with more than one constructor.") :: [Type] |
type family ConstructorsOf (datatype :: DatatypeInfo) :: [ConstructorInfo] where ... #
Calculates constructors of a datatype.
Equations
| ConstructorsOf ('ADT _module _datatype constructors _strictness) = constructors | |
| ConstructorsOf ('Newtype _module _datatype constructor) = '[constructor] |
type family ConstructorNameOf (constructor :: ConstructorInfo) :: ConstructorName where ... #
Calculates the name of a nullary constructor, otherwise generates a type error.
Equations
| ConstructorNameOf ('Constructor name) = name | |
| ConstructorNameOf ('Infix name _assoc _fix) = TypeError ('Text "ConstructorNameOf error: non-nullary constructor " :<>: 'Text name) :: ConstructorName | |
| ConstructorNameOf ('Record name _fields) = TypeError ('Text "ConstructorNameOf error: non-nullary constructor " :<>: 'Text name) :: ConstructorName |
type family ConstructorNamesOf (constructors :: [ConstructorInfo]) :: [ConstructorName] where ... #
Calculate the names of nullary constructors.
Equations
| ConstructorNamesOf ('[] :: [ConstructorInfo]) = '[] :: [ConstructorName] | |
| ConstructorNamesOf (constructor ': constructors) = ConstructorNameOf constructor ': ConstructorNamesOf constructors |
type family DimPG hask :: [Nat] where ... #
DimPG turns Haskell nested homogeneous tuples into a list of lengths,
up to a depth of 10 for each dimension.
Equations
| DimPG (x, x) = 2 ': DimPG x | |
| DimPG (x, x, x) = 3 ': DimPG x | |
| DimPG (x, x, x, x) = 4 ': DimPG x | |
| DimPG (x, x, x, x, x) = 5 ': DimPG x | |
| DimPG (x, x, x, x, x, x) = 6 ': DimPG x | |
| DimPG (x, x, x, x, x, x, x) = 7 ': DimPG x | |
| DimPG (x, x, x, x, x, x, x, x) = 8 ': DimPG x | |
| DimPG (x, x, x, x, x, x, x, x, x) = 9 ': DimPG x | |
| DimPG (x, x, x, x, x, x, x, x, x, x) = 10 ': DimPG x | |
| DimPG x = '[] :: [Nat] |
type family FixPG hask :: NullType where ... #
FixPG extracts NullPG of the base type of nested homogeneous tuples,
up to a depth of 10 for each dimension.
Equations
| FixPG (x, x) = FixPG x | |
| FixPG (x, x, x) = FixPG x | |
| FixPG (x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x, x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x, x, x, x, x, x) = FixPG x | |
| FixPG (x, x, x, x, x, x, x, x, x, x, x) = FixPG x | |
| FixPG x = NullPG x |
PGType is the promoted datakind of PostgreSQL types.
>>>:kind 'PGbool'PGbool :: PGType
Constructors
| PGbool | logical Boolean (true/false) |
| PGint2 | signed two-byte integer |
| PGint4 | signed four-byte integer |
| PGint8 | signed eight-byte integer |
| PGnumeric | arbitrary precision numeric type |
| PGfloat4 | single precision floating-point number (4 bytes) |
| PGfloat8 | double precision floating-point number (8 bytes) |
| PGmoney | currency amount |
| PGchar Nat | fixed-length character string |
| PGvarchar Nat | variable-length character string |
| PGtext | variable-length character string |
| PGbytea | binary data ("byte array") |
| PGtimestamp | date and time (no time zone) |
| PGtimestamptz | date and time, including time zone |
| PGdate | calendar date (year, month, day) |
| PGtime | time of day (no time zone) |
| PGtimetz | time of day, including time zone |
| PGinterval | time span |
| PGuuid | universally unique identifier |
| PGinet | IPv4 or IPv6 host address |
| PGjson | textual JSON data |
| PGjsonb | binary JSON data, decomposed |
| PGvararray NullType | variable length array |
| PGfixarray [Nat] NullType | fixed length array |
| PGenum [Symbol] | enumerated (enum) types are data types that comprise a static, ordered set of values. |
| PGcomposite RowType | a composite type represents the structure of a row or record; it is essentially just a list of field names and their data types. |
| PGtsvector | A tsvector value is a sorted list of distinct lexemes, which are words that have been normalized to merge different variants of the same word. |
| PGtsquery | A tsquery value stores lexemes that are to be searched for. |
| PGoid | Object identifiers (OIDs) are used internally by PostgreSQL as primary keys for various system tables. |
| PGrange PGType | Range types are data types representing a range of values of some element type (called the range's subtype). |
| UnsafePGType Symbol | an escape hatch for unsupported PostgreSQL types |
Instances
NullType encodes the potential presence or definite absence of a
NULL allowing operations which are sensitive to such to be well typed.
>>>:kind 'Null 'PGint4'Null 'PGint4 :: NullType>>>:kind 'NotNull ('PGvarchar 50)'NotNull ('PGvarchar 50) :: NullType
Instances
| Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # | |
| Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # | |
| (Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| FromValue ty (Maybe y) => IsLabel fld (MaybeT (DecodeRow ((fld ::: ty) ': row)) y) | |
| IsLabel fld (MaybeT (DecodeRow row) y) => IsLabel fld (MaybeT (DecodeRow (field ': row)) y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| FromValue ty y => IsLabel fld (DecodeRow ((fld ::: ty) ': row) y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsLabel fld (DecodeRow row y) => IsLabel fld (DecodeRow (field ': row) y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| (HasUnique tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsLabel col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression 'Ungrouped lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsLabel col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression ('Grouped bys) lat with db params from) tys # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column # | |
| (KnownSymbol alias, NullTyped db ty) => FieldTyped db (alias ::: ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods fieldtype :: Aliased (TypeExpression db) (alias ::: ty) # | |
| OidOfNull db ty => OidOfField db (fld ::: ty) | |
Defined in Squeal.PostgreSQL.Session.Oid Methods oidOfField :: ReaderT (K Connection db) IO Oid # | |
| (fld0 ~ fld1, ToParam db ty x) => ToField db (fld0 ::: ty) (fld1 ::: x) | |
| NullTyped db ('Null ty) => ColumnTyped db ('NoDef :=> 'Null ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods columntype :: ColumnTypeExpression db ('NoDef :=> 'Null ty) # | |
| NullTyped db ('NotNull ty) => ColumnTyped db ('NoDef :=> 'NotNull ty) | |
Defined in Squeal.PostgreSQL.Expression.Type Methods columntype :: ColumnTypeExpression db ('NoDef :=> 'NotNull ty) # | |
| (KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 # | |
| JsonBuildObject ('[] :: [NullType]) | |
Defined in Squeal.PostgreSQL.Expression.Json | |
| FilterWhere AggregateArg 'Ungrouped | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition 'Ungrouped lat with db params from -> AggregateArg xs lat with db params from -> AggregateArg xs lat with db params from # | |
| FilterWhere (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) grp | |
Defined in Squeal.PostgreSQL.Expression.Window Methods filterWhere :: forall (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType) (xs :: k). Condition grp lat with db params from -> WindowArg grp xs lat with db params from -> WindowArg grp xs lat with db params from # | |
| Additional (FromClause lat with db params :: FromType -> Type) | |
Defined in Squeal.PostgreSQL.Query.From Methods also :: forall (ys :: [a]) (xs :: [a]). FromClause lat with db params ys -> FromClause lat with db params xs -> FromClause lat with db params (Join xs ys) # | |
| Additional (Selection grp lat with db params from :: RowType -> Type) | |
| (JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject ('NotNull key ': (value ': tys)) | |
Defined in Squeal.PostgreSQL.Expression.Json | |
| (KnownSymbol alias, InlineParam x ty) => InlineField (alias ::: x) (alias ::: ty) | |
Defined in Squeal.PostgreSQL.Expression.Inline Methods inlineField :: forall (grp :: Grouping) (lat :: FromType) (with :: FromType) (db :: SchemasType) (params :: [NullType]) (from :: FromType). P (alias ::: x) -> Aliased (Expression grp lat with db params from) (alias ::: ty) # | |
| (KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: x) (col ::: ('NoDef :=> ty)) | |
Defined in Squeal.PostgreSQL.Expression.Inline | |
| (KnownSymbol col, InlineParam x ty) => InlineColumn (col ::: Optional I ('Def :=> x)) (col ::: ('Def :=> ty)) | |
Defined in Squeal.PostgreSQL.Expression.Inline | |
| (FromValue ty y, fld0 ~ fld1) => FromField (fld0 ::: ty) (fld1 ::: y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> null0 ty0)) (alias1 ::: (def1 :=> null1 ty1)) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| AddColumn ('NoDef :=> 'Null ty) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('NoDef :=> 'Null ty) -> AlterTable sch tab db (constraints :=> Create column ('NoDef :=> 'Null ty) columns) # | |
| AddColumn ('Def :=> ty) | |
Defined in Squeal.PostgreSQL.Definition.Table Methods addColumn :: forall (column :: Symbol) (sch :: Symbol) (db :: [(Symbol, [(Symbol, SchemumType)])]) (schema :: [(Symbol, SchemumType)]) (tab :: Symbol) (constraints :: TableConstraints) (columns :: ColumnsType). (KnownSymbol column, Has sch db schema, Has tab schema ('Table (constraints :=> columns))) => Alias column -> ColumnTypeExpression db ('Def :=> ty) -> AlterTable sch tab db (constraints :=> Create column ('Def :=> ty) columns) # | |
| IsString (Selection grp lat with db params from '["fromOnly" ::: 'NotNull 'PGtext]) | |
Defined in Squeal.PostgreSQL.Query.Select | |
type (:=>) (constraint :: k) (ty :: k1) = '(constraint, ty) infixr 7 #
The constraint operator, :=> is a type level pair
between a "constraint" and some type, for use in pairing
an Optionality with a NullType to produce a ColumnType
or a TableConstraints and a ColumnsType to produce a TableType.
data Optionality #
Optionality encodes the availability of DEFAULT for inserts and updates.
A column can be assigned a default value.
A data Manipulation command can also
request explicitly that a column be set to its default value,
without having to know what that value is.
Constructors
| Def |
|
| NoDef |
|
Instances
type ColumnType = (Optionality, NullType) #
ColumnType encodes the allowance of DEFAULT and NULL and the
base PGType for a column.
>>>:set -XTypeFamilies -XTypeInType>>>import GHC.TypeLits>>>type family IdColumn :: ColumnType where IdColumn = 'Def :=> 'NotNull 'PGint4>>>type family EmailColumn :: ColumnType where EmailColumn = 'NoDef :=> 'Null 'PGtext
type ColumnsType = [(Symbol, ColumnType)] #
ColumnsType is a row of ColumnTypes.
>>>:{type family UsersColumns :: ColumnsType where UsersColumns = '[ "name" ::: 'NoDef :=> 'NotNull 'PGtext , "id" ::: 'Def :=> 'NotNull 'PGint4 ] :}
data TableConstraint #
TableConstraint encodes various forms of data constraints
of columns in a table.
TableConstraints give you as much control over the data in your tables
as you wish. If a user attempts to store data in a column that would
violate a constraint, an error is raised. This applies
even if the value came from the default value definition.
type TableConstraints = [(Symbol, TableConstraint)] #
A TableConstraints is a row of TableConstraints.
>>>:{type family UsersConstraints :: TableConstraints where UsersConstraints = '[ "pk_users" ::: 'PrimaryKey '["id"] ] :}
type family Uniquely (key :: [Symbol]) (constraints :: TableConstraints) where ... #
A ForeignKey must reference columns that either are
a PrimaryKey or form a Unique constraint.
type TableType = (TableConstraints, ColumnsType) #
TableType encodes a row of constraints on a table as well as the types
of its columns.
>>>:{type family UsersTable :: TableType where UsersTable = '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4 , "name" ::: 'NoDef :=> 'NotNull 'PGtext ] :}
type FromType = [(Symbol, RowType)] #
FromType is a row of RowTypes. It can be thought of as
a product, or horizontal gluing and is used in FromClauses
and TableExpressions.
type family ColumnsToRow (columns :: ColumnsType) :: RowType where ... #
ColumnsToRow removes column constraints.
Equations
| ColumnsToRow ((column ::: (_1 :=> ty)) ': columns) = (column ::: ty) ': ColumnsToRow columns | |
| ColumnsToRow ('[] :: [(Symbol, ColumnType)]) = '[] :: [(Symbol, NullType)] |
type family TableToColumns (table :: TableType) :: ColumnsType where ... #
TableToColumns removes table constraints.
Equations
| TableToColumns (constraints :=> columns) = columns |
type family TableToRow (table :: TableType) :: RowType where ... #
Convert a table to a row type.
Equations
| TableToRow tab = ColumnsToRow (TableToColumns tab) |
type PGNum = '['PGint2, 'PGint4, 'PGint8, 'PGnumeric, 'PGfloat4, 'PGfloat8] #
Numeric Postgres types.
type PGFloating = '['PGfloat4, 'PGfloat8, 'PGnumeric] #
Floating Postgres types.
type PGIntegral = '['PGint2, 'PGint4, 'PGint8] #
Integral Postgres types.
class SamePGType (ty0 :: (Symbol, ColumnType)) (ty1 :: (Symbol, ColumnType)) #
Equality constraint on the underlying PGType of two columns.
Instances
| ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> null0 ty0)) (alias1 ::: (def1 :=> null1 ty1)) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
type family AllNotNull (columns :: ColumnsType) where ... #
AllNotNull is a constraint that proves a ColumnsType has no NULLs.
Equations
| AllNotNull ((_1 ::: (_2 :=> 'NotNull _3)) ': columns) = AllNotNull columns | |
| AllNotNull ('[] :: [(Symbol, ColumnType)]) = () |
type family NotAllNull (columns :: ColumnsType) where ... #
NotAllNull is a constraint that proves a ColumnsType has some
NOT NULL.
Equations
| NotAllNull ((_1 ::: (_2 :=> 'NotNull _3)) ': _4) = () | |
| NotAllNull ((_1 ::: (_2 :=> 'Null _3)) ': columns) = NotAllNull columns |
type family NullifyType (ty :: NullType) :: NullType where ... #
NullifyType is an idempotent that nullifies a NullType.
Equations
| NullifyType (null ty) = 'Null ty |
type family NullifyRow (columns :: RowType) :: RowType where ... #
NullifyRow is an idempotent that nullifies a RowType.
Equations
| NullifyRow ((column ::: ty) ': columns) = (column ::: NullifyType ty) ': NullifyRow columns | |
| NullifyRow ('[] :: [(Symbol, NullType)]) = '[] :: [(Symbol, NullType)] |
type family NullifyFrom (tables :: FromType) :: FromType where ... #
NullifyFrom is an idempotent that nullifies a FromType
used to nullify the left or right hand side of an outer join
in a FromClause.
Equations
| NullifyFrom ((table ::: columns) ': tables) = (table ::: NullifyRow columns) ': NullifyFrom tables | |
| NullifyFrom ('[] :: [(Symbol, RowType)]) = '[] :: [(Symbol, RowType)] |
type family Create (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Create alias x xs adds alias ::: x to the end of xs and is used in
createTable statements and in ALTER TABLE
addColumn.
Equations
| Create alias (x :: k) ('[] :: [(Symbol, k)]) = '[alias ::: x] | |
| Create alias (x :: k) ((alias ::: y) ': xs :: [(Symbol, k)]) = TypeError (('Text "Create: alias " :<>: 'ShowType alias) :<>: 'Text "already exists") :: [(Symbol, k)] | |
| Create alias (y :: k) (x ': xs :: [(Symbol, k)]) = x ': Create alias y xs |
type family CreateIfNotExists (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Similar to Create but no error on pre-existence
Equations
| CreateIfNotExists alias (x :: k) ('[] :: [(Symbol, k)]) = '[alias ::: x] | |
| CreateIfNotExists alias (x :: k) ((alias ::: y) ': xs :: [(Symbol, k)]) = (alias ::: y) ': xs | |
| CreateIfNotExists alias (y :: k) (x ': xs :: [(Symbol, k)]) = x ': CreateIfNotExists alias y xs |
type family CreateOrReplace (alias :: Symbol) (x :: t) (xs :: [(Symbol, t)]) :: [(Symbol, t)] where ... #
Similar to Create but used to replace values
with the same type.
Equations
| CreateOrReplace alias (x :: k) ('[] :: [(Symbol, k)]) = '[alias ::: x] | |
| CreateOrReplace alias (x :: k) ((alias ::: x) ': xs :: [(Symbol, k)]) = (alias ::: x) ': xs | |
| CreateOrReplace alias (x :: t) ((alias ::: y) ': xs :: [(Symbol, t)]) = TypeError ((((('Text "CreateOrReplace: expected type " :<>: 'ShowType x) :<>: 'Text " but alias ") :<>: 'ShowType alias) :<>: 'Text " has type ") :<>: 'ShowType y) :: [(Symbol, t)] | |
| CreateOrReplace alias (y :: t) (x ': xs :: [(Symbol, t)]) = x ': CreateOrReplace alias y xs |
type family Drop (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Drop alias xs removes the type associated with alias in xs
and is used in dropTable statements
and in ALTER TABLE dropColumn statements.
type family DropSchemum (alias :: Symbol) (sch :: k1 -> k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Drop a particular flavor of schemum type
Equations
| DropSchemum alias (sch :: k1 -> k2) ('[] :: [(Symbol, k2)]) = TypeError (('Text "DropSchemum: alias " :<>: 'ShowType alias) :<>: 'Text " does not exist") :: [(Symbol, k2)] | |
| DropSchemum alias (sch :: k1 -> k2) ((alias ::: sch x) ': xs :: [(Symbol, k2)]) = xs | |
| DropSchemum alias (sch0 :: k1 -> k2) ((alias ::: sch1 x) ': xs :: [(Symbol, k2)]) = TypeError ((((('Text "DropSchemum: expected schemum " :<>: 'ShowType sch0) :<>: 'Text " but alias ") :<>: 'ShowType alias) :<>: 'Text " has schemum ") :<>: 'ShowType sch1) :: [(Symbol, k2)] | |
| DropSchemum alias (sch :: k1 -> k2) (x ': xs :: [(Symbol, k2)]) = x ': DropSchemum alias sch xs |
type family DropIfExists (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Similar to Drop but no error on non-existence
Equations
| DropIfExists alias ('[] :: [(Symbol, k)]) = '[] :: [(Symbol, k)] | |
| DropIfExists alias ((alias ::: x) ': xs :: [(Symbol, k)]) = xs | |
| DropIfExists alias (x ': xs :: [(Symbol, k)]) = x ': DropIfExists alias xs |
type family DropSchemumIfExists (alias :: Symbol) (sch :: k1 -> k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Similar to DropSchemum but no error on non-existence
Equations
| DropSchemumIfExists alias (sch :: k1 -> k2) ('[] :: [(Symbol, k2)]) = '[] :: [(Symbol, k2)] | |
| DropSchemumIfExists alias (sch :: k1 -> k2) ((alias ::: sch x) ': xs :: [(Symbol, k2)]) = xs | |
| DropSchemumIfExists alias (sch0 :: k1 -> k2) ((alias ::: sch1 x) ': xs :: [(Symbol, k2)]) = TypeError ((((('Text "DropSchemumIfExists: expected schemum " :<>: 'ShowType sch1) :<>: 'Text " but alias ") :<>: 'ShowType alias) :<>: 'Text " has schemum ") :<>: 'ShowType sch0) :: [(Symbol, k2)] | |
| DropSchemumIfExists alias (sch :: k1 -> k2) (x ': xs :: [(Symbol, k2)]) = x ': DropSchemumIfExists alias sch xs |
type family Alter (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Alter alias x xs replaces the type associated with an alias in xs
with the type x and is used in alterTable
and alterColumn.
Equations
| Alter alias (x :: k) ('[] :: [(Symbol, k)]) = TypeError (('Text "Alter: alias " :<>: 'ShowType alias) :<>: 'Text " does not exist") :: [(Symbol, k)] | |
| Alter alias (x1 :: k) ((alias ::: x0) ': xs :: [(Symbol, k)]) = (alias ::: x1) ': xs | |
| Alter alias (x1 :: k) (x0 ': xs :: [(Symbol, k)]) = x0 ': Alter alias x1 xs |
type family AlterIfExists (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Similar to Alter but no error on non-existence
Equations
| AlterIfExists alias (x :: k) ('[] :: [(Symbol, k)]) = '[] :: [(Symbol, k)] | |
| AlterIfExists alias (x1 :: k) ((alias ::: x0) ': xs :: [(Symbol, k)]) = (alias ::: x1) ': xs | |
| AlterIfExists alias (x1 :: k) (x0 ': xs :: [(Symbol, k)]) = x0 ': AlterIfExists alias x1 xs |
type family Rename (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Rename alias0 alias1 xs replaces the alias alias0 by alias1 in xs
and is used in alterTableRename and
renameColumn.
Equations
| Rename alias0 alias1 ('[] :: [(Symbol, k)]) = TypeError (('Text "Rename: alias " :<>: 'ShowType alias0) :<>: 'Text " does not exist") :: [(Symbol, k)] | |
| Rename alias0 alias1 ((alias0 ::: x0) ': xs :: [(Symbol, k)]) = (alias1 ::: x0) ': xs | |
| Rename alias0 alias1 (x ': xs :: [(Symbol, k)]) = x ': Rename alias0 alias1 xs |
type family RenameIfExists (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #
Similar to Rename but no error on non-existence
Equations
| RenameIfExists alias x ('[] :: [(Symbol, k)]) = '[] :: [(Symbol, k)] | |
| RenameIfExists alias0 alias1 ((alias0 ::: x0) ': xs :: [(Symbol, k)]) = (alias1 ::: x0) ': xs | |
| RenameIfExists alias0 alias1 (x ': xs :: [(Symbol, k)]) = x ': RenameIfExists alias0 alias1 xs |
type family SetSchema (sch0 :: Symbol) (sch1 :: Symbol) (schema0 :: [(Symbol, k)]) (schema1 :: [(Symbol, k)]) (obj :: Symbol) (srt :: k1 -> k) (ty :: k1) (db :: [(Symbol, [(Symbol, k)])]) :: [(Symbol, [(Symbol, k)])] where ... #
Move an object from one schema to another
type family ConstraintInvolves (column :: Symbol) (constraint :: TableConstraint) :: Bool where ... #
Check if a TableConstraint involves a column
Equations
| ConstraintInvolves column ('Check columns) = Elem column columns | |
| ConstraintInvolves column ('Unique columns) = Elem column columns | |
| ConstraintInvolves column ('PrimaryKey columns) = Elem column columns | |
| ConstraintInvolves column ('ForeignKey columns sch tab refcolumns) = Elem column columns |
type family DropIfConstraintsInvolve (column :: Symbol) (constraints :: [(Symbol, TableConstraint)]) :: [(Symbol, TableConstraint)] where ... #
Drop all TableConstraints that involve a column
Equations
| DropIfConstraintsInvolve column ('[] :: [(Symbol, TableConstraint)]) = '[] :: [(Symbol, TableConstraint)] | |
| DropIfConstraintsInvolve column ((alias ::: constraint) ': constraints) = If (ConstraintInvolves column constraint) (DropIfConstraintsInvolve column constraints) ((alias ::: constraint) ': DropIfConstraintsInvolve column constraints) |
data SchemumType #
A SchemumType is a user-created type, like a Table,
View or Typedef.
Constructors
| Table TableType | |
| View RowType | |
| Typedef PGType | |
| Index IndexType | |
| Function FunctionType | |
| Procedure [NullType] | |
| UnsafeSchemum Symbol |
Instances
| Category Definition | |
Defined in Squeal.PostgreSQL.Definition Methods id :: forall (a :: k). Definition a a # (.) :: forall (b :: k) (c :: k) (a :: k). Definition b c -> Definition a b -> Definition a c # | |
| IndexedMonadTrans PQ | |
Defined in Squeal.PostgreSQL.Session Methods pqAp :: forall (m :: Type -> Type) (i :: k) (j :: k) x y (k1 :: k). Monad m => PQ i j m (x -> y) -> PQ j k1 m x -> PQ i k1 m y # pqJoin :: forall (m :: Type -> Type) (i :: k) (j :: k) (k1 :: k) y. Monad m => PQ i j m (PQ j k1 m y) -> PQ i k1 m y # pqBind :: forall (m :: Type -> Type) x (j :: k) (k1 :: k) y (i :: k). Monad m => (x -> PQ j k1 m y) -> PQ i j m x -> PQ i k1 m y # pqThen :: forall (m :: Type -> Type) (j :: k) (k1 :: k) y (i :: k) x. Monad m => PQ j k1 m y -> PQ i j m x -> PQ i k1 m y # pqAndThen :: forall (m :: Type -> Type) y (j :: k) (k1 :: k) z x (i :: k). Monad m => (y -> PQ j k1 m z) -> (x -> PQ i j m y) -> x -> PQ i k1 m z # | |
| Aggregate AggregateArg (Expression ('Grouped bys) :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => AggregateArg '[null int] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGbool] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). AggregateArg '[null ty] lat with db params from -> Expression ('Grouped bys) lat with db params from ('Null (PGAvg ty)) # | |
| Aggregate (WindowArg grp :: [NullType] -> FromType -> FromType -> SchemasType -> [NullType] -> FromType -> Type) (WindowFunction grp :: FromType -> FromType -> SchemasType -> [NullType] -> FromType -> NullType -> Type) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: forall (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowFunction grp lat with db params from ('NotNull 'PGint8) # count :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('NotNull 'PGint8) # sum_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGSum ty)) # arrayAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ('PGvararray ty)) # jsonAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjson) # jsonbAgg :: forall (ty :: NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[ty] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGjsonb) # bitAnd :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # bitOr :: forall (int :: PGType) (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). In int PGIntegral => WindowArg grp '[null int] lat with db params from -> WindowFunction grp lat with db params from ('Null int) # boolAnd :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # boolOr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # every :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGbool] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGbool) # max_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # min_ :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null ty) # avg :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # corr :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarPop :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # covarSamp :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgX :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrAvgY :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrCount :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGint8) # regrIntercept :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrR2 :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSlope :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxx :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSxy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # regrSyy :: forall (null :: PGType -> NullType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null 'PGfloat8, null 'PGfloat8] lat with db params from -> WindowFunction grp lat with db params from ('Null 'PGfloat8) # stddev :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # stddevSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # variance :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varPop :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # varSamp :: forall (null :: PGType -> NullType) (ty :: PGType) (lat :: k) (with :: k1) (db :: k2) (params :: k3) (from :: k4). WindowArg grp '[null ty] lat with db params from -> WindowFunction grp lat with db params from ('Null (PGAvg ty)) # | |
| Migratory Definition (Indexed PQ IO ()) | pure migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration Definition) db0 db1 -> Indexed PQ IO () db0 db1 # | |
| Migratory (IsoQ (Indexed PQ IO ())) (IsoQ (Indexed PQ IO ())) | impure rewindable migrations |
| Migratory (IsoQ Definition) (IsoQ (Indexed PQ IO ())) | pure rewindable migrations |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (IsoQ Definition)) db0 db1 -> IsoQ (Indexed PQ IO ()) db0 db1 # | |
| Migratory (OpQ (Indexed PQ IO ())) (OpQ (Indexed PQ IO ())) | impure rewinds |
| Migratory (OpQ Definition) (OpQ (Indexed PQ IO ())) | pure rewinds |
Defined in Squeal.PostgreSQL.Session.Migration Methods runMigrations :: forall (db0 :: k) (db1 :: k). Path (Migration (OpQ Definition)) db0 db1 -> OpQ (Indexed PQ IO ()) db0 db1 # | |
| Migratory (Indexed PQ IO ()) (Indexed PQ IO ()) | impure migrations |
type FunctionType = ([NullType], ReturnsType) #
Use :=> to pair the parameter types with the return
type of a function.
>>>:{type family Fn :: FunctionType where Fn = '[ 'NotNull 'PGint4] :=> 'Returns ('NotNull 'PGint4) :}
PostgreSQL provides several index types: B-tree, Hash, GiST, SP-GiST, GIN and BRIN. Each index type uses a different algorithm that is best suited to different types of queries.
Constructors
| Btree | B-trees can handle equality and range queries on data that can be sorted into some ordering. |
| Hash | Hash indexes can only handle simple equality comparisons. |
| Gist | GiST indexes are not a single kind of index, but rather an infrastructure within which many different indexing strategies can be implemented. |
| Spgist | SP-GiST indexes, like GiST indexes, offer an infrastructure that supports various kinds of searches. |
| Gin | GIN indexes are “inverted indexes” which are appropriate for data values that contain multiple component values, such as arrays. |
| Brin | BRIN indexes (a shorthand for Block Range INdexes) store summaries about the values stored in consecutive physical block ranges of a table. |
data ReturnsType #
Return type of a function
Constructors
| Returns NullType | function |
| ReturnsTable RowType | set returning function |
type SchemaType = [(Symbol, SchemumType)] #
A schema of a database consists of a list of aliased,
user-defined SchemumTypes.
>>>:{type family Schema :: SchemaType where Schema = '[ "users" ::: 'Table ( '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4 , "name" ::: 'NoDef :=> 'NotNull 'PGtext ]) , "emails" ::: 'Table ( '[ "pk_emails" ::: 'PrimaryKey '["id"] , "fk_user_id" ::: 'ForeignKey '["user_id"] "public" "users" '["id"] ] :=> '[ "id" ::: 'Def :=> 'NotNull 'PGint4 , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4 , "email" ::: 'NoDef :=> 'Null 'PGtext ]) ] :}
type SchemasType = [(Symbol, SchemaType)] #
A database contains one or more named schemas, which in turn contain tables. The same object name can be used in different schemas without conflict; for example, both schema1 and myschema can contain tables named mytable. Unlike databases, schemas are not rigidly separated: a user can access objects in any of the schemas in the database they are connected to, if they have privileges to do so.
There are several reasons why one might want to use schemas:
- To allow many users to use one database without interfering with each other.
- To organize database objects into logical groups to make them more manageable.
- Third-party applications can be put into separate schemas so they do not collide with the names of other objects.
type family Public (schema :: SchemaType) :: SchemasType where ... #
A type family to use for a single schema database.
class IsPGlabel (label :: Symbol) expr where #
IsPGlabel looks very much like the IsLabel class. Whereas
the overloaded label, fromLabel is used for column references,
labels are used for enum terms. A label is called with
type application like label @"beef".
Instances
| label ~ label1 => IsPGlabel label (PGlabel label1) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| IsPGlabel label (y -> K y label) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| IsPGlabel label (y -> NP (K y :: Symbol -> Type) '[label]) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| labels ~ '[label] => IsPGlabel label (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| (KnownSymbol label, In label labels) => IsPGlabel label (Expression grp lat with db params from (null ('PGenum labels))) | |
Defined in Squeal.PostgreSQL.Expression Methods label :: Expression grp lat with db params from (null ('PGenum labels)) # | |
data PGlabel (label :: Symbol) #
Constructors
| PGlabel |
Instances
| label ~ label1 => IsPGlabel label (PGlabel label1) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| labels ~ '[label] => IsPGlabel label (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| KnownSymbol label => RenderSQL (PGlabel label) | |
Defined in Squeal.PostgreSQL.Type.Schema Methods renderSQL :: PGlabel label -> ByteString # | |
| All KnownSymbol labels => RenderSQL (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Type.Schema Methods renderSQL :: NP PGlabel labels -> ByteString # | |
type PGJsonType = '['PGjson, 'PGjsonb] #
Is a type a valid JSON type?
class IsNotElem (x :: k) (isElem :: k1) #
Utility class for AllUnique to provide nicer error messages.
Instances
| IsNotElem (x :: k) 'False | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| (TypeError (('Text "Cannot assign to " :<>: 'ShowType alias) :<>: 'Text " more than once") :: Constraint) => IsNotElem ('(alias, a) :: (k1, k2)) 'True | |
Defined in Squeal.PostgreSQL.Type.Schema | |
class AllUnique (xs :: [(Symbol, a)]) #
No elem of xs appears more than once, in the context of assignment.
Instances
| AllUnique ('[] :: [(Symbol, a)]) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
| (IsNotElem x (Elem x xs), AllUnique xs) => AllUnique (x ': xs :: [(Symbol, a)]) | |
Defined in Squeal.PostgreSQL.Type.Schema | |
type Updatable (table :: TableType) (columns :: [(Symbol, a)]) = (All (HasIn (TableToColumns table) :: (Symbol, a) -> Constraint) columns, AllUnique columns, SListI (TableToColumns table)) #
Updatable lists of columns
type family UserTypeName (schema :: SchemaType) (ty :: PGType) :: Maybe Symbol where ... #
Calculate the name of a user defined type.
Equations
| UserTypeName ('[] :: [(Symbol, SchemumType)]) ty = 'Nothing :: Maybe Symbol | |
| UserTypeName ((td ::: 'Typedef ty) ': _1) ty = 'Just td | |
| UserTypeName (_1 ': schema) ty = UserTypeName schema ty |
type family UserTypeNamespace (sch :: Symbol) (td :: Maybe Symbol) (schemas :: SchemasType) (ty :: PGType) :: (Symbol, Symbol) where ... #
Helper to calculate the schema of a user defined type.
Equations
| UserTypeNamespace sch ('Nothing :: Maybe Symbol) schemas ty = UserType schemas ty | |
| UserTypeNamespace sch ('Just td) schemas ty = '(sch, td) |
type family UserType (db :: SchemasType) (ty :: PGType) :: (Symbol, Symbol) where ... #
Calculate the schema and name of a user defined type.
Equations
| UserType ('[] :: [(Symbol, SchemaType)]) ty = TypeError ('Text "No such user type: " :<>: 'ShowType ty) :: (Symbol, Symbol) | |
| UserType ((sch ::: schema) ': schemas) ty = UserTypeNamespace sch (UserTypeName schema ty) schemas ty |
mapAliased :: forall k expr (x :: k) (y :: k) (alias :: Symbol). (expr x -> expr y) -> Aliased expr (alias ::: x) -> Aliased expr (alias ::: y) #
Map a function over an Aliased expression.
renderAliased :: forall k expression (aliased :: (Symbol, k)). (forall (ty :: k). expression ty -> ByteString) -> Aliased expression aliased -> ByteString #
>>>let renderMaybe = fromString . maybe "Nothing" (const "Just")>>>renderAliased renderMaybe (Just (3::Int) `As` #an_int)"Just AS \"an_int\""
class (KnownSymbol table, KnownSymbol column) => GroupedBy (table :: Symbol) (column :: Symbol) (bys :: k) #
A GroupedBy constraint indicates that a table qualified column is
a member of the auxiliary namespace created by GROUP BY clauses and thus,
may be called in an output Expression without aggregating.
Instances
| (KnownSymbol table, KnownSymbol column) => GroupedBy table column ('(table, column) ': bys :: [(Symbol, Symbol)]) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (KnownSymbol table, KnownSymbol column, GroupedBy table column bys) => GroupedBy table column (tabcol ': bys :: [a]) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
data Alias (alias :: Symbol) #
Aliases are proxies for a type level string or Symbol
and have an IsLabel instance so that with -XOverloadedLabels
>>>:set -XOverloadedLabels>>>#foobar :: Alias "foobar"Alias
Constructors
| Alias |
Instances
| IsQualified qualifier alias (Alias qualifier, Alias alias) | |
| alias1 ~ alias2 => IsLabel alias1 (Alias alias2) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| aliases ~ '[alias] => IsLabel alias (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) | |
| Eq (Alias alias) | |
| Ord (Alias alias) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| Show (Alias alias) | |
| Generic (Alias alias) | |
| NFData (Alias alias) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| KnownSymbol alias => RenderSQL (Alias alias) |
|
Defined in Squeal.PostgreSQL.Type.Alias Methods renderSQL :: Alias alias -> ByteString # | |
| All KnownSymbol aliases => RenderSQL (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods renderSQL :: NP Alias aliases -> ByteString # | |
| type Rep (Alias alias) | |
data Aliased (expression :: k -> Type) (aliased :: (Symbol, k)) where #
The As operator is used to name an expression. As is like a demoted
version of :::.
>>>Just "hello" `As` #hi :: Aliased Maybe ("hi" ::: String)As (Just "hello") Alias
Constructors
| As :: forall k (alias :: Symbol) (expression :: k -> Type) (ty :: k). KnownSymbol alias => expression ty -> Alias alias -> Aliased expression '(alias, ty) |
Instances
| (Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (KnownSymbol alias, tys ~ '[alias ::: ty]) => Aliasable alias (expression ty) (NP (Aliased expression) tys) | |
| (KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (HasUnique tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsLabel col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression 'Ungrouped lat with db params from) column # | |
| (HasUnique tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression ('Grouped bys) lat with db params from) column # | |
| (alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) | |
| (q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) # | |
| Eq (expression ty) => Eq (Aliased expression (alias ::: ty)) | |
| Ord (expression ty) => Ord (Aliased expression (alias ::: ty)) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods compare :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Ordering # (<) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool # (<=) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool # (>) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool # (>=) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool # max :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) # min :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) # | |
| Show (expression ty) => Show (Aliased expression (alias ::: ty)) | |
class KnownSymbol alias => Aliasable (alias :: Symbol) expression aliased | aliased -> expression, aliased -> alias where #
Instances
| (KnownSymbol alias, tys ~ '[alias ::: ty]) => Aliasable alias (expression ty) (NP (Aliased expression) tys) | |
| (KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (Path (CommonTableExpression statement db params) with with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods as :: statement with db params common -> Alias cte -> Path (CommonTableExpression statement db params) with with1 # | |
| (KnownSymbol cte, with1 ~ ((cte ::: common) ': with)) => Aliasable cte (statement with db params common) (CommonTableExpression statement db params with with1) | |
Defined in Squeal.PostgreSQL.Query.With Methods as :: statement with db params common -> Alias cte -> CommonTableExpression statement db params with with1 # | |
| (KnownSymbol col, row ~ '[col ::: ty]) => Aliasable col (Expression grp lat with db params from ty) (Selection grp lat with db params from row) | |
Defined in Squeal.PostgreSQL.Query.Select Methods as :: Expression grp lat with db params from ty -> Alias col -> Selection grp lat with db params from row # | |
type HasUnique (alias :: Symbol) (fields :: [(Symbol, k)]) (field :: k) = fields ~ '[alias ::: field] #
HasUnique alias fields field is a constraint that proves that
fields is a singleton of alias ::: field.
type Has (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) = HasErr fields alias fields field #
Has alias fields field is a constraint that proves that
fields has a field of alias ::: field, inferring field
from alias and fields.
class KnownSymbol alias => HasErr (err :: k) (alias :: Symbol) (fields :: [(Symbol, kind)]) (field :: kind) | alias fields -> field #
HasErr is like Has except it also retains the original
list of fields being searched, so that error messages are more
useful.
Instances
| (KnownSymbol alias, field0 ~ field1) => HasErr (err :: k) alias ((alias ::: field0) ': fields :: [(Symbol, kind)]) (field1 :: kind) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (KnownSymbol alias, HasErr err alias fields field) => HasErr (err :: k) alias (field' ': fields :: [(Symbol, kind)]) (field :: kind) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
class HasIn (fields :: k) (field :: k1) #
HasIn fields (alias ::: field) is a constraint that proves that
fields has a field of alias ::: field. It is used in UPDATEs to
choose which subfields to update.
class All KnownSymbol aliases => HasAll (aliases :: [Symbol]) (fields :: [(Symbol, kind)]) (subfields :: [(Symbol, kind)]) | aliases fields -> subfields #
Instances
| HasAll ('[] :: [Symbol]) (fields :: [(Symbol, kind)]) ('[] :: [(Symbol, kind)]) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (Has alias fields field, HasAll aliases fields subfields) => HasAll (alias ': aliases) (fields :: [(Symbol, k)]) ((alias ::: field) ': subfields :: [(Symbol, k)]) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
class IsQualified (qualifier :: Symbol) (alias :: Symbol) expression where #
Analagous to IsLabel, the constraint
IsQualified defines ! for a column alias qualified
by a table alias.
Instances
| (Has rel rels cols, Has col cols ty, by ~ '(rel, col)) => IsQualified rel col (By rels by) | |
| IsQualified qualifier alias (Alias qualifier, Alias alias) | |
| (q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.Type.Alias Methods (!) :: Alias q -> Alias a -> QualifiedAlias q' a' # | |
| (Has rel rels cols, Has col cols ty, bys ~ '['(rel, col)]) => IsQualified rel col (NP (By rels) bys) | |
| (Has tab (Join from lat) row, Has col row ty, tys ~ '[ty]) => IsQualified tab col (NP (Expression 'Ungrouped lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression 'Ungrouped lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, tys ~ '[ty]) => IsQualified tab col (NP (Expression ('Grouped bys) lat with db params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, columns ~ '[col ::: ty]) => IsQualified tab col (NP (Aliased (Expression ('Grouped bys) lat with db params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression 'Ungrouped lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression ('Grouped bys) lat with db params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty]) => IsQualified tab col (Selection 'Ungrouped lat with db params from row1) | |
| (Has tab (Join from lat) row0, Has col row0 ty, row1 ~ '[col ::: ty], GroupedBy tab col bys) => IsQualified tab col (Selection ('Grouped bys) lat with db params from row1) | |
| (Has tab (Join from lat) row, Has col row ty) => IsQualified tab col (Expression 'Ungrouped lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join from lat) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (Expression ('Grouped bys) lat with db params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
data QualifiedAlias (qualifier :: Symbol) (alias :: Symbol) #
QualifiedAliases enables multi-schema support by allowing a reference
to a Table, Typedef
or View to be qualified by their schemas. By default,
a qualifier of public is provided.
>>>:{let alias1 :: QualifiedAlias "sch" "tab" alias1 = #sch ! #tab alias2 :: QualifiedAlias "public" "vw" alias2 = #vw in printSQL alias1 >> printSQL alias2 :} "sch"."tab" "vw"
Constructors
| QualifiedAlias |
Instances
| (q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.Type.Alias Methods (!) :: Alias q -> Alias a -> QualifiedAlias q' a' # | |
| (q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) | |
Defined in Squeal.PostgreSQL.Type.Alias | |
| (q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.Type.Alias Methods fromLabel :: QualifiedAlias q' a' # | |
| (q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) # | |
| Eq (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods (==) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # (/=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # | |
| Ord (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods compare :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Ordering # (<) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # (<=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # (>) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # (>=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # max :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias # min :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias # | |
| Show (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods showsPrec :: Int -> QualifiedAlias qualifier alias -> ShowS # show :: QualifiedAlias qualifier alias -> String # showList :: [QualifiedAlias qualifier alias] -> ShowS # | |
| Generic (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.Type.Alias Associated Types type Rep (QualifiedAlias qualifier alias) :: Type -> Type # Methods from :: QualifiedAlias qualifier alias -> Rep (QualifiedAlias qualifier alias) x # to :: Rep (QualifiedAlias qualifier alias) x -> QualifiedAlias qualifier alias # | |
| NFData (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods rnf :: QualifiedAlias qualifier alias -> () # | |
| (KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) | |
Defined in Squeal.PostgreSQL.Type.Alias Methods renderSQL :: QualifiedAlias q a -> ByteString # | |
| type Rep (QualifiedAlias qualifier alias) | |
disjoin :: forall k (xs :: [k]) (ys :: [k]) (expr :: k -> Type). SListI xs => NP expr (Join xs ys) -> (NP expr xs, NP expr ys) #
type family Join (xs :: [a]) (ys :: [a]) :: [a] where ... #
Join is simply promoted ++ and is used in JOINs in
FromClauses.
class Additional (expr :: [a] -> Type) where #
The Additional class is for appending
type-level list parameterized constructors such as NP,
Selection, and FromClause.
Instances
| Additional (NP expr :: [a] -> Type) | |
| Additional (FromClause lat with db params :: FromType -> Type) | |
Defined in Squeal.PostgreSQL.Query.From Methods also :: forall (ys :: [a]) (xs :: [a]). FromClause lat with db params ys -> FromClause lat with db params xs -> FromClause lat with db params (Join xs ys) # | |
| Additional (Selection grp lat with db params from :: RowType -> Type) | |
type family Length (xs :: [k]) :: Nat where ... #
Calculate the Length of a type level list
>>>:kind! Length '[Char,String,Bool,Double]Length '[Char,String,Bool,Double] :: Nat = 4
The Money newtype stores a monetary value in terms
of the number of cents, i.e. $2,000.20 would be expressed as
Money { cents = 200020 }.
>>>:kind! PG MoneyPG Money :: PGType = 'PGmoney
Instances
| Eq Money | |
| Ord Money | |
| Read Money | |
| Show Money | |
| Generic Money | |
| Generic Money | |
| HasDatatypeInfo Money | |
Defined in Squeal.PostgreSQL.Type Associated Types type DatatypeInfoOf Money :: DatatypeInfo # Methods datatypeInfo :: proxy Money -> DatatypeInfo (Code Money) # | |
| Inline Money | |
| FromPG Money | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG Money | |
Defined in Squeal.PostgreSQL.Type.PG | |
| ToPG db Money | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| type Rep Money | |
Defined in Squeal.PostgreSQL.Type | |
| type Code Money | |
Defined in Squeal.PostgreSQL.Type | |
| type DatatypeInfoOf Money | |
Defined in Squeal.PostgreSQL.Type | |
| type PG Money | |
Defined in Squeal.PostgreSQL.Type.PG | |
The Json newtype is an indication that the Haskell
type it's applied to should be stored as a
PGjson.
>>>:kind! PG (Json [String])PG (Json [String]) :: PGType = 'PGjson
Instances
| ToJSON x => ToPG db (Json x) | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| Eq hask => Eq (Json hask) | |
| Ord hask => Ord (Json hask) | |
| Read hask => Read (Json hask) | |
| Show hask => Show (Json hask) | |
| Generic (Json hask) | |
| Generic (Json hask) | |
| HasDatatypeInfo (Json hask) | |
Defined in Squeal.PostgreSQL.Type Associated Types type DatatypeInfoOf (Json hask) :: DatatypeInfo # Methods datatypeInfo :: proxy (Json hask) -> DatatypeInfo (Code (Json hask)) # | |
| ToJSON x => Inline (Json x) | |
| FromJSON x => FromPG (Json x) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG (Json hask) | |
Defined in Squeal.PostgreSQL.Type.PG | |
| type Rep (Json hask) | |
Defined in Squeal.PostgreSQL.Type | |
| type Code (Json hask) | |
Defined in Squeal.PostgreSQL.Type | |
| type DatatypeInfoOf (Json hask) | |
Defined in Squeal.PostgreSQL.Type | |
| type PG (Json hask) | |
Defined in Squeal.PostgreSQL.Type.PG | |
The Jsonb newtype is an indication that the Haskell
type it's applied to should be stored as a
PGjsonb.
>>>:kind! PG (Jsonb [String])PG (Jsonb [String]) :: PGType = 'PGjsonb
Instances
| ToJSON x => ToPG db (Jsonb x) | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| Eq hask => Eq (Jsonb hask) | |
| Ord hask => Ord (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type | |
| Read hask => Read (Jsonb hask) | |
| Show hask => Show (Jsonb hask) | |
| Generic (Jsonb hask) | |
| Generic (Jsonb hask) | |
| HasDatatypeInfo (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type Associated Types type DatatypeInfoOf (Jsonb hask) :: DatatypeInfo # Methods datatypeInfo :: proxy (Jsonb hask) -> DatatypeInfo (Code (Jsonb hask)) # | |
| ToJSON x => Inline (Jsonb x) | |
| FromJSON x => FromPG (Jsonb x) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type.PG | |
| type Rep (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type | |
| type Code (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type | |
| type DatatypeInfoOf (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type | |
| type PG (Jsonb hask) | |
Defined in Squeal.PostgreSQL.Type.PG | |
The Composite newtype is an indication that the Haskell
type it's applied to should be stored as a
PGcomposite.
>>>:{data Complex = Complex { real :: Double , imaginary :: Double } deriving stock GHC.Generic deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) :}
>>>:kind! PG (Composite Complex)PG (Composite Complex) :: PGType = 'PGcomposite '["real" ::: 'NotNull 'PGfloat8, "imaginary" ::: 'NotNull 'PGfloat8]
Constructors
| Composite | |
Fields
| |
Instances
newtype Enumerated enum #
The Enumerated newtype is an indication that the Haskell
type it's applied to should be stored as a
PGenum.
>>>:kind! PG (Enumerated Ordering)PG (Enumerated Ordering) :: PGType = 'PGenum '["LT", "EQ", "GT"]
Constructors
| Enumerated | |
Fields
| |
Instances
The VarArray newtype is an indication that the Haskell
type it's applied to should be stored as a
PGvararray.
>>>import Data.Vector>>>:kind! PG (VarArray (Vector Double))PG (VarArray (Vector Double)) :: PGType = 'PGvararray ('NotNull 'PGfloat8)
Constructors
| VarArray | |
Fields
| |
Instances
The FixArray newtype is an indication that the Haskell
type it's applied to should be stored as a
PGfixarray.
>>>:kind! PG (FixArray ((Double, Double), (Double, Double)))PG (FixArray ((Double, Double), (Double, Double))) :: PGType = 'PGfixarray '[2, 2] ('NotNull 'PGfloat8)
Constructors
| FixArray | |
Fields
| |
Instances
| (ToArray db dims ty x, OidOfNull db ty) => ToPG db (FixArray x) | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| Eq arr => Eq (FixArray arr) | |
| Ord arr => Ord (FixArray arr) | |
Defined in Squeal.PostgreSQL.Type | |
| Read arr => Read (FixArray arr) | |
| Show arr => Show (FixArray arr) | |
| Generic (FixArray arr) | |
| Generic (FixArray arr) | |
| HasDatatypeInfo (FixArray arr) | |
Defined in Squeal.PostgreSQL.Type Associated Types type DatatypeInfoOf (FixArray arr) :: DatatypeInfo # Methods datatypeInfo :: proxy (FixArray arr) -> DatatypeInfo (Code (FixArray arr)) # | |
| FromArray dims ty y => FromPG (FixArray y) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG (FixArray hask) |
|
Defined in Squeal.PostgreSQL.Type.PG | |
| type Rep (FixArray arr) | |
Defined in Squeal.PostgreSQL.Type | |
| type Code (FixArray arr) | |
Defined in Squeal.PostgreSQL.Type | |
| type DatatypeInfoOf (FixArray arr) | |
Defined in Squeal.PostgreSQL.Type | |
| type PG (FixArray hask) | |
Defined in Squeal.PostgreSQL.Type.PG | |
Only is a 1-tuple type, useful for encoding or decoding a singleton
Instances
| Functor Only | |
| Foldable Only | |
Defined in Squeal.PostgreSQL.Type Methods fold :: Monoid m => Only m -> m # foldMap :: Monoid m => (a -> m) -> Only a -> m # foldMap' :: Monoid m => (a -> m) -> Only a -> m # foldr :: (a -> b -> b) -> b -> Only a -> b # foldr' :: (a -> b -> b) -> b -> Only a -> b # foldl :: (b -> a -> b) -> b -> Only a -> b # foldl' :: (b -> a -> b) -> b -> Only a -> b # foldr1 :: (a -> a -> a) -> Only a -> a # foldl1 :: (a -> a -> a) -> Only a -> a # elem :: Eq a => a -> Only a -> Bool # maximum :: Ord a => Only a -> a # | |
| Traversable Only | |
| Eq x => Eq (Only x) | |
| Ord x => Ord (Only x) | |
| Read x => Read (Only x) | |
| Show x => Show (Only x) | |
| Generic (Only x) | |
| Generic (Only x) | |
| HasDatatypeInfo (Only x) | |
Defined in Squeal.PostgreSQL.Type Associated Types type DatatypeInfoOf (Only x) :: DatatypeInfo # Methods datatypeInfo :: proxy (Only x) -> DatatypeInfo (Code (Only x)) # | |
| type Rep (Only x) | |
Defined in Squeal.PostgreSQL.Type | |
| type Code (Only x) | |
Defined in Squeal.PostgreSQL.Type | |
| type DatatypeInfoOf (Only x) | |
Defined in Squeal.PostgreSQL.Type | |
Variable-length text type with limit
>>>:kind! PG (VarChar 4)PG (VarChar 4) :: PGType = 'PGvarchar 4
Instances
| ToPG db (VarChar n) | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| Eq (VarChar n) | |
| Ord (VarChar n) | |
| Read (VarChar n) | |
| Show (VarChar n) | |
| (KnownNat n, 1 <= n) => Inline (VarChar n) | |
| KnownNat n => FromPG (VarChar n) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG (VarChar n) | |
Defined in Squeal.PostgreSQL.Type.PG | |
| type PG (VarChar n) | |
Defined in Squeal.PostgreSQL.Type.PG | |
Fixed-length, blank padded
>>>:kind! PG (FixChar 4)PG (FixChar 4) :: PGType = 'PGchar 4
Instances
| ToPG db (FixChar n) | |
Defined in Squeal.PostgreSQL.Session.Encode | |
| Eq (FixChar n) | |
| Ord (FixChar n) | |
| Read (FixChar n) | |
| Show (FixChar n) | |
| (KnownNat n, 1 <= n) => Inline (FixChar n) | |
| KnownNat n => FromPG (FixChar n) | |
Defined in Squeal.PostgreSQL.Session.Decode | |
| IsPG (FixChar n) | |
Defined in Squeal.PostgreSQL.Type.PG | |
| type PG (FixChar n) | |
Defined in Squeal.PostgreSQL.Type.PG | |
throwSqueal :: MonadUnliftIO io => SquealException -> io a #
Throw SquealExceptions.
trySqueal :: MonadUnliftIO io => io a -> io (Either SquealException a) #
Either return a SquealException or a result.
Arguments
| :: MonadUnliftIO io | |
| => (SquealException -> io a) | handler |
| -> io a | |
| -> io a |
Handle SquealExceptions.
Arguments
| :: MonadUnliftIO io | |
| => io a | |
| -> (SquealException -> io a) | handler |
| -> io a |
Catch SquealExceptions.
pattern UniqueViolation :: ByteString -> SquealException #
A pattern for unique violation exceptions.
pattern CheckViolation :: ByteString -> SquealException #
A pattern for check constraint violation exceptions.
pattern SerializationFailure :: ByteString -> SquealException #
A pattern for serialization failure exceptions.
data SquealException #
Exceptions that can be thrown by Squeal.
Constructors
| SQLException SQLState | SQL exception state |
| ConnectionException Text |
|
| DecodingException Text Text | decoding exception function and error message |
| ColumnsException Text Column | unexpected number of columns |
| RowsException Text Row Row | too few rows, expected at least and actual number of rows |
Instances
| Eq SquealException | |
Defined in Squeal.PostgreSQL.Session.Exception Methods (==) :: SquealException -> SquealException -> Bool # (/=) :: SquealException -> SquealException -> Bool # | |
| Show SquealException | |
Defined in Squeal.PostgreSQL.Session.Exception Methods showsPrec :: Int -> SquealException -> ShowS # show :: SquealException -> String # showList :: [SquealException] -> ShowS # | |
| Exception SquealException | |
Defined in Squeal.PostgreSQL.Session.Exception Methods toException :: SquealException -> SomeException # | |
A class for rendering SQL
Methods
renderSQL :: sql -> ByteString #