| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Control.Effect.Squeal
Synopsis
- data Squeal (schemas :: SchemasType) m k where
- ManipulateParams :: ToParams x params => Manipulation '[] schemas params ys -> x -> (K Result ys -> m k) -> Squeal schemas m k
- TraversePrepared :: (ToParams x params, Traversable list) => Manipulation '[] schemas params ys -> list x -> (list (K Result ys) -> m k) -> Squeal schemas m k
- TraversePrepared_ :: (ToParams x params, Foldable list) => Manipulation '[] schemas params '[] -> list x -> m k -> Squeal schemas m k
- manipulateParams :: (Has (Squeal schemas) sig m, ToParams x params) => Manipulation '[] schemas params ys -> x -> m (K Result ys)
- manipulateParams_ :: (Has (Squeal schemas) sig m, ToParams x params) => Manipulation '[] schemas params ys -> x -> m ()
- manipulate :: Has (Squeal schemas) sig m => Manipulation '[] schemas '[] ys -> m (K Result ys)
- manipulate_ :: Has (Squeal schemas) sig m => Manipulation '[] schemas '[] ys -> m ()
- runQueryParams :: (Has (Squeal schemas) sig m, ToParams x params) => Query '[] '[] schemas params ys -> x -> m (K Result ys)
- runQuery :: Has (Squeal schemas) sig m => Query '[] '[] schemas '[] ys -> m (K Result ys)
- traversePrepared :: (ToParams x params, Traversable list, Has (Squeal schemas) sig m) => Manipulation '[] schemas params ys -> list x -> m (list (K Result ys))
- forPrepared :: (ToParams x params, Traversable list, Has (Squeal schemas) sig m) => list x -> Manipulation '[] schemas params ys -> m (list (K Result ys))
- traversePrepared_ :: (ToParams x params, Foldable list, Has (Squeal schemas) sig m) => Manipulation '[] schemas params '[] -> list x -> m ()
- forPrepared_ :: (ToParams x params, Foldable list, Has (Squeal schemas) sig m) => list x -> Manipulation '[] schemas params '[] -> m ()
- type DBConnection (schemas :: SchemasType) = K Connection schemas
- newtype SquealPool schemas m k = GetSquealPool (Pool (DBConnection schemas) -> m k)
- getSquealPool :: Has (SquealPool schemas) sig m => m (Pool (DBConnection schemas))
- class IsLabel (x :: Symbol) a where
- fromLabel :: a
- (>>>) :: Category cat => cat a b -> cat b c -> cat a c
- (&) :: a -> (a -> b) -> b
- newtype K a (b :: k) :: forall k. Type -> k -> Type = K a
- unK :: K a b -> a
- data NP (a :: k -> Type) (b :: [k]) :: forall k. (k -> Type) -> [k] -> Type where
- data Result
- data ExecStatus
- data Row
- data Connection
- defaultMain :: Migratory p => ByteString -> AlignedList (Migration p) db0 db1 -> IO ()
- pureMigration :: Migration Definition schemas0 schemas1 -> Migration (Terminally PQ IO) schemas0 schemas1
- terminally :: Functor (trans x0 x1 monad) => trans x0 x1 monad ignore -> Terminally trans monad x0 x1
- data Migration (p :: k -> k -> Type) (schemas0 :: k) (schemas1 :: k) :: forall k. (k -> k -> Type) -> k -> k -> Type = Migration {}
- class Category p => Migratory (p :: SchemasType -> SchemasType -> Type) where
- migrateUp :: AlignedList (Migration p) schemas0 schemas1 -> PQ schemas0 schemas1 IO ()
- migrateDown :: AlignedList (Migration p) schemas0 schemas1 -> PQ schemas1 schemas0 IO ()
- newtype Terminally (trans :: k1 -> k2 -> k -> Type -> Type) (monad :: k) (x0 :: k1) (x1 :: k2) :: forall k k1 k2. (k1 -> k2 -> k -> Type -> Type) -> k -> k1 -> k2 -> Type = Terminally {
- runTerminally :: trans x0 x1 monad ()
- type MigrationsTable = (("migrations_unique_name" ::: Unique ("name" ': ([] :: [Symbol]))) ': ([] :: [(Symbol, TableConstraint)])) :=> (("name" ::: (NoDef :=> NotNull PGtext)) ': (("executed_at" ::: (Def :=> NotNull PGtimestamptz)) ': ([] :: [(Symbol, (ColumnConstraint, NullityType))])))
- longRunningMode :: TransactionMode
- defaultMode :: TransactionMode
- rollback :: Manipulation_ schemas () ()
- commit :: Manipulation_ schemas () ()
- begin :: TransactionMode -> Manipulation_ schemas () ()
- ephemerally_ :: (MonadUnliftIO tx, MonadPQ schemas tx) => tx x -> tx x
- ephemerally :: (MonadUnliftIO tx, MonadPQ schemas tx) => TransactionMode -> tx x -> tx x
- transactionallyRetry :: (MonadUnliftIO tx, MonadPQ schemas tx) => TransactionMode -> tx x -> tx x
- transactionally_ :: (MonadUnliftIO tx, MonadPQ schemas tx) => tx x -> tx x
- transactionally :: (MonadUnliftIO tx, MonadPQ schemas tx) => TransactionMode -> tx x -> tx x
- data TransactionMode = TransactionMode {}
- data IsolationLevel
- data AccessMode
- data DeferrableMode
- class Literal hask where
- destroyConnectionPool :: MonadUnliftIO io => Pool (K Connection schemas) -> io ()
- usingConnectionPool :: MonadUnliftIO io => Pool (K Connection schemas) -> PQ schemas schemas io x -> io x
- createConnectionPool :: MonadUnliftIO io => ByteString -> Int -> NominalDiffTime -> Int -> io (Pool (K Connection schemas))
- 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
- okResult :: MonadIO io => K Result row -> io ()
- resultErrorCode :: MonadIO io => K Result results -> io (Maybe ByteString)
- resultErrorMessage :: MonadIO io => K Result results -> io (Maybe ByteString)
- resultStatus :: MonadIO io => K Result results -> io ExecStatus
- ntuples :: MonadIO io => K Result columns -> io Row
- liftResult :: MonadIO io => (Result -> IO x) -> K Result results -> io x
- firstRow :: (FromRow columns y, MonadIO io) => K Result columns -> io (Maybe y)
- getRows :: (FromRow columns y, MonadIO io) => K Result columns -> io [y]
- nextRow :: (FromRow columns y, MonadIO io) => Row -> K Result columns -> Row -> io (Maybe (Row, y))
- getRow :: (FromRow columns y, MonadIO io) => Row -> K Result columns -> io y
- evalPQ :: Functor m => PQ schemas0 schemas1 m x -> K Connection schemas0 -> m x
- execPQ :: Functor m => PQ schemas0 schemas1 m x -> K Connection schemas0 -> m (K Connection schemas1)
- runPQ :: Functor m => PQ schemas0 schemas1 m x -> K Connection schemas0 -> m (x, K Connection schemas1)
- lowerConnection :: K Connection (schema ': schemas) -> K Connection schemas
- withConnection :: MonadUnliftIO io => ByteString -> PQ schemas0 schemas1 io x -> io x
- finish :: MonadIO io => K Connection schemas -> io ()
- connectdb :: MonadIO io => ByteString -> io (K Connection schemas)
- newtype PQ (schemas0 :: SchemasType) (schemas1 :: SchemasType) (m :: Type -> Type) x = PQ {
- unPQ :: K Connection schemas0 -> m (K x schemas1)
- class IndexedMonadTransPQ (pq :: SchemasType -> SchemasType -> (Type -> Type) -> Type -> Type) where
- pqAp :: Monad m => pq schemas0 schemas1 m (x -> y) -> pq schemas1 schemas2 m x -> pq schemas0 schemas2 m y
- pqJoin :: Monad m => pq schemas0 schemas1 m (pq schemas1 schemas2 m y) -> pq schemas0 schemas2 m y
- pqBind :: Monad m => (x -> pq schemas1 schemas2 m y) -> pq schemas0 schemas1 m x -> pq schemas0 schemas2 m y
- pqThen :: Monad m => pq schemas1 schemas2 m y -> pq schemas0 schemas1 m x -> pq schemas0 schemas2 m y
- pqAndThen :: Monad m => (y -> pq schemas1 schemas2 m z) -> (x -> pq schemas0 schemas1 m y) -> x -> pq schemas0 schemas2 m z
- define :: MonadIO io => Definition schemas0 schemas1 -> pq schemas0 schemas1 io ()
- class Monad pq => MonadPQ (schemas :: SchemasType) (pq :: Type -> Type) | pq -> schemas where
- liftPQ :: (Connection -> IO a) -> pq a
- data PQState = PQState {}
- data SquealException
- class ToParam x (pg :: PGType) where
- class HasOid (ty :: PGType) where
- class HasAliasedOid (field :: (Symbol, NullityType)) where
- aliasedOid :: Word32
- class ToNullityParam x (ty :: NullityType) where
- toNullityParam :: x -> K (Maybe Encoding) ty
- class ToField (x :: (Symbol, Type)) (field :: (Symbol, NullityType)) where
- class ToFixArray x (dims :: [Nat]) (array :: NullityType) where
- toFixArray :: x -> K (K Array dims) array
- class SListI tys => ToParams x (tys :: [NullityType]) where
- class FromValue (pg :: PGType) y where
- class FromField (pg :: (Symbol, NullityType)) (y :: (Symbol, Type)) where
- class FromFixArray (dims :: [Nat]) (ty :: NullityType) y where
- fromFixArray :: Array y
- class SListI result => FromRow (result :: RowType) y where
- fromRow :: NP (K (Maybe ByteString) :: (Symbol, NullityType) -> Type) result -> Either Text y
- newtype Only x = Only {
- fromOnly :: x
- bigserial :: ColumnTypeExpression schemas (Def :=> NotNull PGint8)
- serial8 :: ColumnTypeExpression schemas (Def :=> NotNull PGint8)
- serial :: ColumnTypeExpression schemas (Def :=> NotNull PGint4)
- serial4 :: ColumnTypeExpression schemas (Def :=> NotNull PGint4)
- smallserial :: ColumnTypeExpression schemas (Def :=> NotNull PGint2)
- serial2 :: ColumnTypeExpression schemas (Def :=> NotNull PGint2)
- default_ :: Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ([] :: [(Symbol, RowType)]) ty -> ColumnTypeExpression schemas (NoDef :=> ty) -> ColumnTypeExpression schemas (Def :=> ty)
- notNullable :: TypeExpression schemas (nullity ty) -> ColumnTypeExpression schemas (NoDef :=> NotNull ty)
- nullable :: TypeExpression schemas (nullity ty) -> ColumnTypeExpression schemas (NoDef :=> Null ty)
- dropType :: (Has sch schemas schema, Has td schema (Typedef ty)) => QualifiedAlias sch td -> Definition schemas (Alter sch (Drop td schema) schemas)
- createDomain :: (Has sch schemas schema, KnownSymbol dom) => QualifiedAlias sch dom -> (forall (nullity :: PGType -> NullityType). TypeExpression schemas (nullity ty)) -> (forall (tab :: Symbol). Condition ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ((tab ::: (("value" ::: Null ty) ': ([] :: [(Symbol, NullityType)]))) ': ([] :: [(Symbol, [(Symbol, NullityType)])]))) -> Definition schemas (Alter sch (Create alias (Typedef ty) schema) schemas)
- createTypeCompositeFrom :: (All (FieldTyped schemas) (RowPG hask), KnownSymbol ty, Has sch schemas schema) => QualifiedAlias sch ty -> Definition schemas (Alter sch (Create ty (Typedef (PG (Composite hask))) schema) schemas)
- createTypeComposite :: (KnownSymbol ty, Has sch schemas schema, SListI fields) => QualifiedAlias sch ty -> NP (Aliased (TypeExpression schemas)) fields -> Definition schemas (Alter sch (Create ty (Typedef (PGcomposite fields)) schema) schemas)
- createTypeEnumFrom :: (Generic hask, All KnownSymbol (LabelsPG hask), KnownSymbol enum, Has sch schemas schema) => QualifiedAlias sch enum -> Definition schemas (Alter sch (Create enum (Typedef (PG (Enumerated hask))) schema) schemas)
- createTypeEnum :: (KnownSymbol enum, Has sch schemas schema, All KnownSymbol labels) => QualifiedAlias sch enum -> NP PGlabel labels -> Definition schemas (Alter sch (Create enum (Typedef (PGenum labels)) schema) schemas)
- dropView :: (Has sch schemas schema, Has vw schema (View view)) => QualifiedAlias sch vw -> Definition schemas (Alter sch (Drop vw schema) schemas)
- createView :: (KnownSymbol sch, KnownSymbol vw, Has sch schemas schema) => QualifiedAlias sch vw -> Query ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) schemas ([] :: [NullityType]) view -> Definition schemas (Alter sch (Create vw (View view) schema) schemas)
- alterType :: ColumnTypeExpression schemas ty -> AlterColumn schemas ty0 ty
- dropNotNull :: AlterColumn schemas (constraint :=> NotNull ty) (constraint :=> Null ty)
- setNotNull :: AlterColumn schemas (constraint :=> Null ty) (constraint :=> NotNull ty)
- dropDefault :: AlterColumn schemas (Def :=> ty) (NoDef :=> ty)
- setDefault :: Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ([] :: [(Symbol, RowType)]) ty -> AlterColumn schemas (constraint :=> ty) (Def :=> ty)
- alterColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), Has column columns ty0, table1 ~ (constraints :=> Alter column ty1 columns)) => Alias column -> AlterColumn schemas ty0 ty1 -> AlterTable sch tab schemas table1
- renameColumn :: (KnownSymbol column0, KnownSymbol column1, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (constraints :=> Rename column0 column1 columns)) => Alias column0 -> Alias column1 -> AlterTable sch tab schemas table1
- dropColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (constraints :=> Drop column columns)) => Alias column -> AlterTable sch tab schemas table1
- dropConstraint :: (KnownSymbol constraint, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (Drop constraint constraints :=> columns)) => Alias constraint -> AlterTable sch tab schemas table1
- addConstraint :: (KnownSymbol alias, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (Create alias constraint constraints :=> columns)) => Alias alias -> TableConstraintExpression sch tab schemas constraint -> AlterTable sch tab schemas table1
- alterTableRename :: (KnownSymbol table0, KnownSymbol table1) => Alias table0 -> Alias table1 -> Definition schema (Rename table0 table1 schema)
- alterTable :: (Has sch schemas schema, Has tab schema (Table table0)) => QualifiedAlias sch tab -> AlterTable sch tab schemas table1 -> Definition schemas (Alter sch (Alter tab (Table table1) schema) schemas)
- dropTable :: (Has sch schemas schema, Has tab schema (Table table)) => QualifiedAlias sch tab -> Definition schemas (Alter sch (Drop tab schema) schemas)
- dropSchema :: Has sch schemas schema => Alias sch -> Definition schemas (Drop sch schemas)
- foreignKey :: ForeignKeyed schemas sch schema child parent table reftable columns refcolumns constraints cols reftys tys => NP Alias columns -> Alias parent -> NP Alias refcolumns -> OnDeleteClause -> OnUpdateClause -> TableConstraintExpression sch child schemas (ForeignKey columns parent refcolumns)
- primaryKey :: (Has sch schemas schema, Has tab schema (Table table), HasAll aliases (TableToColumns table) subcolumns, AllNotNull subcolumns) => NP Alias aliases -> TableConstraintExpression sch tab schemas (PrimaryKey aliases)
- unique :: (Has sch schemas schema, Has tab schema (Table table), HasAll aliases (TableToRow table) subcolumns) => NP Alias aliases -> TableConstraintExpression sch tab schemas (Unique aliases)
- check :: (Has sch schemas schema, Has tab schema (Table table), HasAll aliases (TableToRow table) subcolumns) => NP Alias aliases -> (forall (t :: Symbol). Condition ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ((t ::: subcolumns) ': ([] :: [(Symbol, [(Symbol, NullityType)])]))) -> TableConstraintExpression sch tab schemas (Check aliases)
- createTableIfNotExists :: (Has sch schemas schema, Has tab schema (Table (constraints :=> columns)), SListI columns, SListI constraints) => QualifiedAlias sch tab -> NP (Aliased (ColumnTypeExpression schemas)) columns -> NP (Aliased (TableConstraintExpression sch tab schemas)) constraints -> Definition schemas schemas
- createTable :: (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch schemas0 schema0, schemas1 ~ Alter sch (Create tab (Table (constraints :=> columns)) schema0) schemas0) => QualifiedAlias sch tab -> NP (Aliased (ColumnTypeExpression schemas0)) columns -> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints -> Definition schemas0 schemas1
- createSchemaIfNotExists :: (KnownSymbol sch, Has sch schemas schema) => Alias sch -> Definition schemas schemas
- createSchema :: KnownSymbol sch => Alias sch -> Definition schemas (Create sch ([] :: [(Symbol, SchemumType)]) schemas)
- manipDefinition :: Manipulation ([] :: [(Symbol, RowType)]) schemas ([] :: [NullityType]) ([] :: [(Symbol, NullityType)]) -> Definition schemas schemas
- newtype Definition (schemas0 :: SchemasType) (schemas1 :: SchemasType) = UnsafeDefinition {}
- newtype TableConstraintExpression (sch :: Symbol) (tab :: Symbol) (schemas :: SchemasType) (constraint :: TableConstraint) = UnsafeTableConstraintExpression {}
- type ForeignKeyed (schemas :: [(Symbol, [(Symbol, SchemumType)])]) (sch :: Symbol) (schema :: [(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 sch schemas schema, Has child schema (Table table), Has parent schema (Table reftable), HasAll columns (TableToColumns table) tys, reftable ~ (constraints :=> cols), HasAll refcolumns cols reftys, AllZip SamePGType tys reftys, Uniquely refcolumns constraints)
- data OnDeleteClause
- data OnUpdateClause
- newtype AlterTable (sch :: Symbol) (tab :: Symbol) (schemas :: SchemasType) (table :: TableType) = UnsafeAlterTable {}
- class AddColumn (ty :: ColumnType) where
- addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas ty -> AlterTable sch tab schemas (constraints :=> Create column ty columns)
- newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) = UnsafeAlterColumn {}
- class FieldTyped (schemas :: SchemasType) (ty :: (Symbol, NullityType)) where
- fieldtype :: Aliased (TypeExpression schemas) ty
- newtype ColumnTypeExpression (schemas :: SchemasType) (ty :: ColumnType) = UnsafeColumnTypeExpression {}
- 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 :: SetOfFunction "jsonb_object_keys" (null PGjsonb) (("jsonb_object_keys" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))
- jsonObjectKeys :: SetOfFunction "json_object_keys" (nullity PGjson) (("json_object_keys" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))
- jsonbEachText :: SetOfFunction "jsonb_each_text" (null PGjsonb) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)])))
- jsonEachText :: SetOfFunction "json_each_text" (null PGjson) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)])))
- jsonbEach :: SetOfFunction "jsonb_each" (nullity PGjsonb) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGjson) ': ([] :: [(Symbol, NullityType)])))
- jsonEach :: SetOfFunction "json_each" (null PGjson) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGjson) ': ([] :: [(Symbol, NullityType)])))
- jsonbPretty :: null PGjsonb :--> null PGtext
- jsonbInsert :: FunctionN (null PGjsonb ': (null (PGvararray (NotNull PGtext)) ': (null PGjsonb ': (null PGbool ': ([] :: [NullityType]))))) (null PGjsonb)
- jsonbSet :: FunctionN (null PGjsonb ': (null (PGvararray (NotNull PGtext)) ': (null PGjsonb ': (null PGbool ': ([] :: [NullityType]))))) (null PGjsonb)
- jsonbStripNulls :: null PGjsonb :--> null PGjsonb
- jsonStripNulls :: null PGjson :--> null PGjson
- jsonbTypeof :: null PGjsonb :--> null PGtext
- jsonTypeof :: null PGjson :--> null PGtext
- jsonbArrayLength :: null PGjsonb :--> null PGint4
- jsonArrayLength :: null PGjson :--> null PGint4
- jsonbZipObject :: FunctionN (null (PGvararray (NotNull PGtext)) ': (null (PGvararray (NotNull PGtext)) ': ([] :: [NullityType]))) (null PGjsonb)
- jsonZipObject :: FunctionN (null (PGvararray (NotNull PGtext)) ': (null (PGvararray (NotNull PGtext)) ': ([] :: [NullityType]))) (null PGjson)
- jsonbObject :: null (PGfixarray (n ': (2 ': ([] :: [Nat]))) (NotNull PGtext)) :--> null PGjsonb
- jsonObject :: null (PGfixarray (n ': (2 ': ([] :: [Nat]))) (NotNull PGtext)) :--> null PGjson
- jsonbBuildArray :: SListI tuple => FunctionN tuple (null PGjsonb)
- jsonBuildArray :: SListI tuple => FunctionN tuple (null PGjson)
- rowToJson :: null (PGcomposite ty) :--> null PGjson
- arrayToJson :: null (PGvararray ty) :--> null PGjson
- toJsonb :: null ty :--> null PGjsonb
- toJson :: null ty :--> null PGjson
- (#-.) :: Operator (null PGjsonb) (null (PGvararray (NotNull PGtext))) (null PGjsonb)
- (.-.) :: In key (PGtext ': (PGvararray (NotNull PGtext) ': (PGint4 ': (PGint2 ': ([] :: [PGType]))))) => Operator (null PGjsonb) (null key) (null PGjsonb)
- (.?&) :: Operator (null PGjsonb) (null (PGvararray (NotNull PGtext))) (Null PGbool)
- (.?|) :: Operator (null PGjsonb) (null (PGvararray (NotNull PGtext))) (Null PGbool)
- (.?) :: Operator (null PGjsonb) (null PGtext) (Null PGbool)
- (.#>>) :: In json PGJsonType => Operator (null json) (null (PGvararray (NotNull PGtext))) (Null PGtext)
- (.#>) :: In json PGJsonType => Operator (null json) (null (PGvararray (NotNull PGtext))) (Null json)
- (.->>) :: (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) (Null PGtext)
- (.->) :: (In json PGJsonType, In key PGJsonKey) => Operator (null json) (null key) (Null json)
- class SListI tys => JsonBuildObject (tys :: [NullityType]) where
- jsonBuildObject :: FunctionN tys (null PGjson)
- jsonbBuildObject :: FunctionN tys (null PGjsonb)
- type JsonPopulateFunction (fun :: Symbol) (json :: PGType) = forall (schemas :: SchemasType) (row :: RowType) (outer :: FromType) (commons :: FromType) (params :: [NullityType]). In json PGJsonType => TypeExpression schemas (NotNull (PGcomposite row)) -> Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]) (NotNull json) -> FromClause outer commons schemas params ((fun ::: row) ': ([] :: [(Symbol, RowType)]))
- type JsonToRecordFunction (json :: PGType) = forall (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (tab :: Symbol) (row :: [(Symbol, NullityType)]). (SListI row, In json PGJsonType) => Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]) (NotNull json) -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: row) -> FromClause outer commons schemas params ((tab ::: row) ': ([] :: [(Symbol, [(Symbol, NullityType)])]))
- field :: (Has sch schemas schema, Has tydef schema (Typedef (PGcomposite row)), Has field row ty) => QualifiedAlias sch tydef -> Alias field -> Expression outer commons grp schemas params from (NotNull (PGcomposite row)) -> Expression outer commons grp schemas params from ty
- row :: SListI row => NP (Aliased (Expression outer commons grp schemas params from)) row -> Expression outer commons grp schemas params from (null (PGcomposite row))
- unnest :: SetOfFunction "unnest" (null (PGvararray ty)) (("unnest" ::: ty) ': ([] :: [(Symbol, NullityType)]))
- index :: Word64 -> null (PGvararray ty) :--> NullifyType ty
- cardinality :: null (PGvararray ty) :--> null PGint8
- array2 :: (All ([NullityType] ~ tys) tyss, All (SListI :: [NullityType] -> Constraint) tyss, Length tyss ~ n1, All (NullityType ~ ty) tys, Length tys ~ n2) => NP (NP (Expression outer commons grp schemas params from)) tyss -> Expression outer commons grp schemas params from (null (PGfixarray (n1 ': (n2 ': ([] :: [Nat]))) ty))
- array1 :: (n ~ Length tys, All (NullityType ~ ty) tys) => NP (Expression outer commons grp schemas params from) tys -> Expression outer commons grp schemas params from (null (PGfixarray (n ': ([] :: [Nat])) ty))
- array :: [Expression outer commons grp schemas params from ty] -> Expression outer commons grp schemas params from (null (PGvararray ty))
- generateSeriesTimestamp :: In ty (PGtimestamp ': (PGtimestamptz ': ([] :: [PGType]))) => SetOfFunctionN "generate_series" (null ty ': (null ty ': (null PGinterval ': ([] :: [NullityType])))) (("generate_series" ::: null ty) ': ([] :: [(Symbol, NullityType)]))
- generateSeriesStep :: In ty (PGint4 ': (PGint8 ': (PGnumeric ': ([] :: [PGType])))) => SetOfFunctionN "generate_series" (null ty ': (null ty ': (null ty ': ([] :: [NullityType])))) (("generate_series" ::: null ty) ': ([] :: [(Symbol, NullityType)]))
- generateSeries :: In ty (PGint4 ': (PGint8 ': (PGnumeric ': ([] :: [PGType])))) => SetOfFunctionN "generate_series" (null ty ': (null ty ': ([] :: [NullityType]))) (("generate_series" ::: null ty) ': ([] :: [(Symbol, NullityType)]))
- unsafeSetOfFunctionN :: (SListI tys, KnownSymbol fun) => SetOfFunctionN fun tys setof
- unsafeSetOfFunction :: KnownSymbol fun => SetOfFunction fun ty setof
- type SetOfFunction (fun :: Symbol) (ty :: NullityType) (setof :: k) = forall (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]). Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]) ty -> FromClause outer commons schemas params ((fun ::: setof) ': ([] :: [(Symbol, k)]))
- type SetOfFunctionN (fun :: Symbol) (tys :: [NullityType]) (setof :: k) = forall (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]). NP (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)])) tys -> FromClause outer commons schemas params ((fun ::: setof) ': ([] :: [(Symbol, k)]))
- notIn :: Expression outer commons grp schemas params from ty -> [Expression outer commons grp schemas params from ty] -> Condition outer commons grp schemas params from
- in_ :: Expression outer commons grp schemas params from ty -> [Expression outer commons grp schemas params from ty] -> Condition outer commons grp schemas params from
- subAny :: Expression outer commons grp schemas params from ty1 -> Operator ty1 ty2 (Null PGbool) -> Query (Join outer from) commons schemas params ((col ::: ty2) ': ([] :: [(Symbol, NullityType)])) -> Condition outer commons grp schemas params from
- subAll :: Expression outer commons grp schemas params from ty1 -> Operator ty1 ty2 (Null PGbool) -> Query (Join outer from) commons schemas params ((col ::: ty2) ': ([] :: [(Symbol, NullityType)])) -> Condition outer commons grp schemas params from
- exists :: Query (Join outer from) commons schemas params row -> Condition outer commons grp schemas params from
- deleteFrom_ :: (db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row ~ TableToRow table, columns ~ TableToColumns table) => QualifiedAlias sch tab -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row) ': ([] :: [(Symbol, RowType)])) -> Manipulation commons schemas params ([] :: [(Symbol, NullityType)])
- deleteFrom :: (SListI row1, db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row0 ~ TableToRow table, columns ~ TableToColumns table) => QualifiedAlias sch tab -> UsingClause commons schemas params from -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row0) ': from) -> ReturningClause commons schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) row1 -> Manipulation commons schemas params row1
- update_ :: (SListI columns, db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row ~ TableToRow table, columns ~ TableToColumns table, All (HasIn columns :: (Symbol, (ColumnConstraint, NullityType)) -> Constraint) subcolumns, AllUnique subcolumns) => QualifiedAlias sch tab -> NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas params ((tab ::: row) ': ([] :: [(Symbol, RowType)]))))) subcolumns -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row) ': ([] :: [(Symbol, RowType)])) -> Manipulation commons schemas params ([] :: [(Symbol, NullityType)])
- update :: (SListI columns, SListI row1, db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row0 ~ TableToRow table, columns ~ TableToColumns table, All (HasIn columns :: (Symbol, (ColumnConstraint, NullityType)) -> Constraint) subcolumns, AllUnique subcolumns) => QualifiedAlias sch tab -> NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)]))))) subcolumns -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) -> ReturningClause commons schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) row1 -> Manipulation commons schemas params row1
- insertInto_ :: (Has sch schemas schema, Has tab schema (Table table), columns ~ TableToColumns table, row ~ TableToRow table, SListI columns) => QualifiedAlias sch tab -> QueryClause commons schemas params columns -> Manipulation commons schemas params ([] :: [(Symbol, NullityType)])
- insertInto :: (Has sch schemas schema, Has tab schema (Table table), columns ~ TableToColumns table, row0 ~ TableToRow table, SListI columns, SListI row1) => QualifiedAlias sch tab -> QueryClause commons schemas params columns -> ConflictClause tab commons schemas params table -> ReturningClause commons schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) row1 -> Manipulation commons schemas params row1
- queryStatement :: Query ([] :: [(Symbol, RowType)]) commons schemas params columns -> Manipulation commons schemas params columns
- pattern Values_ :: forall (columns :: [(Symbol, (ColumnConstraint, NullityType))]) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]). SListI columns => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ([] :: [(Symbol, RowType)])))) columns -> QueryClause commons schemas params columns
- pattern Returning_ :: forall (row :: [(Symbol, NullityType)]) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). SListI row => NP (Aliased (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params from)) row -> ReturningClause commons schemas params from row
- newtype Manipulation (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: RowType) = UnsafeManipulation {}
- type family Manipulation_ (schemas :: SchemasType) params row :: Type where ...
- data QueryClause (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]) where
- Values :: forall (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]). SListI columns => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ([] :: [(Symbol, RowType)])))) columns -> [NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ([] :: [(Symbol, RowType)])))) columns] -> QueryClause commons schemas params columns
- Select :: forall (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]) (grp :: Grouping) (from :: FromType). SListI columns => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons grp schemas params from))) columns -> TableExpression ([] :: [(Symbol, RowType)]) commons grp schemas params from -> QueryClause commons schemas params columns
- Subquery :: forall (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]) (row :: RowType). ColumnsToRow columns ~ row => Query ([] :: [(Symbol, RowType)]) commons schemas params row -> QueryClause commons schemas params columns
- data Optional (expr :: k -> Type) (ty :: (ColumnConstraint, k)) :: forall k. (k -> Type) -> (ColumnConstraint, k) -> Type where
- Default :: forall k (expr :: k -> Type) (ty :: (ColumnConstraint, k)) (ty1 :: k). Optional expr ((,) Def ty1)
- Set :: forall k (expr :: k -> Type) (ty :: (ColumnConstraint, k)) (ty1 :: k) (def :: ColumnConstraint). expr ty1 -> Optional expr ((,) def ty1)
- newtype ReturningClause (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType) = Returning (Selection ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params from row)
- data ConflictClause (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (table :: ([(Symbol, kind)], ColumnsType)) :: forall kind. Symbol -> FromType -> SchemasType -> [NullityType] -> ([(Symbol, kind)], ColumnsType) -> Type where
- OnConflictDoRaise :: forall kind (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (table :: ([(Symbol, kind)], ColumnsType)). ConflictClause tab commons schemas params table
- OnConflict :: forall kind (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (table :: ([(Symbol, kind)], ColumnsType)) (constraints :: [(Symbol, kind)]) (columns :: ColumnsType). ConflictTarget constraints -> ConflictAction tab commons schemas params columns -> ConflictClause tab commons schemas params ((,) constraints columns)
- data ConflictAction (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: ColumnsType) where
- DoNothing :: forall (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: ColumnsType). ConflictAction tab commons schemas params columns
- DoUpdate :: forall (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: ColumnsType) (row :: RowType) (col0 :: (Symbol, ColumnType)) (cols :: [(Symbol, ColumnType)]) (subcolumns :: [(Symbol, (ColumnConstraint, NullityType))]). (row ~ ColumnsToRow columns, SListI columns, columns ~ (col0 ': cols), All (HasIn columns :: (Symbol, (ColumnConstraint, NullityType)) -> Constraint) subcolumns, AllUnique subcolumns) => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row) ': (("excluded" ::: row) ': ([] :: [(Symbol, RowType)])))))) subcolumns -> [Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row) ': (("excluded" ::: row) ': ([] :: [(Symbol, RowType)])))] -> ConflictAction tab commons schemas params columns
- data ConflictTarget (constraints :: [(Symbol, kind)]) :: forall kind. [(Symbol, kind)] -> Type where
- OnConstraint :: forall kind (constraints :: [(Symbol, kind)]) (con :: Symbol) (constraint :: kind). Has con constraints constraint => Alias con -> ConflictTarget constraints
- data UsingClause (commons :: k) (schemas :: k1) (params :: k2) (from :: [k3]) :: forall k k1 k2 k3. k -> k1 -> k2 -> [k3] -> Type where
- NoUsing :: forall k k1 k2 k3 (commons :: k) (schemas :: k1) (params :: k2) (from :: [k3]). UsingClause commons schemas params ([] :: [k3])
- Using :: forall k k1 k2 k3 (commons :: k) (schemas :: k1) (params :: k2) (from :: [k3]) k4. FromClause ([] :: [k4]) commons schemas params from -> UsingClause commons schemas params from
- withRecursive :: Aliased (Query outer (recursive ': commons) schemas params) recursive -> Query outer (recursive ': commons) schemas params row -> Query outer commons schemas params row
- fullOuterJoin :: FromClause outer commons schemas params right -> Condition outer commons Ungrouped schemas params (Join left right) -> FromClause outer commons schemas params left -> FromClause outer commons schemas params (Join (NullifyFrom left) (NullifyFrom right))
- rightOuterJoin :: FromClause outer commons schemas params right -> Condition outer commons Ungrouped schemas params (Join left right) -> FromClause outer commons schemas params left -> FromClause outer commons schemas params (Join (NullifyFrom left) right)
- leftOuterJoin :: FromClause outer commons schemas params right -> Condition outer commons Ungrouped schemas params (Join left right) -> FromClause outer commons schemas params left -> FromClause outer commons schemas params (Join left (NullifyFrom right))
- innerJoin :: FromClause outer commons schemas params right -> Condition outer commons Ungrouped schemas params (Join left right) -> FromClause outer commons schemas params left -> FromClause outer commons schemas params (Join left right)
- crossJoin :: FromClause outer commons schemas params right -> FromClause outer commons schemas params left -> FromClause outer commons schemas params (Join left right)
- common :: Has cte commons common => Aliased Alias (alias ::: cte) -> FromClause outer commons schemas params ((alias ::: common) ': ([] :: [(Symbol, k4)]))
- view :: (Has sch schemas schema, Has vw schema (View view)) => Aliased (QualifiedAlias sch) (alias ::: vw) -> FromClause outer commons schemas params ((alias ::: view) ': ([] :: [(Symbol, RowType)]))
- subquery :: Aliased (Query outer commons schemas params) query -> FromClause outer commons schemas params (query ': ([] :: [(Symbol, RowType)]))
- table :: (Has sch schemas schema, Has tab schema (Table table)) => Aliased (QualifiedAlias sch) (alias ::: tab) -> FromClause outer commons schemas params ((alias ::: TableToRow table) ': ([] :: [(Symbol, RowType)]))
- offset :: Word64 -> TableExpression outer commons grp schemas params from -> TableExpression outer commons grp schemas params from
- limit :: Word64 -> TableExpression outer commons grp schemas params from -> TableExpression outer commons grp schemas params from
- having :: Condition outer commons (Grouped bys) schemas params from -> TableExpression outer commons (Grouped bys) schemas params from -> TableExpression outer commons (Grouped bys) schemas params from
- groupBy :: SListI bys => NP (By from) bys -> TableExpression outer commons Ungrouped schemas params from -> TableExpression outer commons (Grouped bys) schemas params from
- where_ :: Condition outer commons Ungrouped schemas params from -> TableExpression outer commons grp schemas params from -> TableExpression outer commons grp schemas params from
- from :: FromClause outer commons schemas params from -> TableExpression outer commons Ungrouped schemas params from
- values_ :: SListI cols => NP (Aliased (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]))) cols -> Query outer commons schemas params cols
- values :: SListI cols => NP (Aliased (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]))) cols -> [NP (Aliased (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]))) cols] -> Query outer commons schemas params cols
- selectDistinct_ :: (SListI columns, columns ~ (col ': cols)) => NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns -> TableExpression outer commons Ungrouped schemas params from -> Query outer commons schemas params columns
- selectDistinct :: (SListI columns, columns ~ (col ': cols)) => Selection outer commons Ungrouped schemas params from columns -> TableExpression outer commons Ungrouped schemas params from -> Query outer commons schemas params columns
- select_ :: (SListI row, row ~ (x ': xs)) => NP (Aliased (Expression outer commons grp schemas params from)) row -> TableExpression outer commons grp schemas params from -> Query outer commons schemas params row
- select :: (SListI row, row ~ (x ': xs)) => Selection outer commons grp schemas params from row -> TableExpression outer commons grp schemas params from -> Query outer commons schemas params row
- exceptAll :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns
- except :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns
- intersectAll :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns
- intersect :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns
- unionAll :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns
- union :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns
- newtype Query (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (row :: RowType) = UnsafeQuery {}
- type family Query_ (schemas :: SchemasType) parameters row :: Type where ...
- data Selection (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType) where
- Star :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType) (tab :: Symbol). HasUnique tab from row => Selection outer commons Ungrouped schemas params from row
- DotStar :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType) (tab :: Symbol). Has tab from row => Alias tab -> Selection outer commons Ungrouped schemas params from row
- List :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType). SListI row => NP (Aliased (Expression outer commons grp schemas params from)) row -> Selection outer commons grp schemas params from row
- Over :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType). SListI row => NP (Aliased (WindowFunction outer commons grp schemas params from)) row -> WindowDefinition outer commons grp schemas params from -> Selection outer commons grp schemas params from row
- Also :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType) (right :: RowType) (left :: RowType). Selection outer commons grp schemas params from right -> Selection outer commons grp schemas params from left -> Selection outer commons grp schemas params from (Join left right)
- data TableExpression (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) = TableExpression {
- fromClause :: FromClause outer commons schemas params from
- whereClause :: [Condition outer commons Ungrouped schemas params from]
- groupByClause :: GroupByClause grp from
- havingClause :: HavingClause outer commons grp schemas params from
- orderByClause :: [SortExpression outer commons grp schemas params from]
- limitClause :: [Word64]
- offsetClause :: [Word64]
- newtype FromClause (outer :: k) (commons :: k1) (schemas :: k2) (params :: k3) (from :: k4) :: forall k k1 k2 k3 k4. k -> k1 -> k2 -> k3 -> k4 -> Type = UnsafeFromClause {}
- data By (from :: FromType) (by :: (Symbol, Symbol)) where
- By1 :: forall (from :: FromType) (by :: (Symbol, Symbol)) (table :: Symbol) (columns :: [(Symbol, NullityType)]) (column :: Symbol) (ty :: NullityType). (HasUnique table from columns, Has column columns ty) => Alias column -> By from ((,) table column)
- By2 :: forall (from :: FromType) (by :: (Symbol, Symbol)) (table :: Symbol) (columns :: [(Symbol, NullityType)]) (column :: Symbol) (ty :: NullityType). (Has table from columns, Has column columns ty) => Alias table -> Alias column -> By from ((,) table column)
- data GroupByClause (grp :: Grouping) (from :: FromType) where
- data HavingClause (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) where
- NoHaving :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). HavingClause outer commons Ungrouped schemas params from
- Having :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (bys :: [(Symbol, Symbol)]). [Condition outer commons (Grouped bys) schemas params from] -> HavingClause outer commons (Grouped bys) schemas params from
- data CommonTableExpression (statement :: FromType -> SchemasType -> [NullityType] -> RowType -> Type) (schemas :: SchemasType) (params :: [NullityType]) (commons0 :: FromType) (commons1 :: FromType) where
- CommonTableExpression :: forall (statement :: FromType -> SchemasType -> [NullityType] -> RowType -> Type) (schemas :: SchemasType) (params :: [NullityType]) (commons0 :: FromType) (commons1 :: FromType) (cte :: Symbol) (common :: RowType). Aliased (statement commons0 schemas params) (cte ::: common) -> CommonTableExpression statement schemas params commons0 ((cte ::: common) ': commons0)
- class With (statement :: FromType -> SchemasType -> [NullityType] -> RowType -> Type) where
- with :: AlignedList (CommonTableExpression statement schemas params) commons0 commons1 -> statement commons1 schemas params row -> statement commons0 schemas params row
- nthValue :: WinFunN (null ty ': (NotNull PGint4 ': ([] :: [NullityType]))) (Null ty)
- lastValue :: WinFun1 ty ty
- firstValue :: WinFun1 ty ty
- lead :: WinFunN (ty ': (NotNull PGint4 ': (ty ': ([] :: [NullityType])))) ty
- lag :: WinFunN (ty ': (NotNull PGint4 ': (ty ': ([] :: [NullityType])))) ty
- ntile :: WinFun1 (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 :: SListI xs => ByteString -> WinFunN xs y
- unsafeWindowFunction1 :: ByteString -> WinFun1 x y
- partitionBy :: SListI bys => NP (Expression outer commons grp schemas params from) bys -> WindowDefinition outer commons grp schemas params from
- data WindowDefinition (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) where
- WindowDefinition :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (bys :: [NullityType]). SListI bys => NP (Expression outer commons grp schemas params from) bys -> [SortExpression outer commons grp schemas params from] -> WindowDefinition outer commons grp schemas params from
- newtype WindowFunction (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: NullityType) = UnsafeWindowFunction {}
- type WinFun0 (x :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). WindowFunction outer commons grp schemas params from x
- type WinFun1 (x :: NullityType) (y :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x -> WindowFunction outer commons grp schemas params from y
- type WinFunN (xs :: [NullityType]) (y :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). NP (Expression outer commons grp schemas params from) xs -> WindowFunction outer commons grp schemas params from y
- class Aggregate (expr1 :: NullityType -> Type) (exprN :: [k] -> Type) (aggr :: NullityType -> Type) | aggr -> expr1, aggr -> exprN where
- countStar :: aggr (NotNull PGint8)
- count :: expr1 ty -> aggr (NotNull PGint8)
- sum_ :: expr1 (null ty) -> aggr (Null (PGSum ty))
- arrayAgg :: expr1 ty -> aggr (Null (PGvararray ty))
- jsonAgg :: expr1 ty -> aggr (Null PGjson)
- jsonbAgg :: expr1 ty -> aggr (Null PGjsonb)
- bitAnd :: In int PGIntegral => expr1 (null int) -> aggr (Null int)
- bitOr :: In int PGIntegral => expr1 (null int) -> aggr (Null int)
- boolAnd :: expr1 (null PGbool) -> aggr (Null PGbool)
- boolOr :: expr1 (null PGbool) -> aggr (Null PGbool)
- every :: expr1 (null PGbool) -> aggr (Null PGbool)
- max_ :: expr1 (null ty) -> aggr (Null ty)
- min_ :: expr1 (null ty) -> aggr (Null ty)
- avg :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- corr :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- covarPop :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- covarSamp :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrAvgX :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrAvgY :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrCount :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGint8)
- regrIntercept :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrR2 :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrSlope :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrSxx :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrSxy :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- regrSyy :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8)
- stddev :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- stddevPop :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- stddevSamp :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- variance :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- varPop :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- varSamp :: expr1 (null ty) -> aggr (Null (PGAvg ty))
- data Distinction (expr :: kind -> Type) (ty :: kind) :: forall kind. (kind -> Type) -> kind -> Type
- type family PGSum (ty :: PGType) :: PGType where ...
- type family PGAvg (ty :: PGType) :: PGType where ...
- isNotUnknown :: null0 PGbool :--> null1 PGbool
- isUnknown :: null0 PGbool :--> null1 PGbool
- isNotFalse :: null0 PGbool :--> null1 PGbool
- isFalse :: null0 PGbool :--> null1 PGbool
- isNotTrue :: null0 PGbool :--> null1 PGbool
- isTrue :: null0 PGbool :--> null1 PGbool
- isNotDistinctFrom :: Operator (null0 ty) (null1 ty) (NotNull PGbool)
- isDistinctFrom :: Operator (null0 ty) (null1 ty) (Null PGbool)
- notBetweenSymmetric :: BetweenExpr
- betweenSymmetric :: BetweenExpr
- notBetween :: BetweenExpr
- between :: BetweenExpr
- least :: FunctionVar ty ty ty
- greatest :: FunctionVar ty ty ty
- (.>) :: Operator (null0 ty) (null1 ty) (Null PGbool)
- (.<=) :: Operator (null0 ty) (null1 ty) (Null PGbool)
- (.<) :: Operator (null0 ty) (null1 ty) (Null PGbool)
- (.>=) :: Operator (null0 ty) (null1 ty) (Null PGbool)
- (./=) :: Operator (null0 ty) (null1 ty) (Null PGbool)
- (.==) :: Operator (null0 ty) (null1 ty) (Null PGbool)
- type BetweenExpr = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: NullityType). Expression outer commons grp schemas params from ty -> (Expression outer commons grp schemas params from ty, Expression outer commons grp schemas params from ty) -> Condition outer commons grp schemas params from
- nullIf :: FunctionN (NotNull ty ': (NotNull ty ': ([] :: [NullityType]))) (Null ty)
- matchNull :: Expression outer commons grp schemas params from nullty -> (Expression outer commons grp schemas params from (NotNull ty) -> Expression outer commons grp schemas params from nullty) -> Expression outer commons grp schemas params from (Null ty) -> Expression outer commons grp schemas params from nullty
- isNotNull :: Null ty :--> null PGbool
- isNull :: Null ty :--> null PGbool
- fromNull :: Expression outer commons grp schemas params from (NotNull ty) -> Expression outer commons grp schemas params from (Null ty) -> Expression outer commons grp schemas params from (NotNull ty)
- coalesce :: FunctionVar (Null ty) (NotNull ty) (NotNull ty)
- notNull :: NotNull ty :--> Null ty
- null_ :: Expr (Null ty)
- ifThenElse :: Condition outer commons grp schemas params from -> Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty
- caseWhenThenElse :: [(Condition outer commons grp schemas params from, Expression outer commons grp schemas params from ty)] -> Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty
- (.||) :: Operator (null PGbool) (null PGbool) (null PGbool)
- (.&&) :: Operator (null PGbool) (null PGbool) (null PGbool)
- not_ :: null PGbool :--> null PGbool
- false :: Expr (null PGbool)
- true :: Expr (null PGbool)
- type Condition (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) = Expression outer commons grp schemas params from (Null PGbool)
- ceiling_ :: In frac PGFloating => null frac :--> null frac
- round_ :: In frac PGFloating => null frac :--> null frac
- trunc :: In frac PGFloating => null frac :--> null frac
- rem_ :: In int PGIntegral => Operator (null int) (null int) (null int)
- quot_ :: In int PGIntegral => Operator (null int) (null int) (null int)
- atan2_ :: In float PGFloating => FunctionN (null float ': (null float ': ([] :: [NullityType]))) (null float)
- param :: (PGTyped schemas ty, HasParameter n params ty) => Expression outer commons grp schemas params from ty
- class KnownNat n => HasParameter (n :: Nat) (params :: [NullityType]) (ty :: NullityType) | n params -> ty where
- parameter :: TypeExpression schemas ty -> Expression outer commons grp schemas params from ty
- data SortExpression (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) where
- Asc :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (NotNull ty) -> SortExpression outer commons grp schemas params from
- Desc :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (NotNull ty) -> SortExpression outer commons grp schemas params from
- AscNullsFirst :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from
- AscNullsLast :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from
- DescNullsFirst :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from
- DescNullsLast :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from
- class OrderBy (expr :: FromType -> FromType -> Grouping -> SchemasType -> [NullityType] -> FromType -> Type) where
- orderBy :: [SortExpression outer commons grp schemas params from] -> expr outer commons grp schemas params from -> expr outer commons grp schemas params from
- ilike :: Operator (null PGtext) (null PGtext) (Null PGbool)
- like :: Operator (null PGtext) (null PGtext) (Null PGbool)
- charLength :: null PGtext :--> null PGint4
- upper :: null PGtext :--> null PGtext
- lower :: null PGtext :--> null PGtext
- tsHeadline :: In document (PGtext ': (PGjson ': (PGjsonb ': ([] :: [PGType])))) => FunctionN (null document ': (null PGtsquery ': ([] :: [NullityType]))) (null PGtext)
- tsFilter :: FunctionN (null PGtsvector ': (null (PGvararray (NotNull (PGchar 1))) ': ([] :: [NullityType]))) (null PGtsvector)
- tsDelete :: FunctionN (null PGtsvector ': (null (PGvararray (NotNull PGtext)) ': ([] :: [NullityType]))) (null PGtsvector)
- jsonbToTSvector :: FunctionN (null PGjsonb ': (null PGjsonb ': ([] :: [NullityType]))) (null PGtsvector)
- jsonToTSvector :: FunctionN (null PGjson ': (null PGjson ': ([] :: [NullityType]))) (null PGtsvector)
- strip :: null PGtsvector :--> null PGtsvector
- setWeight :: FunctionN (null PGtsvector ': (null (PGchar 1) ': ([] :: [NullityType]))) (null PGtsvector)
- toTSvector :: In ty (PGtext ': (PGjson ': (PGjsonb ': ([] :: [PGType])))) => null ty :--> null PGtsvector
- toTSquery :: null PGtext :--> null PGtsquery
- queryTree :: null PGtsquery :--> null PGtext
- websearchToTSquery :: null PGtext :--> null PGtsquery
- phraseToTSquery :: null PGtext :--> null PGtsquery
- plainToTSquery :: null PGtext :--> null PGtsquery
- numnode :: null PGtsquery :--> null PGint4
- tsvectorLength :: null PGtsvector :--> null PGint4
- arrayToTSvector :: null (PGvararray (NotNull PGtext)) :--> null PGtsvector
- (<->) :: Operator (null PGtsquery) (null PGtsquery) (null PGtsquery)
- (.!) :: null PGtsquery :--> null PGtsquery
- (.|) :: Operator (null PGtsquery) (null PGtsquery) (null PGtsquery)
- (.&) :: Operator (null PGtsquery) (null PGtsquery) (null PGtsquery)
- (@@) :: Operator (null PGtsvector) (null PGtsquery) (Null PGbool)
- interval_ :: Double -> TimeUnit -> Expr (null PGinterval)
- makeTimestamptz :: FunctionN (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGfloat8 ': ([] :: [NullityType]))))))) (null PGtimestamptz)
- makeTimestamp :: FunctionN (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGfloat8 ': ([] :: [NullityType]))))))) (null PGtimestamp)
- makeTime :: FunctionN (null PGint4 ': (null PGint4 ': (null PGfloat8 ': ([] :: [NullityType])))) (null PGtime)
- makeDate :: FunctionN (null PGint4 ': (null PGint4 ': (null PGint4 ': ([] :: [NullityType])))) (null PGdate)
- now :: Expr (null PGtimestamptz)
- localTimestamp :: Expr (null PGtimestamp)
- localTime :: Expr (null PGtime)
- currentTimestamp :: Expr (null PGtimestamptz)
- currentTime :: Expr (null PGtimetz)
- currentDate :: Expr (null PGdate)
- class TimeOp (time :: k) (diff :: k) | time -> diff where
- data TimeUnit
- tsquery :: TypeExpression schemas (null PGtsquery)
- tsvector :: TypeExpression schemas (null PGtsvector)
- fixarray :: All KnownNat dims => TypeExpression schemas pg -> TypeExpression schemas (null (PGfixarray dims pg))
- vararray :: TypeExpression schemas pg -> TypeExpression schemas (null (PGvararray pg))
- jsonb :: TypeExpression schemas (null PGjsonb)
- json :: TypeExpression schemas (null PGjson)
- inet :: TypeExpression schemas (null PGinet)
- uuid :: TypeExpression schemas (null PGuuid)
- interval :: TypeExpression schemas (null PGinterval)
- timeWithTimeZone :: TypeExpression schemas (null PGtimetz)
- time :: TypeExpression schemas (null PGtime)
- date :: TypeExpression schemas (null PGdate)
- timestampWithTimeZone :: TypeExpression schemas (null PGtimestamptz)
- timestamp :: TypeExpression schemas (null PGtimestamp)
- bytea :: TypeExpression schemas (null PGbytea)
- characterVarying :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGvarchar n))
- varchar :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGvarchar n))
- character :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGchar n))
- char :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGchar n))
- text :: TypeExpression schemas (null PGtext)
- money :: TypeExpression schema (null PGmoney)
- doublePrecision :: TypeExpression schemas (null PGfloat8)
- float8 :: TypeExpression schemas (null PGfloat8)
- real :: TypeExpression schemas (null PGfloat4)
- float4 :: TypeExpression schemas (null PGfloat4)
- numeric :: TypeExpression schemas (null PGnumeric)
- bigint :: TypeExpression schemas (null PGint8)
- int8 :: TypeExpression schemas (null PGint8)
- integer :: TypeExpression schemas (null PGint4)
- int :: TypeExpression schemas (null PGint4)
- int4 :: TypeExpression schemas (null PGint4)
- smallint :: TypeExpression schemas (null PGint2)
- int2 :: TypeExpression schemas (null PGint2)
- bool :: TypeExpression schemas (null PGbool)
- typeview :: (Has sch schemas schema, Has vw schema (View view)) => QualifiedAlias sch vw -> TypeExpression schemas (null (PGcomposite view))
- typetable :: (Has sch schemas schema, Has tab schema (Table table)) => QualifiedAlias sch tab -> TypeExpression schemas (null (PGcomposite (TableToRow table)))
- typedef :: (Has sch schemas schema, Has td schema (Typedef ty)) => QualifiedAlias sch td -> TypeExpression schemas (null ty)
- inferredtype :: PGTyped schemas ty => Expression outer common grp schemas params from ty -> Expression outer common grp schemas params from ty
- astype :: TypeExpression schemas ty -> Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty
- cast :: TypeExpression schemas ty1 -> Expression outer commons grp schemas params from ty0 -> Expression outer commons grp schemas params from ty1
- newtype TypeExpression (schemas :: SchemasType) (ty :: NullityType) = UnsafeTypeExpression {}
- class PGTyped (schemas :: SchemasType) (ty :: NullityType) where
- pgtype :: TypeExpression schemas ty
- unsafeFunctionN :: SListI xs => ByteString -> FunctionN xs y
- unsafeFunction :: ByteString -> x :--> y
- unsafeUnaryOpR :: ByteString -> x :--> y
- unsafeUnaryOpL :: ByteString -> x :--> y
- unsafeBinaryOp :: ByteString -> Operator ty0 ty1 ty2
- unsafeFunctionVar :: ByteString -> FunctionVar x0 x1 y
- newtype Expression (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: NullityType) = UnsafeExpression {}
- type Expr (x :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x
- type Operator (x1 :: NullityType) (x2 :: NullityType) (y :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x1 -> Expression outer commons grp schemas params from x2 -> Expression outer commons grp schemas params from y
- type (:-->) (x :: NullityType) (y :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x -> Expression outer commons grp schemas params from y
- type FunctionN (xs :: [NullityType]) (y :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). NP (Expression outer commons grp schemas params from) xs -> Expression outer commons grp schemas params from y
- type FunctionVar (x0 :: NullityType) (x1 :: NullityType) (y :: NullityType) = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). [Expression outer commons grp schemas params from x0] -> Expression outer commons grp schemas params from x1 -> Expression outer commons grp schemas params from y
- class PGSubset (container :: k) where
- type family PG hask :: PGType
- type family LabelsPG hask :: [ConstructorName] where ...
- type family RowPG hask :: RowType where ...
- type family RowOf (record :: [(Symbol, Type)]) :: RowType where ...
- type family NullPG hask :: NullityType where ...
- type family TuplePG hask :: [NullityType] where ...
- type family TupleOf (tuple :: [Type]) :: [NullityType] 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 :: NullityType where ...
- 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
- 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 NullityType
- | PGfixarray [Nat] NullityType
- | PGenum [Symbol]
- | PGcomposite RowType
- | PGtsvector
- | PGtsquery
- | UnsafePGType Symbol
- data NullityType
- type (:=>) (constraint :: k) (ty :: k1) = (,) constraint ty
- data ColumnConstraint
- type ColumnType = (ColumnConstraint, NullityType)
- type ColumnsType = [(Symbol, ColumnType)]
- data TableConstraint
- = Check [Symbol]
- | Unique [Symbol]
- | PrimaryKey [Symbol]
- | ForeignKey [Symbol] Symbol [Symbol]
- type TableConstraints = [(Symbol, TableConstraint)]
- type family Uniquely (key :: [Symbol]) (constraints :: TableConstraints) :: Constraint where ...
- type TableType = (TableConstraints, ColumnsType)
- type RowType = [(Symbol, NullityType)]
- 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 ': ([] :: [PGType]))))))
- type PGFloating = PGfloat4 ': (PGfloat8 ': (PGnumeric ': ([] :: [PGType])))
- type PGIntegral = PGint2 ': (PGint4 ': (PGint8 ': ([] :: [PGType])))
- type family PGTypeOf (ty :: NullityType) :: PGType where ...
- class SamePGType (ty0 :: (Symbol, ColumnType)) (ty1 :: (Symbol, ColumnType))
- type family AllNotNull (columns :: ColumnsType) :: Constraint where ...
- type family NotAllNull (columns :: ColumnsType) :: Constraint where ...
- type family NullifyType (ty :: NullityType) :: NullityType 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 Drop (alias :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ...
- type family Alter (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 ConstraintInvolves (column :: Symbol) (constraint :: TableConstraint) :: Bool where ...
- type family DropIfConstraintsInvolve (column :: Symbol) (constraints :: [(Symbol, TableConstraint)]) :: [(Symbol, TableConstraint)] where ...
- data SchemumType
- 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 ': ([] :: [PGType])))
- type PGJsonType = PGjson ': (PGjsonb ': ([] :: [PGType]))
- class IsNotElem (x :: k) (isElem :: k1)
- class AllUnique (xs :: [(Symbol, a)])
- renderAliased :: (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)) :: forall k. (k -> Type) -> (Symbol, k) -> Type 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) ': ([] :: [(Symbol, k)]))
- class HasIn (fields :: k) (field :: k1)
- class All KnownSymbol aliases => HasAll (aliases :: [Symbol]) (fields :: [(Symbol, kind)]) (subfields :: [(Symbol, kind)]) | aliases fields -> subfields
- class IsQualified (table :: Symbol) (column :: Symbol) expression where
- data QualifiedAlias (qualifier :: Symbol) (alias :: Symbol) = QualifiedAlias
- (*:) :: f x -> f y -> NP f (x ': (y ': ([] :: [k])))
- single :: p x0 x1 -> AlignedList p x0 x1
- mapAligned :: (forall (z0 :: k) (z1 :: k). p z0 z1 -> q z0 z1) -> AlignedList p x0 x1 -> AlignedList q x0 x1
- extractList :: (forall (a0 :: k) (a1 :: k). p a0 a1 -> b) -> AlignedList p x0 x1 -> [b]
- disjoin :: 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
- data AlignedList (p :: k -> k -> Type) (x0 :: k) (x1 :: k) :: forall k. (k -> k -> Type) -> k -> k -> Type where
- Done :: forall k (p :: k -> k -> Type) (x0 :: k) (x1 :: k). AlignedList p x0 x0
- (:>>) :: forall k (p :: k -> k -> Type) (x0 :: k) (x1 :: k) (x2 :: k). p x0 x2 -> AlignedList p x2 x1 -> AlignedList p x0 x1
- type family Elem (x :: k) (xs :: [k]) :: Bool where ...
- type family In (x :: t) (xs :: [t]) :: Constraint where ...
- type family Length (xs :: [k]) :: Nat where ...
- printSQL :: (RenderSQL sql, MonadIO io) => sql -> io ()
- class RenderSQL sql where
- renderSQL :: sql -> ByteString
- type Pool = Pool
- module Control.Algebra
Documentation
data Squeal (schemas :: SchemasType) m k where Source #
Constructors
| ManipulateParams :: ToParams x params => Manipulation '[] schemas params ys -> x -> (K Result ys -> m k) -> Squeal schemas m k | |
| TraversePrepared :: (ToParams x params, Traversable list) => Manipulation '[] schemas params ys -> list x -> (list (K Result ys) -> m k) -> Squeal schemas m k | |
| TraversePrepared_ :: (ToParams x params, Foldable list) => Manipulation '[] schemas params '[] -> list x -> m k -> Squeal schemas m k |
Instances
| HFunctor (Squeal schemas :: (Type -> Type) -> Type -> Type) Source # | |
| Effect (Squeal schemas :: (Type -> Type) -> Type -> Type) Source # | |
| (MonadUnliftIO m, Algebra sig m) => Algebra ((Squeal schemas :: (Type -> Type) -> Type -> Type) :+: sig) (SquealC schemas m) Source # | |
| Functor m => Functor (Squeal schemas m) Source # | |
manipulateParams :: (Has (Squeal schemas) sig m, ToParams x params) => Manipulation '[] schemas params ys -> x -> m (K Result ys) Source #
See manipulateParams from squeal-postgresql.
manipulateParams_ :: (Has (Squeal schemas) sig m, ToParams x params) => Manipulation '[] schemas params ys -> x -> m () Source #
See manipulateParams_ from squeal-postgresql.
manipulate :: Has (Squeal schemas) sig m => Manipulation '[] schemas '[] ys -> m (K Result ys) Source #
See manipulate from squeal-postgresql.
manipulate_ :: Has (Squeal schemas) sig m => Manipulation '[] schemas '[] ys -> m () Source #
See manipulate_ from squeal-postgresql.
runQueryParams :: (Has (Squeal schemas) sig m, ToParams x params) => Query '[] '[] schemas params ys -> x -> m (K Result ys) Source #
See runQueryParams from squeal-postgresql.
runQuery :: Has (Squeal schemas) sig m => Query '[] '[] schemas '[] ys -> m (K Result ys) Source #
See runQuery from squeal-postgresql.
traversePrepared :: (ToParams x params, Traversable list, Has (Squeal schemas) sig m) => Manipulation '[] schemas params ys -> list x -> m (list (K Result ys)) Source #
See traversePrepared from squeal-postgresql.
forPrepared :: (ToParams x params, Traversable list, Has (Squeal schemas) sig m) => list x -> Manipulation '[] schemas params ys -> m (list (K Result ys)) Source #
See forPrepared from squeal-postgresql.
traversePrepared_ :: (ToParams x params, Foldable list, Has (Squeal schemas) sig m) => Manipulation '[] schemas params '[] -> list x -> m () Source #
See traversePrepared_ from squeal-postgresql.
forPrepared_ :: (ToParams x params, Foldable list, Has (Squeal schemas) sig m) => list x -> Manipulation '[] schemas params '[] -> m () Source #
See forPrepared_ from squeal-postgresql.
Pool
type DBConnection (schemas :: SchemasType) = K Connection schemas Source #
newtype SquealPool schemas m k Source #
Constructors
| GetSquealPool (Pool (DBConnection schemas) -> m k) |
Instances
| HFunctor (SquealPool schemas :: (Type -> Type) -> Type -> Type) Source # | |
Defined in Control.Effect.Squeal Methods hmap :: Functor m => (forall x. m x -> n x) -> SquealPool schemas m a -> SquealPool schemas n a # | |
| Effect (SquealPool schemas :: (Type -> Type) -> Type -> Type) Source # | |
Defined in Control.Effect.Squeal Methods thread :: (Functor ctx, Monad m) => ctx () -> (forall x. ctx (m x) -> n (ctx x)) -> SquealPool schemas m a -> SquealPool schemas n (ctx a) # | |
| Functor m => Functor (SquealPool schemas m) Source # | |
Defined in Control.Effect.Squeal Methods fmap :: (a -> b) -> SquealPool schemas m a -> SquealPool schemas m b # (<$) :: a -> SquealPool schemas m b -> SquealPool schemas m a # | |
getSquealPool :: Has (SquealPool schemas) sig m => m (Pool (DBConnection schemas)) Source #
Reexports
class IsLabel (x :: Symbol) a where #
Instances
| alias1 ~ alias2 => IsLabel alias1 (Alias alias2) | |
Defined in Squeal.PostgreSQL.Alias | |
| (HasUnique rel rels cols, Has col cols ty, by ~ (,) rel col) => IsLabel col (By rels by) | |
Defined in Squeal.PostgreSQL.Query | |
| (q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.Alias Methods fromLabel :: QualifiedAlias q' a' # | |
| (HasUnique rel rels cols, Has col cols ty, bys ~ ((,) rel col ': ([] :: [(Symbol, Symbol)]))) => IsLabel col (NP (By rels) bys) | |
Defined in Squeal.PostgreSQL.Query | |
| (HasUnique tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons Ungrouped schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons (Grouped bys) schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons Ungrouped schemas params from) column # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons (Grouped bys) schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons (Grouped bys) schemas params from) column # | |
| aliases ~ (alias ': ([] :: [Symbol])) => IsLabel alias (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.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.Alias Methods fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) # | |
| (HasUnique tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (Selection outer commons Ungrouped schemas params from row1) | |
Defined in Squeal.PostgreSQL.Query | |
| (HasUnique tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)])), GroupedBy tab col bys) => IsLabel col (Selection outer commons (Grouped bys) schemas params from row1) | |
Defined in Squeal.PostgreSQL.Query | |
| (HasUnique tab (Join outer from) row, Has col row ty) => IsLabel col (Expression outer commons Ungrouped schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression outer commons Ungrouped schemas params from ty # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys) => IsLabel col (Expression outer commons (Grouped bys) schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression outer commons (Grouped bys) schemas params from ty # | |
newtype K a (b :: k) :: forall k. Type -> k -> Type #
The constant type functor.
Like Constant, but kind-polymorphic
in its second argument and with a shorter name.
Constructors
| K a |
Instances
| 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 # 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]) :: forall k. (k -> Type) -> [k] -> Type 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) (b :: [k]). NP a ([] :: [k]) | |
| (:*) :: forall k (a :: k -> Type) (b :: [k]) (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 ': ([] :: [(Symbol, Symbol)]))) => IsQualified rel col (NP (By rels) bys) | |
| (Has tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| HTrans (NP :: (k1 -> Type) -> [k1] -> Type) (NP :: (k2 -> Type) -> [k2] -> Type) | |
| HSequence (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP Methods hsequence' :: (SListIN NP xs, Applicative f) => NP (f :.: g) xs -> f (NP g xs) # hctraverse' :: (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' :: (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_ :: (AllN NP c xs, Applicative g) => proxy c -> (forall (a :: k0). c a => f a -> g ()) -> NP f xs -> g () # htraverse_ :: (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) ': ([] :: [(Symbol, k)]))) => Aliasable alias (expression ty) (NP (Aliased expression) tys) | |
| Additional (NP expr :: [a] -> Type) | |
| Aggregate (Distinction (Expression outer commons Ungrouped schemas params from)) (Distinction (NP (Expression outer commons Ungrouped schemas params from)) :: [NullityType] -> Type) (Expression outer commons (Grouped bys) schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # count :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # sum_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGSum ty)) # arrayAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null (PGvararray ty)) # jsonAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjson) # jsonbAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # bitOr :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # boolAnd :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # boolOr :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # every :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # max_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # min_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # avg :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # corr :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarPop :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarSamp :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgX :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgY :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrCount :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGint8) # regrIntercept :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrR2 :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSlope :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxx :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSyy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # stddev :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # variance :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # | |
| (HasUnique rel rels cols, Has col cols ty, bys ~ ((,) rel col ': ([] :: [(Symbol, Symbol)]))) => IsLabel col (NP (By rels) bys) | |
Defined in Squeal.PostgreSQL.Query | |
| (HasUnique tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons Ungrouped schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons (Grouped bys) schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| aliases ~ (alias ': ([] :: [Symbol])) => IsLabel alias (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Alias | |
| labels ~ (label ': ([] :: [Symbol])) => IsPGlabel label (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Schema | |
| Aggregate (Expression outer commons grp schemas params from) (NP (Expression outer commons grp schemas params from) :: [NullityType] -> Type) (WindowFunction outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: WindowFunction outer commons grp schemas params from (NotNull PGint8) # count :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (NotNull PGint8) # sum_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGSum ty)) # arrayAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null (PGvararray ty)) # jsonAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjson) # jsonbAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # bitOr :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # boolAnd :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # boolOr :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # every :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # max_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # min_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # avg :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # corr :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarPop :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarSamp :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgX :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgY :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrCount :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGint8) # regrIntercept :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrR2 :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSlope :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxx :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSyy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # stddev :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # variance :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # | |
| 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.Schema Methods renderSQL :: NP PGlabel labels -> ByteString # | |
| All KnownSymbol aliases => RenderSQL (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Alias Methods renderSQL :: NP Alias aliases -> ByteString # | |
| SListI tys => RenderSQL (Distinction (NP (Expression outer commons grp schemas params from)) tys) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (NP (Expression outer commons grp schemas params from)) tys -> ByteString # | |
| type Same (NP :: (k1 -> Type) -> [k1] -> Type) | |
| type UnProd (NP :: (k -> Type) -> [k] -> Type) | |
| type Prod (NP :: (k -> Type) -> [k] -> Type) | |
| type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a | |
Defined in Data.SOP.NP | |
| type SListIN (NP :: (k -> Type) -> [k] -> Type) | |
Defined in Data.SOP.NP | |
| type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) | |
Defined in Data.SOP.NP | |
| type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) | |
Defined in Data.SOP.NP | |
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
| :: Migratory p | |
| => ByteString | connection string |
| -> AlignedList (Migration p) db0 db1 | migrations |
| -> IO () |
defaultMain creates a simple executable
from a connection string and a list of Migrations.
pureMigration :: Migration Definition schemas0 schemas1 -> Migration (Terminally PQ IO) schemas0 schemas1 #
A pureMigration turns a Migration involving only pure SQL
Definitions into a Migration that may be combined with arbitrary IO.
terminally :: Functor (trans x0 x1 monad) => trans x0 x1 monad ignore -> Terminally trans monad x0 x1 #
terminally ignores the output of a computation, returning () and
wrapping it up into a Terminally. You can lift an action in the base monad
by using terminally . lift.
data Migration (p :: k -> k -> Type) (schemas0 :: k) (schemas1 :: k) :: forall k. (k -> k -> Type) -> k -> k -> Type #
A Migration is a named "isomorphism" over a given category.
It should contain an inverse pair of up and down
instructions and a unique name.
Constructors
| Migration | |
Instances
| Generic (Migration p schemas0 schemas1) | |
| type Rep (Migration p schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Migration type Rep (Migration p schemas0 schemas1) = D1 (MetaData "Migration" "Squeal.PostgreSQL.Migration" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "Migration" PrefixI True) (S1 (MetaSel (Just "name") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Text) :*: (S1 (MetaSel (Just "up") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (p schemas0 schemas1)) :*: S1 (MetaSel (Just "down") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (p schemas1 schemas0))))) | |
class Category p => Migratory (p :: SchemasType -> SchemasType -> Type) where #
A Migratory p is a Category for which one can execute or rewind
an AlignedList of Migrations over p. This includes the category of pure
SQL Definitions and the category of impure Terminally PQ IO actions.
Methods
migrateUp :: AlignedList (Migration p) schemas0 schemas1 -> PQ schemas0 schemas1 IO () #
Run an AlignedList of Migrations.
Create the MigrationsTable as public.schema_migrations if it does not already exist.
In one transaction, for each each Migration query to see if the Migration has been executed;
if not, up the Migration and insert its name in the MigrationsTable.
migrateDown :: AlignedList (Migration p) schemas0 schemas1 -> PQ schemas1 schemas0 IO () #
Rewind an AlignedList of Migrations.
Create the MigrationsTable as public.schema_migrations if it does not already exist.
In one transaction, for each each Migration query to see if the Migration has been executed;
if so, down the Migration and delete its name in the MigrationsTable.
Instances
| Migratory Definition | |
Defined in Squeal.PostgreSQL.Migration Methods migrateUp :: AlignedList (Migration Definition) schemas0 schemas1 -> PQ schemas0 schemas1 IO () # migrateDown :: AlignedList (Migration Definition) schemas0 schemas1 -> PQ schemas1 schemas0 IO () # | |
| Migratory (Terminally PQ IO) | |
Defined in Squeal.PostgreSQL.Migration Methods migrateUp :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas0 schemas1 IO () # migrateDown :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas1 schemas0 IO () # | |
newtype Terminally (trans :: k1 -> k2 -> k -> Type -> Type) (monad :: k) (x0 :: k1) (x1 :: k2) :: forall k k1 k2. (k1 -> k2 -> k -> Type -> Type) -> k -> k1 -> k2 -> Type #
Terminally turns an indexed monad transformer and the monad it transforms
into a category by restricting the return type to () and permuting the type variables.
This is similar to how applying a monad to () yields a monoid.
Since a Terminally action has a trivial return value, the only reason
to run one is for the side effects, in particular database and other IO effects.
Constructors
| Terminally | |
Fields
| |
Instances
| (IndexedMonadTransPQ trans, Monad monad, forall (x0 :: SchemasType) (x1 :: SchemasType). x0 ~ x1 => Monad (trans x0 x1 monad)) => Category (Terminally trans monad :: SchemasType -> SchemasType -> Type) | |
Defined in Squeal.PostgreSQL.Migration Methods id :: Terminally trans monad a a # (.) :: Terminally trans monad b c -> Terminally trans monad a b -> Terminally trans monad a c # | |
| Migratory (Terminally PQ IO) | |
Defined in Squeal.PostgreSQL.Migration Methods migrateUp :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas0 schemas1 IO () # migrateDown :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas1 schemas0 IO () # | |
| Generic (Terminally trans monad x0 x1) | |
Defined in Squeal.PostgreSQL.Migration Associated Types type Rep (Terminally trans monad x0 x1) :: Type -> Type # Methods from :: Terminally trans monad x0 x1 -> Rep (Terminally trans monad x0 x1) x # to :: Rep (Terminally trans monad x0 x1) x -> Terminally trans monad x0 x1 # | |
| type Rep (Terminally trans monad x0 x1) | |
Defined in Squeal.PostgreSQL.Migration type Rep (Terminally trans monad x0 x1) = D1 (MetaData "Terminally" "Squeal.PostgreSQL.Migration" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Terminally" PrefixI True) (S1 (MetaSel (Just "runTerminally") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (trans x0 x1 monad ())))) | |
type MigrationsTable = (("migrations_unique_name" ::: Unique ("name" ': ([] :: [Symbol]))) ': ([] :: [(Symbol, TableConstraint)])) :=> (("name" ::: (NoDef :=> NotNull PGtext)) ': (("executed_at" ::: (Def :=> NotNull PGtimestamptz)) ': ([] :: [(Symbol, (ColumnConstraint, NullityType))]))) #
The TableType for a Squeal migration.
longRunningMode :: TransactionMode #
TransactionMode with a Serializable IsolationLevel,
ReadOnly AccessMode and Deferrable DeferrableMode.
This mode is well suited for long-running reports or backups.
rollback :: Manipulation_ schemas () () #
ROLLBACK a transaction.
commit :: Manipulation_ schemas () () #
COMMIT a transaction.
begin :: TransactionMode -> Manipulation_ schemas () () #
BEGIN a transaction.
Arguments
| :: (MonadUnliftIO tx, MonadPQ schemas tx) | |
| => tx x | run inside an ephemeral transaction |
| -> tx x |
Run a computation ephemerally in defaultMode.
Arguments
| :: (MonadUnliftIO tx, MonadPQ schemas tx) | |
| => TransactionMode | |
| -> tx x | run inside an ephemeral transaction |
| -> tx x |
Run a computation ephemerally;
Like transactionally but always rollback, useful in testing.
Arguments
| :: (MonadUnliftIO tx, MonadPQ schemas tx) | |
| => TransactionMode | |
| -> tx x | run inside a transaction |
| -> tx x |
Arguments
| :: (MonadUnliftIO tx, MonadPQ schemas tx) | |
| => tx x | run inside a transaction |
| -> tx x |
Run a computation transactionally_, in defaultMode.
Arguments
| :: (MonadUnliftIO tx, MonadPQ schemas tx) | |
| => TransactionMode | |
| -> tx x | run inside a transaction |
| -> tx x |
Run a computation transactionally;
first begin,
then run the computation,
onException rollback and rethrow the exception,
otherwise commit and return the result.
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.Transaction Methods (==) :: TransactionMode -> TransactionMode -> Bool # (/=) :: TransactionMode -> TransactionMode -> Bool # | |
| Show TransactionMode | |
Defined in Squeal.PostgreSQL.Transaction Methods showsPrec :: Int -> TransactionMode -> ShowS # show :: TransactionMode -> String # showList :: [TransactionMode] -> ShowS # | |
| RenderSQL TransactionMode | Render a |
Defined in Squeal.PostgreSQL.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.Transaction Methods (==) :: IsolationLevel -> IsolationLevel -> Bool # (/=) :: IsolationLevel -> IsolationLevel -> Bool # | |
| Show IsolationLevel | |
Defined in Squeal.PostgreSQL.Transaction Methods showsPrec :: Int -> IsolationLevel -> ShowS # show :: IsolationLevel -> String # showList :: [IsolationLevel] -> ShowS # | |
| RenderSQL IsolationLevel | Render an |
Defined in Squeal.PostgreSQL.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.Transaction | |
| Show AccessMode | |
Defined in Squeal.PostgreSQL.Transaction Methods showsPrec :: Int -> AccessMode -> ShowS # show :: AccessMode -> String # showList :: [AccessMode] -> ShowS # | |
| RenderSQL AccessMode | Render an |
Defined in Squeal.PostgreSQL.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.Transaction Methods (==) :: DeferrableMode -> DeferrableMode -> Bool # (/=) :: DeferrableMode -> DeferrableMode -> Bool # | |
| Show DeferrableMode | |
Defined in Squeal.PostgreSQL.Transaction Methods showsPrec :: Int -> DeferrableMode -> ShowS # show :: DeferrableMode -> String # showList :: [DeferrableMode] -> ShowS # | |
| RenderSQL DeferrableMode | Render a |
Defined in Squeal.PostgreSQL.Transaction Methods renderSQL :: DeferrableMode -> ByteString # | |
The Literal class allows embedding a Haskell value directly
as an Expression using literal.
>>>printSQL (literal 'a')E'a'
>>>printSQL (literal (1 :: Double))1.0
>>>printSQL (literal (Json [1 :: Double, 2]))('[1.0,2.0]' :: json)
>>>printSQL (literal (Enumerated GT))'GT'
Instances
| Literal Bool | |
| Literal Char | |
| Literal Double | |
| Literal Float | |
| Literal Int16 | |
| Literal Int32 | |
| Literal Int64 | |
| Literal Text | |
| Literal Text | |
| Literal String | |
| ToJSON hask => Literal (Json hask) | |
| ToJSON hask => Literal (Jsonb hask) | |
| ToParam (Enumerated enum) (PG (Enumerated enum)) => Literal (Enumerated enum) | |
Defined in Squeal.PostgreSQL.Expression.Literal Methods literal :: Enumerated enum -> Expr (null (PG (Enumerated enum))) # | |
Arguments
| :: MonadUnliftIO io | |
| => Pool (K Connection schemas) | 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
| :: MonadUnliftIO io | |
| => Pool (K Connection schemas) | pool |
| -> PQ schemas schemas 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
| :: 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 schemas)) |
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.
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.
okResult :: MonadIO io => K Result row -> io () #
Check if a Result's status is either CommandOk
or TuplesOk otherwise throw a PQException.
resultErrorCode :: MonadIO io => K Result results -> io (Maybe ByteString) #
Returns the error code most recently generated by an operation on the connection.
https://www.postgresql.org/docs/current/static/errcodes-appendix.html
resultErrorMessage :: MonadIO io => K Result results -> io (Maybe ByteString) #
Returns the error message most recently generated by an operation on the connection.
resultStatus :: MonadIO io => K Result results -> io ExecStatus #
Returns the result status of the command.
ntuples :: MonadIO io => K Result columns -> io Row #
Returns the number of rows (tuples) in the query result.
liftResult :: MonadIO io => (Result -> IO x) -> K Result results -> io x #
Lifts actions on results from LibPQ.
Get the first row if possible from a Result.
Get all rows from a Result.
Get a row corresponding to a given row number from a Result,
throwing an exception if the row number is out of bounds.
evalPQ :: Functor m => PQ schemas0 schemas1 m x -> K Connection schemas0 -> m x #
Evaluate a PQ and discard the Connection but keep the result.
execPQ :: Functor m => PQ schemas0 schemas1 m x -> K Connection schemas0 -> m (K Connection schemas1) #
Execute a PQ and discard the result but keep the Connection.
runPQ :: Functor m => PQ schemas0 schemas1 m x -> K Connection schemas0 -> m (x, K Connection schemas1) #
Run a PQ and keep the result and the Connection.
lowerConnection :: K Connection (schema ': schemas) -> K Connection schemas #
Safely lowerConnection to a smaller schema.
withConnection :: MonadUnliftIO io => ByteString -> PQ schemas0 schemas1 io x -> io x #
finish :: MonadIO io => K Connection schemas -> io () #
Closes the connection to the server.
Arguments
| :: MonadIO io | |
| => ByteString | conninfo |
| -> io (K Connection schemas) |
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 Schema = '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint2]]>>>:set -XTypeApplications>>>:set -XOverloadedStrings>>>conn <- connectdb @Schema "host=localhost port=5432 dbname=exampledb"
Note that, for now, squeal doesn't offer any protection from connecting with the wrong schema!
newtype PQ (schemas0 :: SchemasType) (schemas1 :: 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.PQ Methods pqAp :: Monad m => PQ schemas0 schemas1 m (x -> y) -> PQ schemas1 schemas2 m x -> PQ schemas0 schemas2 m y # pqJoin :: Monad m => PQ schemas0 schemas1 m (PQ schemas1 schemas2 m y) -> PQ schemas0 schemas2 m y # pqBind :: Monad m => (x -> PQ schemas1 schemas2 m y) -> PQ schemas0 schemas1 m x -> PQ schemas0 schemas2 m y # pqThen :: Monad m => PQ schemas1 schemas2 m y -> PQ schemas0 schemas1 m x -> PQ schemas0 schemas2 m y # pqAndThen :: Monad m => (y -> PQ schemas1 schemas2 m z) -> (x -> PQ schemas0 schemas1 m y) -> x -> PQ schemas0 schemas2 m z # define :: MonadIO io => Definition schemas0 schemas1 -> PQ schemas0 schemas1 io () # | |
| schemas0 ~ schemas1 => MFunctor (PQ schemas0 schemas1 :: (Type -> Type) -> Type -> Type) | |
| (MonadIO io, schemas0 ~ schemas, schemas1 ~ schemas) => MonadPQ schemas (PQ schemas0 schemas1 io) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> PQ schemas0 schemas1 io (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> PQ schemas0 schemas1 io () # manipulate :: Manipulation [] schemas [] ys -> PQ schemas0 schemas1 io (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> PQ schemas0 schemas1 io () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> PQ schemas0 schemas1 io (K Result ys) # runQuery :: Query [] [] schemas [] ys -> PQ schemas0 schemas1 io (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> PQ schemas0 schemas1 io (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> PQ schemas0 schemas1 io (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> PQ schemas0 schemas1 io () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> PQ schemas0 schemas1 io () # liftPQ :: (Connection -> IO a) -> PQ schemas0 schemas1 io a # | |
| schemas0 ~ schemas1 => MonadTrans (PQ schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.PQ | |
| schemas0 ~ schemas1 => MMonad (PQ schemas0 schemas1) | |
| (Monad m, schemas0 ~ schemas1) => Monad (PQ schemas0 schemas1 m) | |
Defined in Squeal.PostgreSQL.PQ | |
| Monad m => Functor (PQ schemas0 schemas1 m) | |
| (Monad m, schemas0 ~ schemas1) => MonadFail (PQ schemas0 schemas1 m) | |
Defined in Squeal.PostgreSQL.PQ | |
| (Monad m, schemas0 ~ schemas1) => Applicative (PQ schemas0 schemas1 m) | |
Defined in Squeal.PostgreSQL.PQ Methods pure :: a -> PQ schemas0 schemas1 m a # (<*>) :: PQ schemas0 schemas1 m (a -> b) -> PQ schemas0 schemas1 m a -> PQ schemas0 schemas1 m b # liftA2 :: (a -> b -> c) -> PQ schemas0 schemas1 m a -> PQ schemas0 schemas1 m b -> PQ schemas0 schemas1 m c # (*>) :: PQ schemas0 schemas1 m a -> PQ schemas0 schemas1 m b -> PQ schemas0 schemas1 m b # (<*) :: PQ schemas0 schemas1 m a -> PQ schemas0 schemas1 m b -> PQ schemas0 schemas1 m a # | |
| (MonadIO m, schema0 ~ schema1) => MonadIO (PQ schema0 schema1 m) | |
Defined in Squeal.PostgreSQL.PQ | |
| (MonadUnliftIO m, schemas0 ~ schemas1) => MonadUnliftIO (PQ schemas0 schemas1 m) | |
Defined in Squeal.PostgreSQL.PQ | |
| Migratory (Terminally PQ IO) | |
Defined in Squeal.PostgreSQL.Migration Methods migrateUp :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas0 schemas1 IO () # migrateDown :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas1 schemas0 IO () # | |
class IndexedMonadTransPQ (pq :: SchemasType -> SchemasType -> (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, IndexedMonadTransPQ is a class for indexed monad transformers that
support running Definitions using define.
Methods
pqAp :: Monad m => pq schemas0 schemas1 m (x -> y) -> pq schemas1 schemas2 m x -> pq schemas0 schemas2 m y #
indexed analog of <*>
pqJoin :: Monad m => pq schemas0 schemas1 m (pq schemas1 schemas2 m y) -> pq schemas0 schemas2 m y #
indexed analog of join
pqBind :: Monad m => (x -> pq schemas1 schemas2 m y) -> pq schemas0 schemas1 m x -> pq schemas0 schemas2 m y #
indexed analog of =<<
pqThen :: Monad m => pq schemas1 schemas2 m y -> pq schemas0 schemas1 m x -> pq schemas0 schemas2 m y #
indexed analog of flipped >>
pqAndThen :: Monad m => (y -> pq schemas1 schemas2 m z) -> (x -> pq schemas0 schemas1 m y) -> x -> pq schemas0 schemas2 m z #
indexed analog of <=<
define :: MonadIO io => Definition schemas0 schemas1 -> pq schemas0 schemas1 io () #
Run a Definition with exec.
It should be functorial in effect.
define id = return ()
define (statement1 >>> statement2) = define statement1 & pqThen (define statement2)
Instances
| IndexedMonadTransPQ PQ | |
Defined in Squeal.PostgreSQL.PQ Methods pqAp :: Monad m => PQ schemas0 schemas1 m (x -> y) -> PQ schemas1 schemas2 m x -> PQ schemas0 schemas2 m y # pqJoin :: Monad m => PQ schemas0 schemas1 m (PQ schemas1 schemas2 m y) -> PQ schemas0 schemas2 m y # pqBind :: Monad m => (x -> PQ schemas1 schemas2 m y) -> PQ schemas0 schemas1 m x -> PQ schemas0 schemas2 m y # pqThen :: Monad m => PQ schemas1 schemas2 m y -> PQ schemas0 schemas1 m x -> PQ schemas0 schemas2 m y # pqAndThen :: Monad m => (y -> PQ schemas1 schemas2 m z) -> (x -> PQ schemas0 schemas1 m y) -> x -> PQ schemas0 schemas2 m z # define :: MonadIO io => Definition schemas0 schemas1 -> PQ schemas0 schemas1 io () # | |
class Monad pq => MonadPQ (schemas :: SchemasType) (pq :: Type -> Type) | pq -> schemas where #
MonadPQ is an mtl style constraint, similar to
MonadState, for using LibPQ to
manipulateParamsruns aManipulationwith params from a type with aToParamsconstraint. It callsexecParamsand doesn't afraid of anything.manipulateParams_is likemanipulateParamsfor a returning-free statement.manipulateis likemanipulateParamsfor a parameter-free statement.manipulate_is likemanipulatefor a returning-free statement.runQueryParamsis likemanipulateParamsfor query statements.runQueryis likerunQueryParamsfor a parameter-free statement.traversePreparedhas the same type signature as a composition oftraverseandmanipulateParamsbut provides an optimization by preparing the statement withprepareand then traversing aTraversablecontainer withexecPrepared. The temporary prepared statement is then deallocated.forPreparedis a flippedtraversePreparedtraversePrepared_is liketraversePreparedbut works onFoldablecontainers for a returning-free statement.forPrepared_is a flippedtraversePrepared_.liftPQlets you lift actions fromLibPQthat require a connection into your monad.
To define an instance, you can minimally define only manipulateParams,
traversePrepared, traversePrepared_ and liftPQ. Monad transformers get
a default instance.
Minimal complete definition
Nothing
Methods
liftPQ :: (Connection -> IO a) -> pq a #
Instances
| MonadPQ schemas m => MonadPQ schemas (MaybeT m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> MaybeT m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> MaybeT m () # manipulate :: Manipulation [] schemas [] ys -> MaybeT m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> MaybeT m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> MaybeT m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> MaybeT m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> MaybeT m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> MaybeT m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> MaybeT m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> MaybeT m () # liftPQ :: (Connection -> IO a) -> MaybeT m a # | |
| (Monoid w, MonadPQ schemas m) => MonadPQ schemas (WriterT w m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> WriterT w m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> WriterT w m () # manipulate :: Manipulation [] schemas [] ys -> WriterT w m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> WriterT w m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> WriterT w m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> WriterT w m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> WriterT w m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> WriterT w m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> WriterT w m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> WriterT w m () # liftPQ :: (Connection -> IO a) -> WriterT w m a # | |
| (Monoid w, MonadPQ schemas m) => MonadPQ schemas (WriterT w m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> WriterT w m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> WriterT w m () # manipulate :: Manipulation [] schemas [] ys -> WriterT w m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> WriterT w m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> WriterT w m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> WriterT w m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> WriterT w m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> WriterT w m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> WriterT w m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> WriterT w m () # liftPQ :: (Connection -> IO a) -> WriterT w m a # | |
| MonadPQ schemas m => MonadPQ schemas (StateT s m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> StateT s m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> StateT s m () # manipulate :: Manipulation [] schemas [] ys -> StateT s m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> StateT s m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> StateT s m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> StateT s m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> StateT s m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> StateT s m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> StateT s m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> StateT s m () # liftPQ :: (Connection -> IO a) -> StateT s m a # | |
| MonadPQ schemas m => MonadPQ schemas (StateT s m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> StateT s m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> StateT s m () # manipulate :: Manipulation [] schemas [] ys -> StateT s m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> StateT s m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> StateT s m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> StateT s m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> StateT s m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> StateT s m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> StateT s m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> StateT s m () # liftPQ :: (Connection -> IO a) -> StateT s m a # | |
| MonadPQ schemas m => MonadPQ schemas (IdentityT m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> IdentityT m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> IdentityT m () # manipulate :: Manipulation [] schemas [] ys -> IdentityT m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> IdentityT m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> IdentityT m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> IdentityT m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> IdentityT m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> IdentityT m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> IdentityT m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> IdentityT m () # liftPQ :: (Connection -> IO a) -> IdentityT m a # | |
| MonadPQ schemas m => MonadPQ schemas (ExceptT e m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> ExceptT e m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> ExceptT e m () # manipulate :: Manipulation [] schemas [] ys -> ExceptT e m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> ExceptT e m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> ExceptT e m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> ExceptT e m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> ExceptT e m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> ExceptT e m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> ExceptT e m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> ExceptT e m () # liftPQ :: (Connection -> IO a) -> ExceptT e m a # | |
| (MonadIO io, schemas0 ~ schemas, schemas1 ~ schemas) => MonadPQ schemas (PQ schemas0 schemas1 io) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> PQ schemas0 schemas1 io (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> PQ schemas0 schemas1 io () # manipulate :: Manipulation [] schemas [] ys -> PQ schemas0 schemas1 io (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> PQ schemas0 schemas1 io () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> PQ schemas0 schemas1 io (K Result ys) # runQuery :: Query [] [] schemas [] ys -> PQ schemas0 schemas1 io (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> PQ schemas0 schemas1 io (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> PQ schemas0 schemas1 io (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> PQ schemas0 schemas1 io () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> PQ schemas0 schemas1 io () # liftPQ :: (Connection -> IO a) -> PQ schemas0 schemas1 io a # | |
| MonadPQ schemas m => MonadPQ schemas (ReaderT r m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> ReaderT r m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> ReaderT r m () # manipulate :: Manipulation [] schemas [] ys -> ReaderT r m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> ReaderT r m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> ReaderT r m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> ReaderT r m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> ReaderT r m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> ReaderT r m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> ReaderT r m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> ReaderT r m () # liftPQ :: (Connection -> IO a) -> ReaderT r m a # | |
| MonadPQ schemas m => MonadPQ schemas (ContT r m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> ContT r m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> ContT r m () # manipulate :: Manipulation [] schemas [] ys -> ContT r m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> ContT r m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> ContT r m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> ContT r m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> ContT r m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> ContT r m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> ContT r m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> ContT r m () # liftPQ :: (Connection -> IO a) -> ContT r m a # | |
| (Monoid w, MonadPQ schemas m) => MonadPQ schemas (RWST r w s m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> RWST r w s m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> RWST r w s m () # manipulate :: Manipulation [] schemas [] ys -> RWST r w s m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> RWST r w s m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> RWST r w s m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> RWST r w s m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> RWST r w s m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> RWST r w s m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> RWST r w s m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> RWST r w s m () # liftPQ :: (Connection -> IO a) -> RWST r w s m a # | |
| (Monoid w, MonadPQ schemas m) => MonadPQ schemas (RWST r w s m) | |
Defined in Squeal.PostgreSQL.PQ Methods manipulateParams :: ToParams x params => Manipulation [] schemas params ys -> x -> RWST r w s m (K Result ys) # manipulateParams_ :: ToParams x params => Manipulation [] schemas params [] -> x -> RWST r w s m () # manipulate :: Manipulation [] schemas [] ys -> RWST r w s m (K Result ys) # manipulate_ :: Manipulation [] schemas [] [] -> RWST r w s m () # runQueryParams :: ToParams x params => Query [] [] schemas params ys -> x -> RWST r w s m (K Result ys) # runQuery :: Query [] [] schemas [] ys -> RWST r w s m (K Result ys) # traversePrepared :: (ToParams x params, Traversable list) => Manipulation [] schemas params ys -> list x -> RWST r w s m (list (K Result ys)) # forPrepared :: (ToParams x params, Traversable list) => list x -> Manipulation [] schemas params ys -> RWST r w s m (list (K Result ys)) # traversePrepared_ :: (ToParams x params, Foldable list) => Manipulation [] schemas params [] -> list x -> RWST r w s m () # forPrepared_ :: (ToParams x params, Foldable list) => list x -> Manipulation [] schemas params [] -> RWST r w s m () # liftPQ :: (Connection -> IO a) -> RWST r w s m a # | |
the state of LibPQ
Constructors
| PQState | |
data SquealException #
Exceptions that can be thrown by Squeal.
Constructors
| PQException PQState | |
| ResultException Text | |
| ParseException Text |
Instances
| Eq SquealException | |
Defined in Squeal.PostgreSQL.PQ Methods (==) :: SquealException -> SquealException -> Bool # (/=) :: SquealException -> SquealException -> Bool # | |
| Show SquealException | |
Defined in Squeal.PostgreSQL.PQ Methods showsPrec :: Int -> SquealException -> ShowS # show :: SquealException -> String # showList :: [SquealException] -> ShowS # | |
| Exception SquealException | |
Defined in Squeal.PostgreSQL.PQ Methods toException :: SquealException -> SomeException # | |
class ToParam x (pg :: PGType) where #
A ToParam constraint gives an encoding of a Haskell Type into
into the binary format of a PostgreSQL PGType.
Methods
toParam :: x -> K Encoding pg #
>>>:set -XTypeApplications -XDataKinds>>>toParam @Bool @'PGbool FalseK "\NUL"
>>>toParam @Int16 @'PGint2 0K "\NUL\NUL"
>>>toParam @Int32 @'PGint4 0K "\NUL\NUL\NUL\NUL"
>>>:set -XMultiParamTypeClasses>>>newtype Id = Id { getId :: Int16 } deriving Show>>>instance ToParam Id 'PGint2 where toParam = toParam . getId>>>toParam @Id @'PGint2 (Id 1)K "\NUL\SOH"
Instances
class HasOid (ty :: PGType) where #
The object identifier of a PGType.
>>>:set -XTypeApplications>>>oid @'PGbool16
Instances
class HasAliasedOid (field :: (Symbol, NullityType)) where #
Lifts a HasOid constraint to a field.
Methods
aliasedOid :: Word32 #
Instances
| HasOid ty => HasAliasedOid (alias ::: nullity ty) | |
Defined in Squeal.PostgreSQL.Binary Methods aliasedOid :: Word32 # | |
class ToNullityParam x (ty :: NullityType) where #
A ToNullityParam constraint gives an encoding of a Haskell Type into
into the binary format of a PostgreSQL NullityType.
Methods
toNullityParam :: x -> K (Maybe Encoding) ty #
Instances
| ToParam x pg => ToNullityParam x (NotNull pg) | |
Defined in Squeal.PostgreSQL.Binary | |
| ToParam x pg => ToNullityParam (Maybe x) (Null pg) | |
Defined in Squeal.PostgreSQL.Binary | |
class ToField (x :: (Symbol, Type)) (field :: (Symbol, NullityType)) where #
class ToFixArray x (dims :: [Nat]) (array :: NullityType) where #
A ToFixArray constraint gives an encoding of a Haskell Type
into the binary format of a PostgreSQL fixed-length array.
You should not define instances for
ToFixArray, just use the provided instances.
Methods
toFixArray :: x -> K (K Array dims) array #
Instances
| ToNullityParam x ty => ToFixArray x ([] :: [Nat]) ty | |
Defined in Squeal.PostgreSQL.Binary Methods toFixArray :: x -> K (K Array []) ty # | |
| (IsProductType product xs, Length xs ~ dim, All (Type ~ x) xs, ToFixArray x dims ty) => ToFixArray product (dim ': dims) ty | |
Defined in Squeal.PostgreSQL.Binary Methods toFixArray :: product -> K (K Array (dim ': dims)) ty # | |
class SListI tys => ToParams x (tys :: [NullityType]) where #
A ToParams constraint generically sequences the encodings of Types
of the fields of a tuple or record to a row of ColumnTypes. You should
not define instances of ToParams. Instead define Generic instances
which in turn provide ToParams instances.
Methods
toParams :: x -> NP (K (Maybe Encoding) :: NullityType -> Type) tys #
>>>type Params = '[ 'NotNull 'PGbool, 'Null 'PGint2]>>>toParams @(Bool, Maybe Int16) @'[ 'NotNull 'PGbool, 'Null 'PGint2] (False, Just 0)K (Just "\NUL") :* K (Just "\NUL\NUL") :* Nil
>>>:set -XDeriveGeneric>>>data Tuple = Tuple { p1 :: Bool, p2 :: Maybe Int16} deriving GHC.Generic>>>instance Generic Tuple>>>toParams @Tuple @Params (Tuple False (Just 0))K (Just "\NUL") :* K (Just "\NUL\NUL") :* Nil
Instances
| (SListI tys, IsProductType x xs, AllZip ToNullityParam xs tys) => ToParams x tys | |
class FromValue (pg :: PGType) y where #
A FromValue constraint gives a parser from the binary format of
a PostgreSQL PGType into a Haskell Type.
Methods
>>>newtype Id = Id { getId :: Int16 } deriving Show>>>instance FromValue 'PGint2 Id where fromValue = Id <$> fromValue @'PGint2
Instances
class FromField (pg :: (Symbol, NullityType)) (y :: (Symbol, Type)) where #
A FromField constraint lifts the FromValue parser
to a decoding of a (Symbol, NullityType) to a Type,
decoding Nulls to Maybes. You should not define instances for
FromField, just use the provided instances.
class FromFixArray (dims :: [Nat]) (ty :: NullityType) y where #
A FromFixArray constraint gives a decoding to a Haskell Type
from the binary format of a PostgreSQL fixed-length array.
You should not define instances for
FromFixArray, just use the provided instances.
Methods
fromFixArray :: Array y #
Instances
| FromValue pg y => FromFixArray ([] :: [Nat]) (NotNull pg) y | |
Defined in Squeal.PostgreSQL.Binary Methods fromFixArray :: Array y # | |
| FromValue pg y => FromFixArray ([] :: [Nat]) (Null pg) (Maybe y) | |
Defined in Squeal.PostgreSQL.Binary Methods fromFixArray :: Array (Maybe y) # | |
| (IsProductType product ys, Length ys ~ dim, All (Type ~ y) ys, FromFixArray dims ty y) => FromFixArray (dim ': dims) ty product | |
Defined in Squeal.PostgreSQL.Binary Methods fromFixArray :: Array product # | |
class SListI result => FromRow (result :: RowType) y where #
A FromRow constraint generically sequences the parsings of the columns
of a RowType into the fields of a record Type provided they have
the same field names. You should not define instances of FromRow.
Instead define Generic and HasDatatypeInfo instances which in turn
provide FromRow instances.
Methods
fromRow :: NP (K (Maybe ByteString) :: (Symbol, NullityType) -> Type) result -> Either Text y #
>>>:set -XOverloadedStrings>>>import Data.Text>>>newtype UserId = UserId { getUserId :: Int16 } deriving Show>>>instance FromValue 'PGint2 UserId where fromValue = UserId <$> fromValue @'PGint2>>>data UserRow = UserRow { userId :: UserId, userName :: Maybe Text } deriving (Show, GHC.Generic)>>>instance Generic UserRow>>>instance HasDatatypeInfo UserRow>>>type User = '["userId" ::: 'NotNull 'PGint2, "userName" ::: 'Null 'PGtext]>>>fromRow @User @UserRow (K (Just "\NUL\SOH") :* K (Just "bloodninja") :* Nil)Right (UserRow {userId = UserId {getUserId = 1}, userName = Just "bloodninja"})
Only is a 1-tuple type, useful for encoding a single parameter with
toParams or decoding a single value with fromRow.
>>>import Data.Text>>>toParams @(Only (Maybe Text)) @'[ 'Null 'PGtext] (Only (Just "foo"))K (Just "foo") :* Nil
>>>fromRow @'["fromOnly" ::: 'Null 'PGtext] @(Only (Maybe Text)) (K (Just "bar") :* Nil)Right (Only {fromOnly = Just "bar"})
Instances
| Functor Only | |
| Foldable Only | |
Defined in Squeal.PostgreSQL.Binary Methods fold :: Monoid m => Only m -> 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.Binary Associated Types type DatatypeInfoOf (Only x) :: DatatypeInfo # Methods datatypeInfo :: proxy (Only x) -> DatatypeInfo (Code (Only x)) # | |
| type Rep (Only x) | |
Defined in Squeal.PostgreSQL.Binary | |
| type Code (Only x) | |
Defined in Squeal.PostgreSQL.Binary | |
| type DatatypeInfoOf (Only x) | |
Defined in Squeal.PostgreSQL.Binary | |
bigserial :: ColumnTypeExpression schemas (Def :=> NotNull PGint8) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint8
serial8 :: ColumnTypeExpression schemas (Def :=> NotNull PGint8) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint8
serial :: ColumnTypeExpression schemas (Def :=> NotNull PGint4) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint4
serial4 :: ColumnTypeExpression schemas (Def :=> NotNull PGint4) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint4
smallserial :: ColumnTypeExpression schemas (Def :=> NotNull PGint2) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint2
serial2 :: ColumnTypeExpression schemas (Def :=> NotNull PGint2) #
not a true type, but merely a notational convenience for creating
unique identifier columns with type PGint2
default_ :: Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ([] :: [(Symbol, RowType)]) ty -> ColumnTypeExpression schemas (NoDef :=> ty) -> ColumnTypeExpression schemas (Def :=> ty) #
used in createTable commands as a column constraint to give a default
notNullable :: TypeExpression schemas (nullity ty) -> ColumnTypeExpression schemas (NoDef :=> NotNull ty) #
used in createTable commands as a column constraint to ensure
NULL is not present in a column
nullable :: TypeExpression schemas (nullity ty) -> ColumnTypeExpression schemas (NoDef :=> Null ty) #
used in createTable commands as a column constraint to note that
NULL may be present in a column
Arguments
| :: (Has sch schemas schema, Has td schema (Typedef ty)) | |
| => QualifiedAlias sch td | name of the user defined type |
| -> Definition schemas (Alter sch (Drop td schema) schemas) |
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";
createDomain :: (Has sch schemas schema, KnownSymbol dom) => QualifiedAlias sch dom -> (forall (nullity :: PGType -> NullityType). TypeExpression schemas (nullity ty)) -> (forall (tab :: Symbol). Condition ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ((tab ::: (("value" ::: Null ty) ': ([] :: [(Symbol, NullityType)]))) ': ([] :: [(Symbol, [(Symbol, NullityType)])]))) -> Definition schemas (Alter sch (Create alias (Typedef ty) schema) schemas) #
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 .&& (#value & isNotNull)) in printSQL createPositive :} CREATE DOMAIN "positive" AS real CHECK ((("value" > 0) AND "value" IS NOT NULL));
Arguments
| :: (All (FieldTyped schemas) (RowPG hask), KnownSymbol ty, Has sch schemas schema) | |
| => QualifiedAlias sch ty | name of the user defined composite type |
| -> Definition schemas (Alter sch (Create ty (Typedef (PG (Composite hask))) schema) schemas) |
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
| :: (KnownSymbol ty, Has sch schemas schema, SListI fields) | |
| => QualifiedAlias sch ty | name of the user defined composite type |
| -> NP (Aliased (TypeExpression schemas)) fields | list of attribute names and data types |
| -> Definition schemas (Alter sch (Create ty (Typedef (PGcomposite fields)) schema) schemas) |
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
| :: (Generic hask, All KnownSymbol (LabelsPG hask), KnownSymbol enum, Has sch schemas schema) | |
| => QualifiedAlias sch enum | name of the user defined enumerated type |
| -> Definition schemas (Alter sch (Create enum (Typedef (PG (Enumerated hask))) schema) schemas) |
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
| :: (KnownSymbol enum, Has sch schemas schema, All KnownSymbol labels) | |
| => QualifiedAlias sch enum | name of the user defined enumerated type |
| -> NP PGlabel labels | labels of the enumerated type |
| -> Definition schemas (Alter sch (Create enum (Typedef (PGenum labels)) schema) schemas) |
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
| :: (Has sch schemas schema, Has vw schema (View view)) | |
| => QualifiedAlias sch vw | view to remove |
| -> Definition schemas (Alter sch (Drop vw schema) schemas) |
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
| :: (KnownSymbol sch, KnownSymbol vw, Has sch schemas schema) | |
| => QualifiedAlias sch vw | the name of the view to add |
| -> Query ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) schemas ([] :: [NullityType]) view | query |
| -> Definition schemas (Alter sch (Create vw (View view) schema) schemas) |
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 b :* abc))) in printSQL definition :} CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
alterType :: ColumnTypeExpression schemas ty -> AlterColumn schemas 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 :: AlterColumn schemas (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 :: AlterColumn schemas (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 :: AlterColumn schemas (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
| :: Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ([] :: [(Symbol, RowType)]) ty | default value to set |
| -> AlterColumn schemas (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;
Arguments
| :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), Has column columns ty0, table1 ~ (constraints :=> Alter column ty1 columns)) | |
| => Alias column | column to alter |
| -> AlterColumn schemas ty0 ty1 | alteration to perform |
| -> AlterTable sch tab schemas table1 |
An alterColumn alters a single column.
Arguments
| :: (KnownSymbol column0, KnownSymbol column1, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (constraints :=> Rename column0 column1 columns)) | |
| => Alias column0 | column to rename |
| -> Alias column1 | what to rename the column |
| -> AlterTable sch tab schemas table1 |
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
| :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (constraints :=> Drop column columns)) | |
| => Alias column | column to remove |
| -> AlterTable sch tab schemas table1 |
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
| :: (KnownSymbol constraint, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (Drop constraint constraints :=> columns)) | |
| => Alias constraint | constraint to drop |
| -> AlterTable sch tab schemas table1 |
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
| :: (KnownSymbol alias, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (Create alias constraint constraints :=> columns)) | |
| => Alias alias | |
| -> TableConstraintExpression sch tab schemas constraint | constraint to add |
| -> AlterTable sch tab schemas table1 |
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));
Arguments
| :: (KnownSymbol table0, KnownSymbol table1) | |
| => Alias table0 | table to rename |
| -> Alias table1 | what to rename it |
| -> Definition schema (Rename table0 table1 schema) |
alterTableRename changes the name of a table from the schema.
>>>printSQL $ alterTableRename #foo #barALTER TABLE "foo" RENAME TO "bar";
Arguments
| :: (Has sch schemas schema, Has tab schema (Table table0)) | |
| => QualifiedAlias sch tab | table to alter |
| -> AlterTable sch tab schemas table1 | alteration to perform |
| -> Definition schemas (Alter sch (Alter tab (Table table1) schema) schemas) |
alterTable changes the definition of a table from the schema.
Arguments
| :: (Has sch schemas schema, Has tab schema (Table table)) | |
| => QualifiedAlias sch tab | table to remove |
| -> Definition schemas (Alter sch (Drop tab schema) schemas) |
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";
dropSchema :: Has sch schemas schema => Alias sch -> Definition schemas (Drop sch schemas) #
>>>:{let definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public] definition = dropSchema #muh_schema :}
>>>printSQL definitionDROP SCHEMA "muh_schema";
Arguments
| :: ForeignKeyed schemas sch schema child parent table reftable columns refcolumns constraints cols reftys tys | |
| => NP Alias columns | column or columns in the table |
| -> Alias 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 sch child schemas (ForeignKey columns 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"] "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 OnDeleteCascade OnUpdateCascade `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"] "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 OnDeleteCascade OnUpdateCascade `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
| :: (Has sch schemas 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 schemas (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
| :: (Has sch schemas 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 schemas (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
| :: (Has sch schemas 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 ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas ([] :: [NullityType]) ((t ::: subcolumns) ': ([] :: [(Symbol, [(Symbol, NullityType)])]))) | a closed |
| -> TableConstraintExpression sch tab schemas (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")));
Arguments
| :: (Has sch schemas schema, Has tab schema (Table (constraints :=> columns)), SListI columns, SListI constraints) | |
| => QualifiedAlias sch tab | the name of the table to add |
| -> NP (Aliased (ColumnTypeExpression schemas)) columns | the names and datatype of each column |
| -> NP (Aliased (TableConstraintExpression sch tab schemas)) constraints | constraints that must hold for the table |
| -> Definition schemas schemas |
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
| :: (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch schemas0 schema0, schemas1 ~ Alter sch (Create tab (Table (constraints :=> columns)) schema0) schemas0) | |
| => QualifiedAlias sch tab | the name of the table to add |
| -> NP (Aliased (ColumnTypeExpression schemas0)) columns | the names and datatype of each column |
| -> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints | constraints that must hold for the table |
| -> Definition schemas0 schemas1 |
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);
createSchemaIfNotExists :: (KnownSymbol sch, Has sch schemas schema) => Alias sch -> Definition schemas schemas #
Idempotent version of createSchema.
createSchema :: KnownSymbol sch => Alias sch -> Definition schemas (Create sch ([] :: [(Symbol, SchemumType)]) schemas) #
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.
Arguments
| :: Manipulation ([] :: [(Symbol, RowType)]) schemas ([] :: [NullityType]) ([] :: [(Symbol, NullityType)]) | no input or output |
| -> Definition schemas schemas |
A Manipulation without input or output can be run as a statement
along with other Definitions, by embedding it using manipDefinition.
newtype Definition (schemas0 :: SchemasType) (schemas1 :: 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
| Migratory Definition | |
Defined in Squeal.PostgreSQL.Migration Methods migrateUp :: AlignedList (Migration Definition) schemas0 schemas1 -> PQ schemas0 schemas1 IO () # migrateDown :: AlignedList (Migration Definition) schemas0 schemas1 -> PQ schemas1 schemas0 IO () # | |
| Category Definition | |
Defined in Squeal.PostgreSQL.Definition | |
| Eq (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition Methods (==) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool # (/=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool # | |
| Ord (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition Methods compare :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Ordering # (<) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool # (<=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool # (>) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool # (>=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool # max :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Definition schemas0 schemas1 # min :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Definition schemas0 schemas1 # | |
| Show (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition Methods showsPrec :: Int -> Definition schemas0 schemas1 -> ShowS # show :: Definition schemas0 schemas1 -> String # showList :: [Definition schemas0 schemas1] -> ShowS # | |
| Generic (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition Associated Types type Rep (Definition schemas0 schemas1) :: Type -> Type # Methods from :: Definition schemas0 schemas1 -> Rep (Definition schemas0 schemas1) x # to :: Rep (Definition schemas0 schemas1) x -> Definition schemas0 schemas1 # | |
| NFData (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition Methods rnf :: Definition schemas0 schemas1 -> () # | |
| RenderSQL (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition Methods renderSQL :: Definition schemas0 schemas1 -> ByteString # | |
| type Rep (Definition schemas0 schemas1) | |
Defined in Squeal.PostgreSQL.Definition type Rep (Definition schemas0 schemas1) = D1 (MetaData "Definition" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeDefinition" PrefixI True) (S1 (MetaSel (Just "renderDefinition") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
newtype TableConstraintExpression (sch :: Symbol) (tab :: Symbol) (schemas :: 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
| Eq (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition Methods (==) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool # (/=) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool # | |
| Ord (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition Methods compare :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Ordering # (<) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool # (<=) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool # (>) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool # (>=) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool # max :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint # min :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint # | |
| Show (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition Methods showsPrec :: Int -> TableConstraintExpression sch tab schemas constraint -> ShowS # show :: TableConstraintExpression sch tab schemas constraint -> String # showList :: [TableConstraintExpression sch tab schemas constraint] -> ShowS # | |
| Generic (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition Associated Types type Rep (TableConstraintExpression sch tab schemas constraint) :: Type -> Type # Methods from :: TableConstraintExpression sch tab schemas constraint -> Rep (TableConstraintExpression sch tab schemas constraint) x # to :: Rep (TableConstraintExpression sch tab schemas constraint) x -> TableConstraintExpression sch tab schemas constraint # | |
| NFData (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition Methods rnf :: TableConstraintExpression sch tab schemas constraint -> () # | |
| RenderSQL (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition Methods renderSQL :: TableConstraintExpression sch tab schemas constraint -> ByteString # | |
| type Rep (TableConstraintExpression sch tab schemas constraint) | |
Defined in Squeal.PostgreSQL.Definition type Rep (TableConstraintExpression sch tab schemas constraint) = D1 (MetaData "TableConstraintExpression" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeTableConstraintExpression" PrefixI True) (S1 (MetaSel (Just "renderTableConstraintExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
type ForeignKeyed (schemas :: [(Symbol, [(Symbol, SchemumType)])]) (sch :: Symbol) (schema :: [(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 sch schemas schema, Has child schema (Table table), Has parent schema (Table reftable), 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.
data OnDeleteClause #
OnDeleteClause indicates what to do with rows that reference a deleted row.
Constructors
| OnDeleteNoAction | if any referencing rows still exist when the constraint is checked, an error is raised |
| OnDeleteRestrict | prevents deletion of a referenced row |
| OnDeleteCascade | specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well |
Instances
data OnUpdateClause #
Analagous to OnDeleteClause there is also OnUpdateClause which is invoked
when a referenced column is changed (updated).
Constructors
| OnUpdateNoAction | if any referencing rows has not changed when the constraint is checked, an error is raised |
| OnUpdateRestrict | prevents update of a referenced row |
| OnUpdateCascade | the updated values of the referenced column(s) should be copied into the referencing row(s) |
Instances
newtype AlterTable (sch :: Symbol) (tab :: Symbol) (schemas :: SchemasType) (table :: TableType) #
An AlterTable describes the alteration to perform on the columns
of a table.
Constructors
| UnsafeAlterTable | |
Fields | |
Instances
| Eq (AlterTable sch tab schemas table) | |
Defined in Squeal.PostgreSQL.Definition Methods (==) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool # (/=) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool # | |
| Ord (AlterTable sch tab schemas table) | |
Defined in Squeal.PostgreSQL.Definition Methods compare :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Ordering # (<) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool # (<=) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool # (>) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool # (>=) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool # max :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> AlterTable sch tab schemas table # min :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> AlterTable sch tab schemas table # | |
| Show (AlterTable sch tab schemas table) | |
Defined in Squeal.PostgreSQL.Definition Methods showsPrec :: Int -> AlterTable sch tab schemas table -> ShowS # show :: AlterTable sch tab schemas table -> String # showList :: [AlterTable sch tab schemas table] -> ShowS # | |
| Generic (AlterTable sch tab schemas table) | |
Defined in Squeal.PostgreSQL.Definition Associated Types type Rep (AlterTable sch tab schemas table) :: Type -> Type # Methods from :: AlterTable sch tab schemas table -> Rep (AlterTable sch tab schemas table) x # to :: Rep (AlterTable sch tab schemas table) x -> AlterTable sch tab schemas table # | |
| NFData (AlterTable sch tab schemas table) | |
Defined in Squeal.PostgreSQL.Definition Methods rnf :: AlterTable sch tab schemas table -> () # | |
| type Rep (AlterTable sch tab schemas table) | |
Defined in Squeal.PostgreSQL.Definition type Rep (AlterTable sch tab schemas table) = D1 (MetaData "AlterTable" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" 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
| :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) | |
| => Alias column | column to add |
| -> ColumnTypeExpression schemas ty | type of the new column |
| -> AlterTable sch tab schemas (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';
>>>:{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 | |
| AddColumn (Def :=> ty) | |
Defined in Squeal.PostgreSQL.Definition | |
newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) #
An AlterColumn describes the alteration to perform on a single column.
Constructors
| UnsafeAlterColumn | |
Fields | |
Instances
| Eq (AlterColumn schemas ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition Methods (==) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool # (/=) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool # | |
| Ord (AlterColumn schemas ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition Methods compare :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Ordering # (<) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool # (<=) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool # (>) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool # (>=) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool # max :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 # min :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 # | |
| Show (AlterColumn schemas ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition Methods showsPrec :: Int -> AlterColumn schemas ty0 ty1 -> ShowS # show :: AlterColumn schemas ty0 ty1 -> String # showList :: [AlterColumn schemas ty0 ty1] -> ShowS # | |
| Generic (AlterColumn schemas ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition Associated Types type Rep (AlterColumn schemas ty0 ty1) :: Type -> Type # Methods from :: AlterColumn schemas ty0 ty1 -> Rep (AlterColumn schemas ty0 ty1) x # to :: Rep (AlterColumn schemas ty0 ty1) x -> AlterColumn schemas ty0 ty1 # | |
| NFData (AlterColumn schemas ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition Methods rnf :: AlterColumn schemas ty0 ty1 -> () # | |
| type Rep (AlterColumn schemas ty0 ty1) | |
Defined in Squeal.PostgreSQL.Definition type Rep (AlterColumn schemas ty0 ty1) = D1 (MetaData "AlterColumn" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeAlterColumn" PrefixI True) (S1 (MetaSel (Just "renderAlterColumn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
class FieldTyped (schemas :: SchemasType) (ty :: (Symbol, NullityType)) where #
Lift PGTyped to a field
Methods
fieldtype :: Aliased (TypeExpression schemas) ty #
Instances
| (KnownSymbol alias, PGTyped schemas ty) => FieldTyped schemas (alias ::: ty) | |
Defined in Squeal.PostgreSQL.Definition Methods fieldtype :: Aliased (TypeExpression schemas) (alias ::: ty) # | |
newtype ColumnTypeExpression (schemas :: SchemasType) (ty :: ColumnType) #
ColumnTypeExpressions are used in createTable commands.
Constructors
| UnsafeColumnTypeExpression | |
Fields | |
Instances
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 :: SetOfFunction "jsonb_object_keys" (null PGjsonb) (("jsonb_object_keys" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)])) #
Returns set of keys in the outermost JSON object.
>>>printSQL (jsonbObjectKeys (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))jsonb_object_keys(('{"a":"foo","b":"bar"}' :: jsonb))
jsonObjectKeys :: SetOfFunction "json_object_keys" (nullity PGjson) (("json_object_keys" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)])) #
Returns set of keys in the outermost JSON object.
>>>printSQL (jsonObjectKeys (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))json_object_keys(('{"a":"foo","b":"bar"}' :: json))
jsonbEachText :: SetOfFunction "jsonb_each_text" (null PGjsonb) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))) #
Expands the outermost binary JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonbEachText (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM jsonb_each_text(('{"a":"foo","b":"bar"}' :: jsonb))
jsonEachText :: SetOfFunction "json_each_text" (null PGjson) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))) #
Expands the outermost JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonEachText (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM json_each_text(('{"a":"foo","b":"bar"}' :: json))
jsonbEach :: SetOfFunction "jsonb_each" (nullity PGjsonb) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGjson) ': ([] :: [(Symbol, NullityType)]))) #
Expands the outermost binary JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonbEach (literal (Jsonb (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM jsonb_each(('{"a":"foo","b":"bar"}' :: jsonb))
jsonEach :: SetOfFunction "json_each" (null PGjson) (("key" ::: NotNull PGtext) ': (("value" ::: NotNull PGjson) ': ([] :: [(Symbol, NullityType)]))) #
Expands the outermost JSON object into a set of key/value pairs.
>>>printSQL (select Star (from (jsonEach (literal (Json (object ["a" .= "foo", "b" .= "bar"]))))))SELECT * FROM json_each(('{"a":"foo","b":"bar"}' :: json))
jsonbPretty :: null PGjsonb :--> null PGtext #
Returns its argument as indented JSON text.
jsonbInsert :: FunctionN (null PGjsonb ': (null (PGvararray (NotNull PGtext)) ': (null PGjsonb ': (null PGbool ': ([] :: [NullityType]))))) (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 :: FunctionN (null PGjsonb ': (null (PGvararray (NotNull PGtext)) ': (null PGjsonb ': (null PGbool ': ([] :: [NullityType]))))) (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 :: null PGjsonb :--> null PGjsonb #
Returns its argument with all object fields that have null values omitted. Other null values are untouched.
jsonStripNulls :: null PGjson :--> null PGjson #
Returns its argument with all object fields that have null values omitted. Other null values are untouched.
jsonbTypeof :: 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 :: 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 :: null PGjsonb :--> null PGint4 #
Returns the number of elements in the outermost binary JSON array.
jsonArrayLength :: null PGjson :--> null PGint4 #
Returns the number of elements in the outermost JSON array.
jsonbZipObject :: FunctionN (null (PGvararray (NotNull PGtext)) ': (null (PGvararray (NotNull PGtext)) ': ([] :: [NullityType]))) (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 :: FunctionN (null (PGvararray (NotNull PGtext)) ': (null (PGvararray (NotNull PGtext)) ': ([] :: [NullityType]))) (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 :: null (PGfixarray (n ': (2 ': ([] :: [Nat]))) (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 :: null (PGfixarray (n ': (2 ': ([] :: [Nat]))) (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 :: SListI tuple => FunctionN tuple (null PGjsonb) #
Builds a possibly-heterogeneously-typed (binary) JSON array out of a variadic argument list.
jsonBuildArray :: SListI tuple => FunctionN tuple (null PGjson) #
Builds a possibly-heterogeneously-typed JSON array out of a variadic argument list.
rowToJson :: null (PGcomposite ty) :--> null PGjson #
Returns the row as a JSON object.
arrayToJson :: null (PGvararray ty) :--> null PGjson #
Returns the array as a JSON array. A PostgreSQL multidimensional array becomes a JSON array of arrays.
toJsonb :: 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 :: 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.
(#-.) :: 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)
(.-.) :: In key (PGtext ': (PGvararray (NotNull PGtext) ': (PGint4 ': (PGint2 ': ([] :: [PGType]))))) => 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.
(.?&) :: Operator (null PGjsonb) (null (PGvararray (NotNull PGtext))) (Null PGbool) infixl 9 #
Do all of these array strings exist as top-level keys?
(.?|) :: Operator (null PGjsonb) (null (PGvararray (NotNull PGtext))) (Null PGbool) infixl 9 #
Do any of these array strings exist as top-level keys?
(.?) :: Operator (null PGjsonb) (null PGtext) (Null PGbool) infixl 9 #
Does the string exist as a top-level key within the JSON value?
(.#>>) :: In json PGJsonType => Operator (null json) (null (PGvararray (NotNull PGtext))) (Null PGtext) infixl 8 #
Get JSON value at a specified path as text.
(.#>) :: In json PGJsonType => Operator (null json) (null (PGvararray (NotNull PGtext))) (Null json) infixl 8 #
Get JSON value at a specified path.
(.->>) :: (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.
(.->) :: (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 :: [NullityType]) 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 :: FunctionN tys (null PGjson) #
jsonbBuildObject :: FunctionN tys (null PGjsonb) #
Instances
| JsonBuildObject ([] :: [NullityType]) | |
Defined in Squeal.PostgreSQL.Expression.Json Methods jsonBuildObject :: FunctionN [] (null PGjson) # jsonbBuildObject :: FunctionN [] (null PGjsonb) # | |
| (JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject (NotNull key ': (value ': tys)) | |
Defined in Squeal.PostgreSQL.Expression.Json Methods jsonBuildObject :: FunctionN (NotNull key ': (value ': tys)) (null PGjson) # jsonbBuildObject :: FunctionN (NotNull key ': (value ': tys)) (null PGjsonb) # | |
type JsonPopulateFunction (fun :: Symbol) (json :: PGType) #
Arguments
| = forall (schemas :: SchemasType) (row :: RowType) (outer :: FromType) (commons :: FromType) (params :: [NullityType]). In json PGJsonType | |
| => TypeExpression schemas (NotNull (PGcomposite row)) | row type |
| -> Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]) (NotNull json) | json type |
| -> FromClause outer commons schemas params ((fun ::: row) ': ([] :: [(Symbol, RowType)])) |
Build rows from Json types.
type JsonToRecordFunction (json :: PGType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (tab :: Symbol) (row :: [(Symbol, NullityType)]). (SListI row, In json PGJsonType) | |
| => Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]) (NotNull json) | json type |
| -> Aliased (NP (Aliased (TypeExpression schemas))) (tab ::: row) | row type |
| -> FromClause outer commons schemas params ((tab ::: row) ': ([] :: [(Symbol, [(Symbol, NullityType)])])) |
Build rows from Json types.
Arguments
| :: (Has sch schemas schema, Has tydef schema (Typedef (PGcomposite row)), Has field row ty) | |
| => QualifiedAlias sch tydef | row type |
| -> Alias field | field name |
| -> Expression outer commons grp schemas params from (NotNull (PGcomposite row)) | |
| -> Expression outer commons grp schemas 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 outer '[] grp (Public Schema) from params ('NotNull Complex)>>>printSQL $ i & field #complex #imaginary(ROW(0, 1)::"complex")."imaginary"
Arguments
| :: SListI row | |
| => NP (Aliased (Expression outer commons grp schemas params from)) row | zero or more expressions for the row field values |
| -> Expression outer commons grp schemas 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 outer commons grp schemas params from ('NotNull Complex)>>>printSQL iROW(0, 1)
unnest :: SetOfFunction "unnest" (null (PGvararray ty)) (("unnest" ::: ty) ': ([] :: [(Symbol, NullityType)])) #
Expand an array to a set of rows
Arguments
| :: Word64 | index |
| -> null (PGvararray ty) :--> NullifyType ty |
>>>printSQL $ array [null_, false, true] & index 2(ARRAY[NULL, FALSE, TRUE])[2]
cardinality :: null (PGvararray ty) :--> null PGint8 #
>>>printSQL $ cardinality (array [null_, false, true])cardinality(ARRAY[NULL, FALSE, TRUE])
array2 :: (All ([NullityType] ~ tys) tyss, All (SListI :: [NullityType] -> Constraint) tyss, Length tyss ~ n1, All (NullityType ~ ty) tys, Length tys ~ n2) => NP (NP (Expression outer commons grp schemas params from)) tyss -> Expression outer commons grp schemas params from (null (PGfixarray (n1 ': (n2 ': ([] :: [Nat]))) ty)) #
construct a 2-dimensional fixed length array
>>>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 outer commons grp schemas params from (null ('PGfixarray '[2, 3] ('Null 'PGbool)))
array1 :: (n ~ Length tys, All (NullityType ~ ty) tys) => NP (Expression outer commons grp schemas params from) tys -> Expression outer commons grp schemas params from (null (PGfixarray (n ': ([] :: [Nat])) ty)) #
construct a 1-dimensional fixed length array
>>>printSQL $ array1 (null_ :* false *: true)ARRAY[NULL, FALSE, TRUE]
>>>:type array1 (null_ :* false *: true)array1 (null_ :* false *: true) :: Expression outer commons grp schemas params from (null ('PGfixarray '[3] ('Null 'PGbool)))
Arguments
| :: [Expression outer commons grp schemas params from ty] | array elements |
| -> Expression outer commons grp schemas params from (null (PGvararray ty)) |
>>>printSQL $ array [null_, false, true]ARRAY[NULL, FALSE, TRUE]
Arguments
| :: In ty (PGtimestamp ': (PGtimestamptz ': ([] :: [PGType]))) | |
| => SetOfFunctionN "generate_series" (null ty ': (null ty ': (null PGinterval ': ([] :: [NullityType])))) (("generate_series" ::: null ty) ': ([] :: [(Symbol, NullityType)])) | set returning function |
generateSeries (start :* stop *: step)
Generate a series of values, from start to stop with a step size of step
Arguments
| :: In ty (PGint4 ': (PGint8 ': (PGnumeric ': ([] :: [PGType])))) | |
| => SetOfFunctionN "generate_series" (null ty ': (null ty ': (null ty ': ([] :: [NullityType])))) (("generate_series" ::: null ty) ': ([] :: [(Symbol, NullityType)])) | set returning function |
generateSeries (start :* stop *: step)
Generate a series of values, from start to stop with a step size of step
Arguments
| :: In ty (PGint4 ': (PGint8 ': (PGnumeric ': ([] :: [PGType])))) | |
| => SetOfFunctionN "generate_series" (null ty ': (null ty ': ([] :: [NullityType]))) (("generate_series" ::: null ty) ': ([] :: [(Symbol, NullityType)])) | set returning function |
generateSeries (start *: stop)
Generate a series of values, from start to stop with a step size of one
Arguments
| :: (SListI tys, KnownSymbol fun) | |
| => SetOfFunctionN fun tys setof | set returning function |
Escape hatch for a set returning function with multiple argument.
Arguments
| :: KnownSymbol fun | |
| => SetOfFunction fun ty setof | set returning function |
Escape hatch for a set returning function with 1 argument.
type SetOfFunction (fun :: Symbol) (ty :: NullityType) (setof :: k) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]). Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]) ty | input |
| -> FromClause outer commons schemas params ((fun ::: setof) ': ([] :: [(Symbol, k)])) | output |
A RankNType for set returning functions with 1 argument.
type SetOfFunctionN (fun :: Symbol) (tys :: [NullityType]) (setof :: k) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]). NP (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)])) tys | inputs |
| -> FromClause outer commons schemas params ((fun ::: setof) ': ([] :: [(Symbol, k)])) | output |
A RankNType for set returning functions with multiple argument.
Arguments
| :: Expression outer commons grp schemas params from ty | expression |
| -> [Expression outer commons grp schemas params from ty] | |
| -> Condition outer commons grp schemas params from |
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
| :: Expression outer commons grp schemas params from ty | expression |
| -> [Expression outer commons grp schemas params from ty] | |
| -> Condition outer commons grp schemas params from |
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
| :: Expression outer commons grp schemas params from ty1 | expression |
| -> Operator ty1 ty2 (Null PGbool) | operator |
| -> Query (Join outer from) commons schemas params ((col ::: ty2) ': ([] :: [(Symbol, NullityType)])) | subquery |
| -> Condition outer commons grp schemas 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' LIKE ANY (SELECT * FROM (VALUES (E'foobar')) AS t ("foo")))
Arguments
| :: Expression outer commons grp schemas params from ty1 | expression |
| -> Operator ty1 ty2 (Null PGbool) | operator |
| -> Query (Join outer from) commons schemas params ((col ::: ty2) ': ([] :: [(Symbol, NullityType)])) | subquery |
| -> Condition outer commons grp schemas 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")))
exists :: Query (Join outer from) commons schemas params row -> Condition outer commons grp schemas params from #
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
| :: (db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row ~ TableToRow table, columns ~ TableToColumns table) | |
| => QualifiedAlias sch tab | table to delete from |
| -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row) ': ([] :: [(Symbol, RowType)])) | condition under which to delete a row |
| -> Manipulation commons schemas params ([] :: [(Symbol, NullityType)]) |
Delete rows returning Nil.
Arguments
| :: (SListI row1, db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row0 ~ TableToRow table, columns ~ TableToColumns table) | |
| => QualifiedAlias sch tab | table to delete from |
| -> UsingClause commons schemas params from | |
| -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row0) ': from) | condition under which to delete a row |
| -> ReturningClause commons schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) row1 | results to return |
| -> Manipulation commons schemas params row1 |
Delete rows from a table.
Arguments
| :: (SListI columns, db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row ~ TableToRow table, columns ~ TableToColumns table, All (HasIn columns :: (Symbol, (ColumnConstraint, NullityType)) -> Constraint) subcolumns, AllUnique subcolumns) | |
| => QualifiedAlias sch tab | table to update |
| -> NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas params ((tab ::: row) ': ([] :: [(Symbol, RowType)]))))) subcolumns | modified values to replace old values |
| -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row) ': ([] :: [(Symbol, RowType)])) | condition under which to perform update on a row |
| -> Manipulation commons schemas params ([] :: [(Symbol, NullityType)]) |
Update a row returning Nil.
Arguments
| :: (SListI columns, SListI row1, db ~ (commons :=> schemas), Has sch schemas schema, Has tab schema (Table table), row0 ~ TableToRow table, columns ~ TableToColumns table, All (HasIn columns :: (Symbol, (ColumnConstraint, NullityType)) -> Constraint) subcolumns, AllUnique subcolumns) | |
| => QualifiedAlias sch tab | table to update |
| -> NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) Ungrouped schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)]))))) subcolumns | modified values to replace old values |
| -> Condition ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) | condition under which to perform update on a row |
| -> ReturningClause commons schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) row1 | results to return |
| -> Manipulation commons schemas params row1 |
An update command changes the values of the specified columns
in all rows that satisfy the condition.
insertInto_ :: (Has sch schemas schema, Has tab schema (Table table), columns ~ TableToColumns table, row ~ TableToRow table, SListI columns) => QualifiedAlias sch tab -> QueryClause commons schemas params columns -> Manipulation commons schemas params ([] :: [(Symbol, NullityType)]) #
Like insertInto but with OnConflictDoRaise and no ReturningClause.
insertInto :: (Has sch schemas schema, Has tab schema (Table table), columns ~ TableToColumns table, row0 ~ TableToRow table, SListI columns, SListI row1) => QualifiedAlias sch tab -> QueryClause commons schemas params columns -> ConflictClause tab commons schemas params table -> ReturningClause commons schemas params ((tab ::: row0) ': ([] :: [(Symbol, RowType)])) row1 -> Manipulation commons schemas params row1 #
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.
queryStatement :: Query ([] :: [(Symbol, RowType)]) commons schemas params columns -> Manipulation commons schemas params columns #
Convert a Query into a Manipulation.
pattern Values_ :: forall (columns :: [(Symbol, (ColumnConstraint, NullityType))]) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]). SListI columns => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ([] :: [(Symbol, RowType)])))) columns -> QueryClause commons schemas params columns #
Values_ describes a single NP list of Aliased Optional Expressions
whose ColumnsType must match the tables'.
pattern Returning_ :: forall (row :: [(Symbol, NullityType)]) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). SListI row => NP (Aliased (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params from)) row -> ReturningClause commons schemas params from row #
newtype Manipulation (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: RowType) #
A Manipulation is a statement which may modify data in the database,
but does not alter its schemas. Examples are inserts, updates and deletes.
A Query is also considered a Manipulation even though it does not modify data.
The general Manipulation type is parameterized by
Constructors
| UnsafeManipulation | |
Fields | |
Instances
| With Manipulation | |
Defined in Squeal.PostgreSQL.Manipulation Methods with :: AlignedList (CommonTableExpression Manipulation schemas params) commons0 commons1 -> Manipulation commons1 schemas params row -> Manipulation commons0 schemas params row # | |
| Eq (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods (==) :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Bool # (/=) :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Bool # | |
| Ord (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods compare :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Ordering # (<) :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Bool # (<=) :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Bool # (>) :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Bool # (>=) :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Bool # max :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Manipulation commons schemas params columns # min :: Manipulation commons schemas params columns -> Manipulation commons schemas params columns -> Manipulation commons schemas params columns # | |
| Show (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods showsPrec :: Int -> Manipulation commons schemas params columns -> ShowS # show :: Manipulation commons schemas params columns -> String # showList :: [Manipulation commons schemas params columns] -> ShowS # | |
| Generic (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Associated Types type Rep (Manipulation commons schemas params columns) :: Type -> Type # Methods from :: Manipulation commons schemas params columns -> Rep (Manipulation commons schemas params columns) x # to :: Rep (Manipulation commons schemas params columns) x -> Manipulation commons schemas params columns # | |
| NFData (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods rnf :: Manipulation commons schemas params columns -> () # | |
| RenderSQL (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: Manipulation commons schemas params columns -> ByteString # | |
| type Rep (Manipulation commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation type Rep (Manipulation commons schemas params columns) = D1 (MetaData "Manipulation" "Squeal.PostgreSQL.Manipulation" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeManipulation" PrefixI True) (S1 (MetaSel (Just "renderManipulation") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
type family Manipulation_ (schemas :: SchemasType) params row :: Type where ... #
The top level Manipulation_ type is parameterized by a schemas SchemasType,
against which the query is type-checked, an input parameters Haskell Type,
and an ouput row Haskell Type.
A top-level Manipulation_ can be run
using manipulateParams, or if parameters = ()
using manipulate.
Generally, parameters 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.
>>>:set -XDeriveAnyClass -XDerivingStrategies>>>:{data Row a b = Row { col1 :: a, col2 :: b } deriving stock (GHC.Generic) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) :}
simple insert:
>>>type Columns = '["col1" ::: 'NoDef :=> 'Null 'PGint4, "col2" ::: 'Def :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manipulation :: Manipulation_ (Public Schema) () () manipulation = insertInto_ #tab (Values_ (Set 2 `as` #col1 :* Default `as` #col2)) in printSQL manipulation :} INSERT INTO "tab" ("col1", "col2") VALUES (2, DEFAULT)
parameterized insert:
>>>type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let manipulation :: Manipulation_ (Public Schema) (Int32, Int32) () manipulation = insertInto_ #tab (Values_ (Set (param @1) `as` #col1 :* Set (param @2) `as` #col2)) in printSQL manipulation :} INSERT INTO "tab" ("col1", "col2") VALUES (($1 :: int4), ($2 :: int4))
returning insert:
>>>:{let manipulation :: Manipulation_ (Public Schema) () (Only Int32) manipulation = insertInto #tab (Values_ (Set 2 `as` #col1 :* Set 3 `as` #col2)) OnConflictDoRaise (Returning (#col1 `as` #fromOnly)) in printSQL manipulation :} INSERT INTO "tab" ("col1", "col2") VALUES (2, 3) RETURNING "col1" AS "fromOnly"
upsert:
>>>type CustomersColumns = '["name" ::: 'NoDef :=> 'NotNull 'PGtext, "email" ::: 'NoDef :=> 'NotNull 'PGtext]>>>type CustomersConstraints = '["uq" ::: 'Unique '["name"]]>>>type CustomersSchema = '["customers" ::: 'Table (CustomersConstraints :=> CustomersColumns)]>>>:{let manipulation :: Manipulation_ (Public CustomersSchema) () () manipulation = insertInto #customers (Values_ (Set "John Smith" `as` #name :* Set "john@smith.com" `as` #email)) (OnConflict (OnConstraint #uq) (DoUpdate (Set (#excluded ! #email <> "; " <> #customers ! #email) `as` #email) [])) (Returning_ Nil) in printSQL manipulation :} INSERT INTO "customers" ("name", "email") VALUES (E'John Smith', E'john@smith.com') ON CONFLICT ON CONSTRAINT "uq" DO UPDATE SET "email" = ("excluded"."email" || (E'; ' || "customers"."email"))
query insert:
>>>:{let manipulation :: Manipulation_ (Public Schema) () () manipulation = insertInto_ #tab (Subquery (select Star (from (table #tab)))) in printSQL manipulation :} INSERT INTO "tab" SELECT * FROM "tab" AS "tab"
update:
>>>:{let manipulation :: Manipulation_ (Public Schema) () () manipulation = update_ #tab (Set 2 `as` #col1) (#col1 ./= #col2) in printSQL manipulation :} UPDATE "tab" SET "col1" = 2 WHERE ("col1" <> "col2")
delete:
>>>:{let manipulation :: Manipulation_ (Public Schema) () (Row Int32 Int32) manipulation = deleteFrom #tab NoUsing (#col1 .== #col2) (Returning Star) in printSQL manipulation :} DELETE FROM "tab" WHERE ("col1" = "col2") RETURNING *
delete and using clause:
>>>:{type Schema3 = '[ "tab" ::: 'Table ('[] :=> Columns) , "other_tab" ::: 'Table ('[] :=> Columns) , "third_tab" ::: 'Table ('[] :=> Columns) ] :}
>>>:{let manipulation :: Manipulation_ (Public Schema3) () () manipulation = deleteFrom #tab (Using (table #other_tab & also (table #third_tab))) ( (#tab ! #col2 .== #other_tab ! #col2) .&& (#tab ! #col2 .== #third_tab ! #col2) ) (Returning_ Nil) in printSQL manipulation :} DELETE FROM "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 manipulation :: Manipulation_ (Public ProductsSchema) (Only Day) () manipulation = with (deleteFrom #products NoUsing (#date .< param @1) (Returning Star) `as` #del) (insertInto_ #products_deleted (Subquery (select Star (from (common #del))))) in printSQL manipulation :} WITH "del" AS (DELETE FROM "products" WHERE ("date" < ($1 :: date)) RETURNING *) INSERT INTO "products_deleted" SELECT * FROM "del" AS "del"
Equations
| Manipulation_ schemas params row = Manipulation ([] :: [(Symbol, RowType)]) schemas (TuplePG params) (RowPG row) |
data QueryClause (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]) where #
A QueryClause describes what to insertInto a table.
Constructors
| Values :: forall (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]). SListI columns => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ([] :: [(Symbol, RowType)])))) columns -> [NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params ([] :: [(Symbol, RowType)])))) columns] -> QueryClause commons schemas params columns |
|
| Select :: forall (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]) (grp :: Grouping) (from :: FromType). SListI columns => NP (Aliased (Optional (Expression ([] :: [(Symbol, RowType)]) commons grp schemas params from))) columns -> TableExpression ([] :: [(Symbol, RowType)]) commons grp schemas params from -> QueryClause commons schemas params columns |
|
| Subquery :: forall (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: [(Symbol, (ColumnConstraint, NullityType))]) (row :: RowType). ColumnsToRow columns ~ row => Query ([] :: [(Symbol, RowType)]) commons schemas params row -> QueryClause commons schemas params columns |
|
Instances
| RenderSQL (QueryClause commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: QueryClause commons schemas params columns -> ByteString # | |
data Optional (expr :: k -> Type) (ty :: (ColumnConstraint, k)) :: forall k. (k -> Type) -> (ColumnConstraint, k) -> Type where #
Optional is either Default or a value, parameterized by an appropriate
ColumnConstraint.
Constructors
| Default :: forall k (expr :: k -> Type) (ty :: (ColumnConstraint, k)) (ty1 :: k). Optional expr ((,) Def ty1) | Use the |
| Set :: forall k (expr :: k -> Type) (ty :: (ColumnConstraint, k)) (ty1 :: k) (def :: ColumnConstraint). expr ty1 -> Optional expr ((,) def ty1) |
|
Instances
| (forall (x :: k). RenderSQL (expr x)) => RenderSQL (Optional expr ty) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: Optional expr ty -> ByteString # | |
newtype ReturningClause (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (from :: [(Symbol, RowType)]) (row :: RowType) #
A ReturningClause computes and return 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.
Constructors
| Returning (Selection ([] :: [(Symbol, RowType)]) commons Ungrouped schemas params from row) |
Instances
| RenderSQL (ReturningClause commons schemas params from row) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: ReturningClause commons schemas params from row -> ByteString # | |
data ConflictClause (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (table :: ([(Symbol, kind)], ColumnsType)) :: forall kind. Symbol -> FromType -> SchemasType -> [NullityType] -> ([(Symbol, kind)], ColumnsType) -> Type 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 kind (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (table :: ([(Symbol, kind)], ColumnsType)). ConflictClause tab commons schemas params table | |
| OnConflict :: forall kind (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (table :: ([(Symbol, kind)], ColumnsType)) (constraints :: [(Symbol, kind)]) (columns :: ColumnsType). ConflictTarget constraints -> ConflictAction tab commons schemas params columns -> ConflictClause tab commons schemas params ((,) constraints columns) |
Instances
| SListI (TableToColumns table) => RenderSQL (ConflictClause tab commons schemas params table) | Render a |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: ConflictClause tab commons schemas params table -> ByteString # | |
data ConflictAction (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: ColumnsType) 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 (or an alias), and to rows proposed
for insertion using the special #excluded table.
Constructors
| DoNothing :: forall (tab :: Symbol) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (columns :: ColumnsType). ConflictAction tab commons schemas params columns |
|
| DoUpdate |
|
Fields
| |
Instances
| RenderSQL (ConflictAction tab commons schemas params columns) | |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: ConflictAction tab commons schemas params columns -> ByteString # | |
data ConflictTarget (constraints :: [(Symbol, kind)]) :: forall kind. [(Symbol, kind)] -> Type where #
A ConflictTarget specifies the constraint violation that triggers a
ConflictAction.
Constructors
| OnConstraint :: forall kind (constraints :: [(Symbol, kind)]) (con :: Symbol) (constraint :: kind). Has con constraints constraint => Alias con -> ConflictTarget constraints |
Instances
| RenderSQL (ConflictTarget constraints) | Render a |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: ConflictTarget constraints -> ByteString # | |
data UsingClause (commons :: k) (schemas :: k1) (params :: k2) (from :: [k3]) :: forall k k1 k2 k3. k -> k1 -> k2 -> [k3] -> Type where #
Specify additional tables.
Constructors
| NoUsing :: forall k k1 k2 k3 (commons :: k) (schemas :: k1) (params :: k2) (from :: [k3]). UsingClause commons schemas params ([] :: [k3]) | No |
| Using :: forall k k1 k2 k3 (commons :: k) (schemas :: k1) (params :: k2) (from :: [k3]) k4. FromClause ([] :: [k4]) commons schemas params from -> UsingClause commons schemas params from | An |
withRecursive :: Aliased (Query outer (recursive ': commons) schemas params) recursive -> Query outer (recursive ': commons) schemas params row -> Query outer commons schemas params row #
>>>import Data.Monoid (Sum (..))>>>import Data.Int (Int64)>>>:{let query :: Query_ schema () (Sum Int64) 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 query :} WITH RECURSIVE "t" AS ((SELECT * FROM (VALUES ((1 :: int))) AS t ("n")) UNION ALL (SELECT ("n" + 1) AS "n" FROM "t" AS "t" WHERE ("n" < 100))) SELECT COALESCE(sum(ALL "n"), 0) AS "getSum" FROM "t" AS "t"
Arguments
| :: FromClause outer commons schemas params right | right |
| -> Condition outer commons Ungrouped schemas params (Join left right) |
|
| -> FromClause outer commons schemas params left | left |
| -> FromClause outer commons schemas params (Join (NullifyFrom left) (NullifyFrom 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
| :: FromClause outer commons schemas params right | right |
| -> Condition outer commons Ungrouped schemas params (Join left right) |
|
| -> FromClause outer commons schemas params left | left |
| -> FromClause outer commons schemas 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
| :: FromClause outer commons schemas params right | right |
| -> Condition outer commons Ungrouped schemas params (Join left right) |
|
| -> FromClause outer commons schemas params left | left |
| -> FromClause outer commons schemas 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
| :: FromClause outer commons schemas params right | right |
| -> Condition outer commons Ungrouped schemas params (Join left right) |
|
| -> FromClause outer commons schemas params left | left |
| -> FromClause outer commons schemas params (Join left right) |
left & innerJoin right on. The joined table is filtered by
the on condition.
Arguments
| :: FromClause outer commons schemas params right | right |
| -> FromClause outer commons schemas params left | left |
| -> FromClause outer commons schemas 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.
common :: Has cte commons common => Aliased Alias (alias ::: cte) -> FromClause outer commons schemas params ((alias ::: common) ': ([] :: [(Symbol, k4)])) #
common derives a table from a common table expression.
view :: (Has sch schemas schema, Has vw schema (View view)) => Aliased (QualifiedAlias sch) (alias ::: vw) -> FromClause outer commons schemas params ((alias ::: view) ': ([] :: [(Symbol, RowType)])) #
subquery :: Aliased (Query outer commons schemas params) query -> FromClause outer commons schemas params (query ': ([] :: [(Symbol, RowType)])) #
table :: (Has sch schemas schema, Has tab schema (Table table)) => Aliased (QualifiedAlias sch) (alias ::: tab) -> FromClause outer commons schemas params ((alias ::: TableToRow table) ': ([] :: [(Symbol, RowType)])) #
A real table is a table from the database.
Arguments
| :: Word64 | offset parameter |
| -> TableExpression outer commons grp schemas params from | |
| -> TableExpression outer commons grp schemas params from |
An offset is an endomorphism of TableExpressions which adds to the
offsetClause.
Arguments
| :: Word64 | limit parameter |
| -> TableExpression outer commons grp schemas params from | |
| -> TableExpression outer commons grp schemas params from |
A limit is an endomorphism of TableExpressions which adds to the
limitClause.
Arguments
| :: Condition outer commons (Grouped bys) schemas params from | having condition |
| -> TableExpression outer commons (Grouped bys) schemas params from | |
| -> TableExpression outer commons (Grouped bys) schemas params from |
A having is an endomorphism of TableExpressions which adds a
search condition to the havingClause.
Arguments
| :: SListI bys | |
| => NP (By from) bys | grouped columns |
| -> TableExpression outer commons Ungrouped schemas params from | |
| -> TableExpression outer commons (Grouped bys) schemas 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
| :: Condition outer commons Ungrouped schemas params from | filtering condition |
| -> TableExpression outer commons grp schemas params from | |
| -> TableExpression outer commons grp schemas params from |
A where_ is an endomorphism of TableExpressions which adds a
search condition to the whereClause.
Arguments
| :: FromClause outer commons schemas params from | table reference |
| -> TableExpression outer commons Ungrouped schemas 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.
Arguments
| :: SListI cols | |
| => NP (Aliased (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]))) cols | one row of values |
| -> Query outer commons schemas params cols |
values_ computes a row value or set of row values
specified by value expressions.
Arguments
| :: SListI cols | |
| => NP (Aliased (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]))) cols | |
| -> [NP (Aliased (Expression outer commons Ungrouped schemas params ([] :: [(Symbol, RowType)]))) cols] | When more than one row is specified, all the rows must must have the same number of elements |
| -> Query outer commons schemas 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 outer commons schemas '[] Row>>>printSQL querySELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")
Arguments
| :: (SListI columns, columns ~ (col ': cols)) | |
| => NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns | select list |
| -> TableExpression outer commons Ungrouped schemas params from | intermediate virtual table |
| -> Query outer commons schemas params columns |
Like selectDistinct but takes an NP list of Expressions instead
of a general Selection.
Arguments
| :: (SListI columns, columns ~ (col ': cols)) | |
| => Selection outer commons Ungrouped schemas params from columns | selection |
| -> TableExpression outer commons Ungrouped schemas params from | intermediate virtual table |
| -> Query outer commons schemas params columns |
After the select list has been processed, the result table can
be subject to the elimination of duplicate rows using selectDistinct.
Arguments
| :: (SListI row, row ~ (x ': xs)) | |
| => NP (Aliased (Expression outer commons grp schemas params from)) row | select list |
| -> TableExpression outer commons grp schemas params from | intermediate virtual table |
| -> Query outer commons schemas params row |
Like select but takes an NP list of Expressions instead
of a general Selection.
Arguments
| :: (SListI row, row ~ (x ': xs)) | |
| => Selection outer commons grp schemas params from row | selection |
| -> TableExpression outer commons grp schemas params from | intermediate virtual table |
| -> Query outer commons schemas 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.
exceptAll :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns #
The results of two queries can be combined using the set operation
exceptAll, the set difference. Duplicate rows are retained.
except :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns #
The results of two queries can be combined using the set operation
except, the set difference. Duplicate rows are eliminated.
intersectAll :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns #
The results of two queries can be combined using the set operation
intersectAll, the intersection. Duplicate rows are retained.
intersect :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns #
The results of two queries can be combined using the set operation
intersect, the intersection. Duplicate rows are eliminated.
unionAll :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns #
The results of two queries can be combined using the set operation
unionAll, the disjoint union. Duplicate rows are retained.
union :: Query outer commons schemas params columns -> Query outer commons schemas params columns -> Query outer commons schemas params columns #
The results of two queries can be combined using the set operation
union. Duplicate rows are eliminated.
newtype Query (outer :: FromType) (commons :: FromType) (schemas :: SchemasType) (params :: [NullityType]) (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
Constructors
| UnsafeQuery | |
Fields | |
Instances
| With (Query outer) | |
Defined in Squeal.PostgreSQL.Query Methods with :: AlignedList (CommonTableExpression (Query outer) schemas params) commons0 commons1 -> Query outer commons1 schemas params row -> Query outer commons0 schemas params row # | |
| Eq (Query outer commons schemas params row) | |
| Ord (Query outer commons schemas params row) | |
Defined in Squeal.PostgreSQL.Query Methods compare :: Query outer commons schemas params row -> Query outer commons schemas params row -> Ordering # (<) :: Query outer commons schemas params row -> Query outer commons schemas params row -> Bool # (<=) :: Query outer commons schemas params row -> Query outer commons schemas params row -> Bool # (>) :: Query outer commons schemas params row -> Query outer commons schemas params row -> Bool # (>=) :: Query outer commons schemas params row -> Query outer commons schemas params row -> Bool # max :: Query outer commons schemas params row -> Query outer commons schemas params row -> Query outer commons schemas params row # min :: Query outer commons schemas params row -> Query outer commons schemas params row -> Query outer commons schemas params row # | |
| Show (Query outer commons schemas params row) | |
| Generic (Query outer commons schemas params row) | |
Defined in Squeal.PostgreSQL.Query | |
| NFData (Query outer commons schemas params row) | |
Defined in Squeal.PostgreSQL.Query | |
| RenderSQL (Query outer commons schemas params row) | |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: Query outer commons schemas params row -> ByteString # | |
| type Rep (Query outer commons schemas params row) | |
Defined in Squeal.PostgreSQL.Query type Rep (Query outer commons schemas params row) = D1 (MetaData "Query" "Squeal.PostgreSQL.Query" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeQuery" PrefixI True) (S1 (MetaSel (Just "renderQuery") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
type family Query_ (schemas :: SchemasType) parameters row :: Type where ... #
The top level Query_ type is parameterized by a schemas SchemasType,
against which the query is type-checked, an input parameters Haskell Type,
and an ouput row Haskell Type.
A top-level query can be run
using runQueryParams, or if parameters = ()
using runQuery.
Generally, parameters 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.
Let's see some examples of queries.
>>>:set -XDeriveAnyClass -XDerivingStrategies>>>:{data Row a b = Row { col1 :: a, col2 :: b } deriving stock (GHC.Generic) deriving anyclass (SOP.Generic, SOP.HasDatatypeInfo) :}
simple query:
>>>type Columns = '["col1" ::: 'NoDef :=> 'NotNull 'PGint4, "col2" ::: 'NoDef :=> 'NotNull 'PGint4]>>>type Schema = '["tab" ::: 'Table ('[] :=> Columns)]>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = select Star (from (table #tab)) in printSQL query :} SELECT * FROM "tab" AS "tab"
restricted query:
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = select_ ((#col1 + #col2) `as` #col1 :* #col1 `as` #col2) ( from (table #tab) & where_ (#col1 .> #col2) & where_ (#col2 .> 0) ) in printSQL query :} SELECT ("col1" + "col2") AS "col1", "col1" AS "col2" FROM "tab" AS "tab" WHERE (("col1" > "col2") AND ("col2" > 0))
subquery:
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = select Star (from (subquery (select Star (from (table #tab)) `as` #sub))) in printSQL query :} SELECT * FROM (SELECT * FROM "tab" AS "tab") AS "sub"
limits and offsets:
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = select Star (from (table #tab) & limit 100 & offset 2 & limit 50 & offset 2) in printSQL query :} SELECT * FROM "tab" AS "tab" LIMIT 50 OFFSET 4
parameterized query:
>>>:{let query :: Query_ (Public Schema) (Only Int32) (Row Int32 Int32) query = select Star (from (table #tab) & where_ (#col1 .> param @1)) in printSQL query :} SELECT * FROM "tab" AS "tab" WHERE ("col1" > ($1 :: int4))
aggregation query:
>>>:{let query :: Query_ (Public Schema) () (Row Int64 Int32) query = 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 query :} SELECT COALESCE(sum(ALL "col2"), 0) AS "col1", "col1" AS "col2" FROM "tab" AS "table1" GROUP BY "col1" HAVING (sum(DISTINCT "col2") > 1)
sorted query:
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = select Star (from (table #tab) & orderBy [#col1 & Asc]) in printSQL query :} 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"] "customers" '["id"] ,"fk_shippers" ::: ForeignKey '["shipper_id"] "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) ] :}
>>>:{data Order = Order { price :: Float , customerName :: Text , shipperName :: Text } deriving GHC.Generic instance SOP.Generic Order instance SOP.HasDatatypeInfo Order :}
>>>:{let query :: Query_ (Public OrdersSchema) () Order query = 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 query :} 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 query :: Query_ (Public Schema) () (Row Int32 Int32) query = select (#t1 & DotStar) (from (table (#tab `as` #t1) & crossJoin (table (#tab `as` #t2)))) in printSQL query :} SELECT "t1".* FROM "tab" AS "t1" CROSS JOIN "tab" AS "t2"
value queries:
>>>:{let query :: Query_ schemas () (Row String Bool) query = values ("true" `as` #col1 :* true `as` #col2) ["false" `as` #col1 :* false `as` #col2] in printSQL query :} SELECT * FROM (VALUES (E'true', TRUE), (E'false', FALSE)) AS t ("col1", "col2")
set operations:
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = select Star (from (table #tab)) `unionAll` select Star (from (table #tab)) in printSQL query :} (SELECT * FROM "tab" AS "tab") UNION ALL (SELECT * FROM "tab" AS "tab")
with queries:
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int32) query = with ( select Star (from (table #tab)) `as` #cte1 :>> select Star (from (common #cte1)) `as` #cte2 ) (select Star (from (common #cte2))) in printSQL query :} WITH "cte1" AS (SELECT * FROM "tab" AS "tab"), "cte2" AS (SELECT * FROM "cte1" AS "cte1") SELECT * FROM "cte2" AS "cte2"
window function queries
>>>:{let query :: Query_ (Public Schema) () (Row Int32 Int64) query = select (#col1 & Also (rank `as` #col2 `Over` (partitionBy #col1 & orderBy [#col2 & Asc]))) (from (table #tab)) in printSQL query :} SELECT "col1" AS "col1", rank() OVER (PARTITION BY "col1" ORDER BY "col2" ASC) AS "col2" FROM "tab" AS "tab"
correlated subqueries
>>>:{let query :: Query_ (Public Schema) () (Only Int32) query = select (#col1 `as` #fromOnly) (from (table (#tab `as` #t1)) & where_ (exists ( select Star (from (table (#tab `as` #t2)) & where_ (#t2 ! #col2 .== #t1 ! #col1))))) in printSQL query :} SELECT "col1" AS "fromOnly" FROM "tab" AS "t1" WHERE EXISTS (SELECT * FROM "tab" AS "t2" WHERE ("t2"."col2" = "t1"."col1"))
data Selection (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (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 | |
Fields
| |
| DotStar | |
Fields | |
| List | |
Fields
| |
| Over | |
Fields
| |
| Also | |
Fields
| |
Instances
| (Has tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (Selection outer commons Ungrouped schemas params from row1) | |
| (Has tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)])), GroupedBy tab col bys) => IsQualified tab col (Selection outer commons (Grouped bys) schemas params from row1) | |
| (HasUnique tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (Selection outer commons Ungrouped schemas params from row1) | |
Defined in Squeal.PostgreSQL.Query | |
| (HasUnique tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)])), GroupedBy tab col bys) => IsLabel col (Selection outer commons (Grouped bys) schemas params from row1) | |
Defined in Squeal.PostgreSQL.Query | |
| (KnownSymbol col, row ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => Aliasable col (Expression outer commons grp schemas params from ty) (Selection outer commons grp schemas params from row) | |
Defined in Squeal.PostgreSQL.Query Methods as :: Expression outer commons grp schemas params from ty -> Alias col -> Selection outer commons grp schemas params from row # | |
| Additional (Selection outer commons grp schemas params from :: RowType -> Type) | |
| IsString (Selection outer commons grp schemas params from (("fromOnly" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))) | |
Defined in Squeal.PostgreSQL.Query | |
| RenderSQL (Selection outer commons grp schemas params from row) | |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: Selection outer commons grp schemas params from row -> ByteString # | |
data TableExpression (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) #
A TableExpression computes a table. The table expression contains
a fromClause that is optionally followed by a whereClause,
groupByClause, havingClause, orderByClause, limitClause
and offsetClauses. 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 | |
Defined in Squeal.PostgreSQL.Query Methods orderBy :: [SortExpression outer commons grp schemas params from] -> TableExpression outer commons grp schemas params from -> TableExpression outer commons grp schemas params from # | |
| Generic (TableExpression outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Query Associated Types type Rep (TableExpression outer commons grp schemas params from) :: Type -> Type # Methods from :: TableExpression outer commons grp schemas params from -> Rep (TableExpression outer commons grp schemas params from) x # to :: Rep (TableExpression outer commons grp schemas params from) x -> TableExpression outer commons grp schemas params from # | |
| RenderSQL (TableExpression outer commons grp schemas params from) | Render a |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: TableExpression outer commons grp schemas params from -> ByteString # | |
| type Rep (TableExpression outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Query type Rep (TableExpression outer commons grp schemas params from) = D1 (MetaData "TableExpression" "Squeal.PostgreSQL.Query" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "TableExpression" PrefixI True) ((S1 (MetaSel (Just "fromClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (FromClause outer commons schemas params from)) :*: (S1 (MetaSel (Just "whereClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Condition outer commons Ungrouped schemas params from]) :*: S1 (MetaSel (Just "groupByClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (GroupByClause grp from)))) :*: ((S1 (MetaSel (Just "havingClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (HavingClause outer commons grp schemas params from)) :*: S1 (MetaSel (Just "orderByClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [SortExpression outer commons grp schemas params from])) :*: (S1 (MetaSel (Just "limitClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Word64]) :*: S1 (MetaSel (Just "offsetClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [Word64]))))) | |
newtype FromClause (outer :: k) (commons :: k1) (schemas :: k2) (params :: k3) (from :: k4) :: forall k k1 k2 k3 k4. k -> k1 -> k2 -> k3 -> k4 -> Type #
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 outer commons schemas params :: [a] -> Type) | |
Defined in Squeal.PostgreSQL.Query Methods also :: FromClause outer commons schemas params ys -> FromClause outer commons schemas params xs -> FromClause outer commons schemas params (Join xs ys) # | |
| Eq (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods (==) :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Bool # (/=) :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Bool # | |
| Ord (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods compare :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Ordering # (<) :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Bool # (<=) :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Bool # (>) :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Bool # (>=) :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> Bool # max :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> FromClause outer commons schemas params from # min :: FromClause outer commons schemas params from -> FromClause outer commons schemas params from -> FromClause outer commons schemas params from # | |
| Show (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods showsPrec :: Int -> FromClause outer commons schemas params from -> ShowS # show :: FromClause outer commons schemas params from -> String # showList :: [FromClause outer commons schemas params from] -> ShowS # | |
| Generic (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query Associated Types type Rep (FromClause outer commons schemas params from) :: Type -> Type # Methods from :: FromClause outer commons schemas params from -> Rep (FromClause outer commons schemas params from) x # to :: Rep (FromClause outer commons schemas params from) x -> FromClause outer commons schemas params from # | |
| NFData (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods rnf :: FromClause outer commons schemas params from -> () # | |
| RenderSQL (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: FromClause outer commons schemas params from -> ByteString # | |
| type Rep (FromClause outer commons schemas params from) | |
Defined in Squeal.PostgreSQL.Query type Rep (FromClause outer commons schemas params from) = D1 (MetaData "FromClause" "Squeal.PostgreSQL.Query" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeFromClause" PrefixI True) (S1 (MetaSel (Just "renderFromClause") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
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 (from :: FromType) (by :: (Symbol, Symbol)) (table :: Symbol) (columns :: [(Symbol, NullityType)]) (column :: Symbol) (ty :: NullityType). (HasUnique table from columns, Has column columns ty) => Alias column -> By from ((,) table column) | |
| By2 :: forall (from :: FromType) (by :: (Symbol, Symbol)) (table :: Symbol) (columns :: [(Symbol, NullityType)]) (column :: Symbol) (ty :: NullityType). (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 ': ([] :: [(Symbol, Symbol)]))) => 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 | |
| (HasUnique rel rels cols, Has col cols ty, bys ~ ((,) rel col ': ([] :: [(Symbol, Symbol)]))) => IsLabel col (NP (By rels) bys) | |
Defined in Squeal.PostgreSQL.Query | |
| Eq (By from by) | |
| Ord (By from by) | |
Defined in Squeal.PostgreSQL.Query | |
| Show (By from by) | |
| RenderSQL (By from by) | |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: By from by -> ByteString # | |
data GroupByClause (grp :: Grouping) (from :: FromType) where #
A GroupByClause indicates the Grouping of a TableExpression.
A NoGroups indicates Ungrouped while a Group indicates Grouped.
NoGroups is distinguised from Group Nil since no aggregation can be
done on NoGroups while all output Expressions must be aggregated
in Group Nil. In general, all output Expressions in the
complement of bys must be aggregated in Group bys.
Constructors
| NoGroups :: forall (grp :: Grouping) (from :: FromType). GroupByClause Ungrouped from | |
| Group :: forall (grp :: Grouping) (from :: FromType) (bys :: [(Symbol, Symbol)]). SListI bys => NP (By from) bys -> GroupByClause (Grouped bys) from |
Instances
| RenderSQL (GroupByClause grp from) | Renders a |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: GroupByClause grp from -> ByteString # | |
data HavingClause (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (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 (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). HavingClause outer commons Ungrouped schemas params from | |
| Having :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (bys :: [(Symbol, Symbol)]). [Condition outer commons (Grouped bys) schemas params from] -> HavingClause outer commons (Grouped bys) schemas params from |
Instances
| Eq (HavingClause outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods (==) :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Bool # (/=) :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Bool # | |
| Ord (HavingClause outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods compare :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Ordering # (<) :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Bool # (<=) :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Bool # (>) :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Bool # (>=) :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> Bool # max :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from # min :: HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from -> HavingClause outer commons grp schemas params from # | |
| Show (HavingClause outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Query Methods showsPrec :: Int -> HavingClause outer commons grp schemas params from -> ShowS # show :: HavingClause outer commons grp schemas params from -> String # showList :: [HavingClause outer commons grp schemas params from] -> ShowS # | |
| RenderSQL (HavingClause outer commons grp schemas params from) | Render a |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: HavingClause outer commons grp schemas params from -> ByteString # | |
data CommonTableExpression (statement :: FromType -> SchemasType -> [NullityType] -> RowType -> Type) (schemas :: SchemasType) (params :: [NullityType]) (commons0 :: FromType) (commons1 :: FromType) where #
A CommonTableExpression is an auxiliary statement in a with clause.
Constructors
| CommonTableExpression :: forall (statement :: FromType -> SchemasType -> [NullityType] -> RowType -> Type) (schemas :: SchemasType) (params :: [NullityType]) (commons0 :: FromType) (commons1 :: FromType) (cte :: Symbol) (common :: RowType). Aliased (statement commons0 schemas params) (cte ::: common) -> CommonTableExpression statement schemas params commons0 ((cte ::: common) ': commons0) |
Instances
| (KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (AlignedList (CommonTableExpression statement schemas params) commons commons1) | |
Defined in Squeal.PostgreSQL.Query Methods as :: statement commons schemas params common -> Alias cte -> AlignedList (CommonTableExpression statement schemas params) commons commons1 # | |
| (KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (CommonTableExpression statement schemas params commons commons1) | |
Defined in Squeal.PostgreSQL.Query Methods as :: statement commons schemas params common -> Alias cte -> CommonTableExpression statement schemas params commons commons1 # | |
| (forall (c :: FromType) (s :: SchemasType) (p :: [NullityType]) (r :: RowType). RenderSQL (statement c s p r)) => RenderSQL (CommonTableExpression statement schemas params commons0 commons1) | |
Defined in Squeal.PostgreSQL.Query Methods renderSQL :: CommonTableExpression statement schemas params commons0 commons1 -> ByteString # | |
class With (statement :: FromType -> SchemasType -> [NullityType] -> 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.
Methods
Arguments
| :: AlignedList (CommonTableExpression statement schemas params) commons0 commons1 | common table expressions |
| -> statement commons1 schemas params row | larger query |
| -> statement commons0 schemas params row |
Instances
| With Manipulation | |
Defined in Squeal.PostgreSQL.Manipulation Methods with :: AlignedList (CommonTableExpression Manipulation schemas params) commons0 commons1 -> Manipulation commons1 schemas params row -> Manipulation commons0 schemas params row # | |
| With (Query outer) | |
Defined in Squeal.PostgreSQL.Query Methods with :: AlignedList (CommonTableExpression (Query outer) schemas params) commons0 commons1 -> Query outer commons1 schemas params row -> Query outer commons0 schemas params row # | |
nthValue :: WinFunN (null ty ': (NotNull PGint4 ': ([] :: [NullityType]))) (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
returns value evaluated at the row that is the last row of the window frame
firstValue :: WinFun1 ty ty #
returns value evaluated at the row that is the first row of the window frame
lead :: WinFunN (ty ': (NotNull PGint4 ': (ty ': ([] :: [NullityType])))) 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 :: WinFunN (ty ': (NotNull PGint4 ': (ty ': ([] :: [NullityType])))) 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 :: WinFun1 (NotNull PGint4) (NotNull PGint4) #
integer ranging from 1 to the argument value, dividing the partition as equally as possible
>>>printSQL $ ntile 5ntile(5)
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 :: SListI xs => ByteString -> WinFunN xs y #
escape hatch for defining multi-argument window functions
unsafeWindowFunction1 :: ByteString -> WinFun1 x y #
escape hatch for defining window functions
Arguments
| :: SListI bys | |
| => NP (Expression outer commons grp schemas params from) bys | partitions |
| -> WindowDefinition outer commons grp schemas 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.
data WindowDefinition (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (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 | |
Defined in Squeal.PostgreSQL.Expression.Window Methods orderBy :: [SortExpression outer commons grp schemas params from] -> WindowDefinition outer commons grp schemas params from -> WindowDefinition outer commons grp schemas params from # | |
| RenderSQL (WindowDefinition outer commons schemas from grp params) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods renderSQL :: WindowDefinition outer commons schemas from grp params -> ByteString # | |
newtype WindowFunction (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: NullityType) #
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 (Expression outer commons grp schemas params from) (NP (Expression outer commons grp schemas params from) :: [NullityType] -> Type) (WindowFunction outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: WindowFunction outer commons grp schemas params from (NotNull PGint8) # count :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (NotNull PGint8) # sum_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGSum ty)) # arrayAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null (PGvararray ty)) # jsonAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjson) # jsonbAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # bitOr :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # boolAnd :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # boolOr :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # every :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # max_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # min_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # avg :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # corr :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarPop :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarSamp :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgX :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgY :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrCount :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGint8) # regrIntercept :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrR2 :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSlope :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxx :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSyy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # stddev :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # variance :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # | |
| Eq (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods (==) :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Bool # (/=) :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Bool # | |
| Ord (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods compare :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Ordering # (<) :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Bool # (<=) :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Bool # (>) :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Bool # (>=) :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> Bool # max :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty # min :: WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from ty # | |
| Show (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods showsPrec :: Int -> WindowFunction outer commons grp schemas params from ty -> ShowS # show :: WindowFunction outer commons grp schemas params from ty -> String # showList :: [WindowFunction outer commons grp schemas params from ty] -> ShowS # | |
| Generic (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Associated Types type Rep (WindowFunction outer commons grp schemas params from ty) :: Type -> Type # Methods from :: WindowFunction outer commons grp schemas params from ty -> Rep (WindowFunction outer commons grp schemas params from ty) x # to :: Rep (WindowFunction outer commons grp schemas params from ty) x -> WindowFunction outer commons grp schemas params from ty # | |
| NFData (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods rnf :: WindowFunction outer commons grp schemas params from ty -> () # | |
| RenderSQL (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods renderSQL :: WindowFunction outer commons grp schemas params from ty -> ByteString # | |
| type Rep (WindowFunction outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression.Window type Rep (WindowFunction outer commons grp schemas params from ty) = D1 (MetaData "WindowFunction" "Squeal.PostgreSQL.Expression.Window" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeWindowFunction" PrefixI True) (S1 (MetaSel (Just "renderWindowFunction") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
type WinFun0 (x :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). WindowFunction outer commons grp schemas params from x | cannot reference aliases |
A RankNType for window functions with no arguments.
type WinFun1 (x :: NullityType) (y :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x | input |
| -> WindowFunction outer commons grp schemas params from y | output |
A RankNType for window functions with 1 argument.
type WinFunN (xs :: [NullityType]) (y :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). NP (Expression outer commons grp schemas params from) xs | inputs |
| -> WindowFunction outer commons grp schemas 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.
class Aggregate (expr1 :: NullityType -> Type) (exprN :: [k] -> Type) (aggr :: NullityType -> Type) | aggr -> expr1, aggr -> exprN where #
Aggregate functions compute a single result from a set of input values.
Aggregate functions can be used as GroupedBy Expressions as well
as WindowFunctions.
Methods
countStar :: aggr (NotNull PGint8) #
A special aggregation that does not require an input
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params from ('NotNull 'PGint8) expression = countStar in printSQL expression :} count(*)
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null ty]] ('NotNull 'PGint8) expression = count (All #col) in printSQL expression :} count(ALL "col")
sum_ :: expr1 (null ty) -> aggr (Null (PGSum ty)) #
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: 'Null 'PGnumeric]] ('Null 'PGnumeric) expression = sum_ (Distinct #col) in printSQL expression :} sum(DISTINCT "col")
arrayAgg :: expr1 ty -> aggr (Null (PGvararray ty)) #
input values, including nulls, concatenated into an array
jsonAgg :: expr1 ty -> aggr (Null PGjson) #
aggregates values as a JSON array
jsonbAgg :: expr1 ty -> aggr (Null PGjsonb) #
aggregates values as a JSON array
Arguments
| :: In int PGIntegral | |
| => expr1 (null int) | what to aggregate |
| -> aggr (Null int) |
the bitwise AND of all non-null input values, or null if none
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4) expression = bitAnd (Distinct #col) in printSQL expression :} bit_and(DISTINCT "col")
Arguments
| :: In int PGIntegral | |
| => expr1 (null int) | what to aggregate |
| -> aggr (Null int) |
the bitwise OR of all non-null input values, or null if none
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGint4]] ('Null 'PGint4) expression = bitOr (All #col) in printSQL expression :} bit_or(ALL "col")
true if all input values are true, otherwise false
>>>:{let winFun :: WindowFunction '[] commons 'Ungrouped schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool) winFun = boolAnd #col in printSQL winFun :} bool_and("col")
true if at least one input value is true, otherwise false
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool) expression = boolOr (All #col) in printSQL expression :} bool_or(ALL "col")
equivalent to boolAnd
>>>:{let expression :: Expression '[] commons ('Grouped bys) schemas params '[tab ::: '["col" ::: null 'PGbool]] ('Null 'PGbool) expression = every (Distinct #col) in printSQL expression :} every(DISTINCT "col")
Arguments
| :: expr1 (null ty) | what to maximize |
| -> aggr (Null ty) |
maximum value of expression across all input values
Arguments
| :: expr1 (null ty) | what to minimize |
| -> aggr (Null ty) |
minimum value of expression across all input values
the average (arithmetic mean) of all input values
corr :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
correlation coefficient
>>>:{let expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = corr (All (#y *: #x)) in printSQL expression :} corr(ALL "y", "x")
covarPop :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
population covariance
>>>:{let expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = covarPop (All (#y *: #x)) in printSQL expression :} covar_pop(ALL "y", "x")
covarSamp :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
sample covariance
>>>:{let winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) winFun = covarSamp (#y *: #x) in printSQL winFun :} covar_samp("y", "x")
regrAvgX :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
average of the independent variable (sum(X)/N)
>>>:{let expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = regrAvgX (All (#y *: #x)) in printSQL expression :} regr_avgx(ALL "y", "x")
regrAvgY :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
average of the dependent variable (sum(Y)/N)
>>>:{let winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) winFun = regrAvgY (#y *: #x) in printSQL winFun :} regr_avgy("y", "x")
regrCount :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGint8) #
number of input rows in which both expressions are nonnull
>>>:{let winFun :: WindowFunction '[] c 'Ungrouped s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGint8) winFun = regrCount (#y *: #x) in printSQL winFun :} regr_count("y", "x")
regrIntercept :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
y-intercept of the least-squares-fit linear equation determined by the (X, Y) pairs >>> :{ let expression :: Expression '[] c ('Grouped g) s p '[t ::: '["x" ::: 'NotNull 'PGfloat8, "y" ::: 'NotNull 'PGfloat8]] ('Null 'PGfloat8) expression = regrIntercept (All (x)) in printSQL expression :} regr_intercept(ALL "y", "x")
regrR2 :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
regr_r2(Y, X), square of the correlation coefficient
regrSlope :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
regr_slope(Y, X), slope of the least-squares-fit linear equation
determined by the (X, Y) pairs
regrSxx :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
regr_sxx(Y, X), sum(X^2) - sum(X)^2/N
(“sum of squares” of the independent variable)
regrSxy :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
regr_sxy(Y, X), sum(X*Y) - sum(X) * sum(Y)/N
(“sum of products” of independent times dependent variable)
regrSyy :: exprN (null PGfloat8 ': (null PGfloat8 ': ([] :: [k]))) -> aggr (Null PGfloat8) #
regr_syy(Y, X), sum(Y^2) - sum(Y)^2/N
(“sum of squares” of the dependent variable)
stddev :: expr1 (null ty) -> aggr (Null (PGAvg ty)) #
historical alias for stddevSamp
stddevPop :: expr1 (null ty) -> aggr (Null (PGAvg ty)) #
population standard deviation of the input values
stddevSamp :: expr1 (null ty) -> aggr (Null (PGAvg ty)) #
sample standard deviation of the input values
variance :: expr1 (null ty) -> aggr (Null (PGAvg ty)) #
historical alias for varSamp
varPop :: expr1 (null ty) -> aggr (Null (PGAvg ty)) #
population variance of the input values (square of the population standard deviation)
varSamp :: expr1 (null ty) -> aggr (Null (PGAvg ty)) #
sample variance of the input values (square of the sample standard deviation)
Instances
| Aggregate (Distinction (Expression outer commons Ungrouped schemas params from)) (Distinction (NP (Expression outer commons Ungrouped schemas params from)) :: [NullityType] -> Type) (Expression outer commons (Grouped bys) schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # count :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # sum_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGSum ty)) # arrayAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null (PGvararray ty)) # jsonAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjson) # jsonbAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # bitOr :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # boolAnd :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # boolOr :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # every :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # max_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # min_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # avg :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # corr :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarPop :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarSamp :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgX :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgY :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrCount :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGint8) # regrIntercept :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrR2 :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSlope :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxx :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSyy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # stddev :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # variance :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # | |
| Aggregate (Expression outer commons grp schemas params from) (NP (Expression outer commons grp schemas params from) :: [NullityType] -> Type) (WindowFunction outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: WindowFunction outer commons grp schemas params from (NotNull PGint8) # count :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (NotNull PGint8) # sum_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGSum ty)) # arrayAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null (PGvararray ty)) # jsonAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjson) # jsonbAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # bitOr :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # boolAnd :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # boolOr :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # every :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # max_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # min_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # avg :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # corr :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarPop :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarSamp :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgX :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgY :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrCount :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGint8) # regrIntercept :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrR2 :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSlope :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxx :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSyy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # stddev :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # variance :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # | |
data Distinction (expr :: kind -> Type) (ty :: kind) :: forall kind. (kind -> Type) -> kind -> Type #
Distinctions are used for the input of Aggregate Expressions.
All invokes the aggregate once for each input row.
Distinct invokes the aggregate once for each distinct value of the expression
(or distinct set of values, for multiple expressions) found in the input
Instances
| Aggregate (Distinction (Expression outer commons Ungrouped schemas params from)) (Distinction (NP (Expression outer commons Ungrouped schemas params from)) :: [NullityType] -> Type) (Expression outer commons (Grouped bys) schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # count :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # sum_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGSum ty)) # arrayAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null (PGvararray ty)) # jsonAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjson) # jsonbAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # bitOr :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # boolAnd :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # boolOr :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # every :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # max_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # min_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # avg :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # corr :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarPop :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarSamp :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgX :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgY :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrCount :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGint8) # regrIntercept :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrR2 :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSlope :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxx :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSyy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # stddev :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # variance :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # | |
| Eq (expr ty) => Eq (Distinction expr ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods (==) :: Distinction expr ty -> Distinction expr ty -> Bool # (/=) :: Distinction expr ty -> Distinction expr ty -> Bool # | |
| Ord (expr ty) => Ord (Distinction expr ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods compare :: Distinction expr ty -> Distinction expr ty -> Ordering # (<) :: Distinction expr ty -> Distinction expr ty -> Bool # (<=) :: Distinction expr ty -> Distinction expr ty -> Bool # (>) :: Distinction expr ty -> Distinction expr ty -> Bool # (>=) :: Distinction expr ty -> Distinction expr ty -> Bool # max :: Distinction expr ty -> Distinction expr ty -> Distinction expr ty # min :: Distinction expr ty -> Distinction expr ty -> Distinction expr ty # | |
| Show (expr ty) => Show (Distinction expr ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods showsPrec :: Int -> Distinction expr ty -> ShowS # show :: Distinction expr ty -> String # showList :: [Distinction expr ty] -> ShowS # | |
| Generic (Distinction expr ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Associated Types type Rep (Distinction expr ty) :: Type -> Type # Methods from :: Distinction expr ty -> Rep (Distinction expr ty) x # to :: Rep (Distinction expr ty) x -> Distinction expr ty # | |
| NFData (Distinction (Expression outer commons grp schemas params from) ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods rnf :: Distinction (Expression outer commons grp schemas params from) ty -> () # | |
| SListI tys => RenderSQL (Distinction (NP (Expression outer commons grp schemas params from)) tys) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (NP (Expression outer commons grp schemas params from)) tys -> ByteString # | |
| RenderSQL (Distinction (Expression outer commons grp schemas params from) ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (Expression outer commons grp schemas params from) ty -> ByteString # | |
| type Rep (Distinction expr ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate type Rep (Distinction expr ty) = D1 (MetaData "Distinction" "Squeal.PostgreSQL.Expression.Aggregate" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "All" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (expr ty))) :+: C1 (MetaCons "Distinct" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (expr ty)))) | |
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) |
isNotUnknown :: null0 PGbool :--> null1 PGbool #
is true or false
>>>printSQL $ true & isNotUnknown(TRUE IS NOT UNKNOWN)
isUnknown :: null0 PGbool :--> null1 PGbool #
is unknown
>>>printSQL $ true & isUnknown(TRUE IS UNKNOWN)
isNotFalse :: null0 PGbool :--> null1 PGbool #
is true or unknown
>>>printSQL $ true & isNotFalse(TRUE IS NOT FALSE)
isNotTrue :: null0 PGbool :--> null1 PGbool #
is false or unknown
>>>printSQL $ true & isNotTrue(TRUE IS NOT TRUE)
isNotDistinctFrom :: 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 :: 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 :: FunctionVar ty ty ty #
>>>printSQL $ least [null_] currentTimestampLEAST(NULL, CURRENT_TIMESTAMP)
greatest :: FunctionVar ty ty ty #
>>>let expr = greatest [param @1] currentTimestamp :: Expression outer commons grp schemas '[ 'NotNull 'PGtimestamptz] from ('NotNull 'PGtimestamptz)>>>printSQL exprGREATEST(($1 :: timestamp with time zone), CURRENT_TIMESTAMP)
(.>) :: Operator (null0 ty) (null1 ty) (Null PGbool) infix 4 #
>>>printSQL $ true .> null_(TRUE > NULL)
(.<=) :: Operator (null0 ty) (null1 ty) (Null PGbool) infix 4 #
>>>printSQL $ true .<= null_(TRUE <= NULL)
(.<) :: Operator (null0 ty) (null1 ty) (Null PGbool) infix 4 #
>>>printSQL $ true .< null_(TRUE < NULL)
(.>=) :: Operator (null0 ty) (null1 ty) (Null PGbool) infix 4 #
>>>printSQL $ true .>= null_(TRUE >= NULL)
(./=) :: Operator (null0 ty) (null1 ty) (Null PGbool) infix 4 #
>>>printSQL $ true ./= null_(TRUE <> NULL)
type BetweenExpr #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: NullityType). Expression outer commons grp schemas params from ty | |
| -> (Expression outer commons grp schemas params from ty, Expression outer commons grp schemas params from ty) | bounds |
| -> Condition outer commons grp schemas params from |
A RankNType for comparison expressions like between.
Arguments
| :: Expression outer commons grp schemas params from nullty | what to convert |
| -> (Expression outer commons grp schemas params from (NotNull ty) -> Expression outer commons grp schemas params from nullty) | function to perform when |
| -> Expression outer commons grp schemas params from (Null ty) | |
| -> Expression outer commons grp schemas 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
Arguments
| :: Expression outer commons grp schemas params from (NotNull ty) | what to convert |
| -> Expression outer commons grp schemas params from (Null ty) | |
| -> Expression outer commons grp schemas params from (NotNull ty) |
analagous to fromMaybe using COALESCE
>>>printSQL $ fromNull true null_COALESCE(NULL, TRUE)
coalesce :: FunctionVar (Null ty) (NotNull ty) (NotNull ty) #
return the leftmost value which is not NULL
>>>printSQL $ coalesce [null_, true] falseCOALESCE(NULL, TRUE, FALSE)
Arguments
| :: Condition outer commons grp schemas params from | |
| -> Expression outer commons grp schemas params from ty | then |
| -> Expression outer commons grp schemas params from ty | else |
| -> Expression outer commons grp schemas params from ty |
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGint2) expression = ifThenElse true 1 0 in printSQL expression :} CASE WHEN TRUE THEN 1 ELSE 0 END
Arguments
| :: [(Condition outer commons grp schemas params from, Expression outer commons grp schemas params from ty)] | whens and thens |
| -> Expression outer commons grp schemas params from ty | else |
| -> Expression outer commons grp schemas params from ty |
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGint2) expression = caseWhenThenElse [(true, 1), (false, 2)] 3 in printSQL expression :} CASE WHEN TRUE THEN 1 WHEN FALSE THEN 2 ELSE 3 END
(.||) :: Operator (null PGbool) (null PGbool) (null PGbool) infixr 2 #
>>>printSQL $ true .|| false(TRUE OR FALSE)
(.&&) :: Operator (null PGbool) (null PGbool) (null PGbool) infixr 3 #
>>>printSQL $ true .&& false(TRUE AND FALSE)
type Condition (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) = Expression outer commons grp schemas 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_ :: In frac PGFloating => null frac :--> null frac #
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGfloat4) expression = ceiling_ pi in printSQL expression :} ceiling(pi())
round_ :: In frac PGFloating => null frac :--> null frac #
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGfloat4) expression = round_ pi in printSQL expression :} round(pi())
trunc :: In frac PGFloating => null frac :--> null frac #
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGfloat4) expression = trunc pi in printSQL expression :} trunc(pi())
rem_ :: In int PGIntegral => Operator (null int) (null int) (null int) #
remainder upon integer division
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGint2) expression = 5 `rem_` 2 in printSQL expression :} (5 % 2)
quot_ :: In int PGIntegral => Operator (null int) (null int) (null int) #
integer division, truncates the result
>>>:{let expression :: Expression outer commons grp schemas params from (null 'PGint2) expression = 5 `quot_` 2 in printSQL expression :} (5 / 2)
atan2_ :: In float PGFloating => FunctionN (null float ': (null float ': ([] :: [NullityType]))) (null float) #
>>>:{let expression :: Expr (null 'PGfloat4) expression = atan2_ (pi *: 2) in printSQL expression :} atan2(pi(), 2)
Arguments
| :: (PGTyped schemas ty, HasParameter n params ty) | |
| => Expression outer commons grp schemas params from ty | param |
param takes a Nat using type application and for basic types,
infers a TypeExpression.
>>>let expr = param @1 :: Expression outer commons grp schemas '[ 'Null 'PGint4] from ('Null 'PGint4)>>>printSQL expr($1 :: int4)
class KnownNat n => HasParameter (n :: Nat) (params :: [NullityType]) (ty :: NullityType) | 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 :: TypeExpression schemas ty -> Expression outer commons grp schemas params from ty #
parameter takes a Nat using type application and a TypeExpression.
>>>let expr = parameter @1 int4 :: Expression outer '[] grp schemas '[ 'Null 'PGint4] from ('Null 'PGint4)>>>printSQL expr($1 :: int4)
Instances
| (KnownNat n, HasParameter (n - 1) params ty) => HasParameter n (ty' ': params) ty | |
Defined in Squeal.PostgreSQL.Expression.Parameter Methods parameter :: TypeExpression schemas ty -> Expression outer commons grp schemas (ty' ': params) from ty # | |
| HasParameter 1 (ty1 ': tys) ty1 | |
Defined in Squeal.PostgreSQL.Expression.Parameter Methods parameter :: TypeExpression schemas ty1 -> Expression outer commons grp schemas (ty1 ': tys) from ty1 # | |
data SortExpression (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (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 :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (NotNull ty) -> SortExpression outer commons grp schemas params from | |
| Desc :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (NotNull ty) -> SortExpression outer commons grp schemas params from | |
| AscNullsFirst :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from | |
| AscNullsLast :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from | |
| DescNullsFirst :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from | |
| DescNullsLast :: forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: PGType). Expression outer commons grp schemas params from (Null ty) -> SortExpression outer commons grp schemas params from |
Instances
| Show (SortExpression outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Sort Methods showsPrec :: Int -> SortExpression outer commons grp schemas params from -> ShowS # show :: SortExpression outer commons grp schemas params from -> String # showList :: [SortExpression outer commons grp schemas params from] -> ShowS # | |
| RenderSQL (SortExpression outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Sort Methods renderSQL :: SortExpression outer commons grp schemas params from -> ByteString # | |
class OrderBy (expr :: FromType -> FromType -> Grouping -> SchemasType -> [NullityType] -> FromType -> Type) 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
orderBy :: [SortExpression outer commons grp schemas params from] -> expr outer commons grp schemas params from -> expr outer commons grp schemas params from #
Instances
| OrderBy TableExpression | |
Defined in Squeal.PostgreSQL.Query Methods orderBy :: [SortExpression outer commons grp schemas params from] -> TableExpression outer commons grp schemas params from -> TableExpression outer commons grp schemas params from # | |
| OrderBy WindowDefinition | |
Defined in Squeal.PostgreSQL.Expression.Window Methods orderBy :: [SortExpression outer commons grp schemas params from] -> WindowDefinition outer commons grp schemas params from -> WindowDefinition outer commons grp schemas params from # | |
ilike :: 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' ILIKE E'a%')
like :: 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' LIKE E'a%')
charLength :: null PGtext :--> null PGint4 #
>>>printSQL $ charLength "four"char_length(E'four')
tsHeadline :: In document (PGtext ': (PGjson ': (PGjsonb ': ([] :: [PGType])))) => FunctionN (null document ': (null PGtsquery ': ([] :: [NullityType]))) (null PGtext) #
display a tsquery match
tsFilter :: FunctionN (null PGtsvector ': (null (PGvararray (NotNull (PGchar 1))) ': ([] :: [NullityType]))) (null PGtsvector) #
select only elements with given weights from tsvector
tsDelete :: FunctionN (null PGtsvector ': (null (PGvararray (NotNull PGtext)) ': ([] :: [NullityType]))) (null PGtsvector) #
remove given lexeme from tsvector
jsonbToTSvector :: FunctionN (null PGjsonb ': (null PGjsonb ': ([] :: [NullityType]))) (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 :: FunctionN (null PGjson ': (null PGjson ': ([] :: [NullityType]))) (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 :: null PGtsvector :--> null PGtsvector #
remove positions and weights from tsvector
setWeight :: FunctionN (null PGtsvector ': (null (PGchar 1) ': ([] :: [NullityType]))) (null PGtsvector) #
assign weight to each element of tsvector
toTSvector :: In ty (PGtext ': (PGjson ': (PGjsonb ': ([] :: [PGType])))) => null ty :--> null PGtsvector #
reduce document text to tsvector
websearchToTSquery :: null PGtext :--> null PGtsquery #
produce tsquery from a web search style query
phraseToTSquery :: null PGtext :--> null PGtsquery #
produce tsquery that searches for a phrase,
ignoring punctuation
tsvectorLength :: null PGtsvector :--> null PGint4 #
number of lexemes in tsvector
arrayToTSvector :: null (PGvararray (NotNull PGtext)) :--> null PGtsvector #
convert array of lexemes to tsvector
interval_ :: Double -> TimeUnit -> Expr (null PGinterval) #
>>>printSQL $ interval_ 7 Days(INTERVAL '7.0 days')
makeTimestamptz :: FunctionN (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGfloat8 ': ([] :: [NullityType]))))))) (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, 7, 15, 8, 15, 23.5)
makeTimestamp :: FunctionN (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGint4 ': (null PGfloat8 ': ([] :: [NullityType]))))))) (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, 7, 15, 8, 15, 23.5)
makeTime :: FunctionN (null PGint4 ': (null PGint4 ': (null PGfloat8 ': ([] :: [NullityType])))) (null PGtime) #
Create time from hour, minute and seconds fields
>>>printSQL (makeTime (8 :* 15 *: 23.5))make_time(8, 15, 23.5)
makeDate :: FunctionN (null PGint4 ': (null PGint4 ': (null PGint4 ': ([] :: [NullityType])))) (null PGdate) #
Create date from year, month and day fields
>>>printSQL (makeDate (1984 :* 7 *: 3))make_date(1984, 7, 3)
now :: Expr (null PGtimestamptz) #
Current date and time (equivalent to currentTimestamp)
>>>printSQL nownow()
localTimestamp :: Expr (null PGtimestamp) #
>>>printSQL localTimestampLOCALTIMESTAMP
currentTimestamp :: Expr (null PGtimestamptz) #
>>>printSQL currentTimestampCURRENT_TIMESTAMP
currentTime :: Expr (null PGtimetz) #
>>>printSQL currentTimeCURRENT_TIME
currentDate :: 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
(!+) :: Operator (null time) (null diff) (null time) infixl 6 #
>>>printSQL (makeDate (1984 :* 7 *: 3) !+ 365)(make_date(1984, 7, 3) + 365)
(+!) :: Operator (null diff) (null time) (null time) infixl 6 #
>>>printSQL (365 +! makeDate (1984 :* 7 *: 3))(365 + make_date(1984, 7, 3))
(!-) :: Operator (null time) (null diff) (null time) infixl 6 #
>>>printSQL (makeDate (1984 :* 7 *: 3) !- 365)(make_date(1984, 7, 3) - 365)
(!-!) :: Operator (null time) (null time) (null diff) infixl 6 #
>>>printSQL (makeDate (1984 :* 7 *: 3) !-! currentDate)(make_date(1984, 7, 3) - CURRENT_DATE)
Instances
Constructors
| Years | |
| Months | |
| Weeks | |
| Days | |
| Hours | |
| Minutes | |
| Seconds | |
| Microseconds | |
| Milliseconds | |
| Decades | |
| Centuries | |
| Millennia |
Instances
tsquery :: TypeExpression schemas (null PGtsquery) #
text search document
tsvector :: TypeExpression schemas (null PGtsvector) #
text search query
fixarray :: All KnownNat dims => TypeExpression schemas pg -> TypeExpression schemas (null (PGfixarray dims pg)) #
fixed length array
>>>renderSQL (fixarray @'[2] json)"json[2]"
vararray :: TypeExpression schemas pg -> TypeExpression schemas (null (PGvararray pg)) #
variable length array
jsonb :: TypeExpression schemas (null PGjsonb) #
binary JSON data, decomposed
json :: TypeExpression schemas (null PGjson) #
textual JSON data
inet :: TypeExpression schemas (null PGinet) #
IPv4 or IPv6 host address
uuid :: TypeExpression schemas (null PGuuid) #
universally unique identifier
interval :: TypeExpression schemas (null PGinterval) #
time span
timeWithTimeZone :: TypeExpression schemas (null PGtimetz) #
time of day, including time zone
time :: TypeExpression schemas (null PGtime) #
time of day (no time zone)
date :: TypeExpression schemas (null PGdate) #
calendar date (year, month, day)
timestampWithTimeZone :: TypeExpression schemas (null PGtimestamptz) #
date and time, including time zone
timestamp :: TypeExpression schemas (null PGtimestamp) #
date and time (no time zone)
bytea :: TypeExpression schemas (null PGbytea) #
binary data ("byte array")
characterVarying :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGvarchar n)) #
variable-length character string
varchar :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGvarchar n)) #
variable-length character string
character :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGchar n)) #
fixed-length character string
char :: (KnownNat n, 1 <= n) => TypeExpression schemas (null (PGchar n)) #
fixed-length character string
text :: TypeExpression schemas (null PGtext) #
variable-length character string
money :: TypeExpression schema (null PGmoney) #
currency amount
doublePrecision :: TypeExpression schemas (null PGfloat8) #
double precision floating-point number (8 bytes)
float8 :: TypeExpression schemas (null PGfloat8) #
double precision floating-point number (8 bytes)
real :: TypeExpression schemas (null PGfloat4) #
single precision floating-point number (4 bytes)
float4 :: TypeExpression schemas (null PGfloat4) #
single precision floating-point number (4 bytes)
numeric :: TypeExpression schemas (null PGnumeric) #
arbitrary precision numeric type
bigint :: TypeExpression schemas (null PGint8) #
signed eight-byte integer
int8 :: TypeExpression schemas (null PGint8) #
signed eight-byte integer
integer :: TypeExpression schemas (null PGint4) #
signed four-byte integer
int :: TypeExpression schemas (null PGint4) #
signed four-byte integer
int4 :: TypeExpression schemas (null PGint4) #
signed four-byte integer
smallint :: TypeExpression schemas (null PGint2) #
signed two-byte integer
int2 :: TypeExpression schemas (null PGint2) #
signed two-byte integer
bool :: TypeExpression schemas (null PGbool) #
logical Boolean (true/false)
typeview :: (Has sch schemas schema, Has vw schema (View view)) => QualifiedAlias sch vw -> TypeExpression schemas (null (PGcomposite view)) #
The composite type corresponding to a View definition can be expressed
by its alias.
typetable :: (Has sch schemas schema, Has tab schema (Table table)) => QualifiedAlias sch tab -> TypeExpression schemas (null (PGcomposite (TableToRow table))) #
The composite type corresponding to a Table definition can be expressed
by its alias.
typedef :: (Has sch schemas schema, Has td schema (Typedef ty)) => QualifiedAlias sch td -> TypeExpression schemas (null ty) #
The enum or composite type in a Typedef can be expressed by its alias.
inferredtype :: PGTyped schemas ty => Expression outer common grp schemas params from ty -> Expression outer common grp schemas 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
| :: TypeExpression schemas ty | type to specify as |
| -> Expression outer commons grp schemas params from ty | value |
| -> Expression outer commons grp schemas params from ty |
A safe version of cast which just matches a value with its type.
>>>printSQL (1 & astype int)(1 :: int)
Arguments
| :: TypeExpression schemas ty1 | type to cast as |
| -> Expression outer commons grp schemas params from ty0 | value to convert |
| -> Expression outer commons grp schemas params from ty1 |
>>>printSQL $ true & cast int4(TRUE :: int4)
newtype TypeExpression (schemas :: SchemasType) (ty :: NullityType) #
TypeExpressions are used in casts and
createTable commands.
Constructors
| UnsafeTypeExpression | |
Fields | |
Instances
class PGTyped (schemas :: SchemasType) (ty :: NullityType) where #
Methods
pgtype :: TypeExpression schemas ty #
Instances
unsafeFunctionN :: SListI xs => ByteString -> FunctionN xs y #
>>>printSQL $ unsafeFunctionN "f" (currentTime :* localTimestamp :* false *: literal 'a')f(CURRENT_TIME, LOCALTIMESTAMP, FALSE, E'a')
unsafeFunction :: ByteString -> x :--> y #
>>>printSQL $ unsafeFunction "f" truef(TRUE)
unsafeUnaryOpR :: ByteString -> x :--> y #
>>>printSQL $ true & unsafeUnaryOpR "IS NOT TRUE"(TRUE IS NOT TRUE)
unsafeUnaryOpL :: ByteString -> x :--> y #
>>>printSQL $ unsafeUnaryOpL "NOT" true(NOT TRUE)
unsafeBinaryOp :: ByteString -> Operator ty0 ty1 ty2 #
>>>printSQL $ unsafeBinaryOp "OR" true false(TRUE OR FALSE)
unsafeFunctionVar :: ByteString -> FunctionVar x0 x1 y #
>>>printSQL (unsafeFunctionVar "greatest" [true, null_] false)greatest(TRUE, NULL, FALSE)
newtype Expression (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType) (ty :: NullityType) #
Expressions are used in a variety of contexts,
such as in the target List of the
select command,
as new column values in insertRow 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
outer ::FromType, thefromclauses of any outer queries in which theExpressionis a correlated subquery expression;commons ::FromType, theCommonTableExpressions that are in scope for theExpression;grp ::Grouping, theGroupingof thefromclause which may limit which columns may be referenced by alias;schemas ::SchemasType, the schemas of your database that are in scope for theExpression;from ::FromType, thefromclause which theExpressionmay use to reference columns by alias;ty ::NullityType, the type of theExpression.
Constructors
| UnsafeExpression | |
Fields | |
Instances
| (Has tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons (Grouped bys) schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty) => IsQualified tab col (Expression outer commons Ungrouped schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (Expression outer commons (Grouped bys) schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
| Aggregate (Distinction (Expression outer commons Ungrouped schemas params from)) (Distinction (NP (Expression outer commons Ungrouped schemas params from)) :: [NullityType] -> Type) (Expression outer commons (Grouped bys) schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # count :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # sum_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGSum ty)) # arrayAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null (PGvararray ty)) # jsonAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjson) # jsonbAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # bitOr :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # boolAnd :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # boolOr :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # every :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # max_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # min_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # avg :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # corr :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarPop :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarSamp :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgX :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgY :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrCount :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGint8) # regrIntercept :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrR2 :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSlope :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxx :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSyy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # stddev :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # variance :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # | |
| (HasUnique tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons Ungrouped schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons (Grouped bys) schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons Ungrouped schemas params from) column # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons (Grouped bys) schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons (Grouped bys) schemas params from) column # | |
| Aggregate (Expression outer commons grp schemas params from) (NP (Expression outer commons grp schemas params from) :: [NullityType] -> Type) (WindowFunction outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: WindowFunction outer commons grp schemas params from (NotNull PGint8) # count :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (NotNull PGint8) # sum_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGSum ty)) # arrayAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null (PGvararray ty)) # jsonAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjson) # jsonbAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # bitOr :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # boolAnd :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # boolOr :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # every :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # max_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # min_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # avg :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # corr :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarPop :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarSamp :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgX :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgY :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrCount :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGint8) # regrIntercept :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrR2 :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSlope :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxx :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSyy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # stddev :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # variance :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # | |
| (HasUnique tab (Join outer from) row, Has col row ty) => IsLabel col (Expression outer commons Ungrouped schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression outer commons Ungrouped schemas params from ty # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys) => IsLabel col (Expression outer commons (Grouped bys) schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Expression outer commons (Grouped bys) schemas params from ty # | |
| (KnownSymbol label, In label labels) => IsPGlabel label (Expression outer commons grp schemas params from (null (PGenum labels))) | |
Defined in Squeal.PostgreSQL.Expression Methods label :: Expression outer commons grp schemas params from (null (PGenum labels)) # | |
| (KnownSymbol col, row ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => Aliasable col (Expression outer commons grp schemas params from ty) (Selection outer commons grp schemas params from row) | |
Defined in Squeal.PostgreSQL.Query Methods as :: Expression outer commons grp schemas params from ty -> Alias col -> Selection outer commons grp schemas params from row # | |
| NFData (Distinction (Expression outer commons grp schemas params from) ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods rnf :: Distinction (Expression outer commons grp schemas params from) ty -> () # | |
| SListI tys => RenderSQL (Distinction (NP (Expression outer commons grp schemas params from)) tys) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (NP (Expression outer commons grp schemas params from)) tys -> ByteString # | |
| RenderSQL (Distinction (Expression outer commons grp schemas params from) ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (Expression outer commons grp schemas params from) ty -> ByteString # | |
| Eq (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods (==) :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Bool # (/=) :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Bool # | |
| (In ty PGNum, In ty PGFloating) => Floating (Expression outer commons grp schemas params from (null ty)) | |
Defined in Squeal.PostgreSQL.Expression Methods pi :: Expression outer commons grp schemas params from (null ty) # exp :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # log :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # sqrt :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # (**) :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # logBase :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # sin :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # cos :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # tan :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # asin :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # acos :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # atan :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # sinh :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # cosh :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # tanh :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # asinh :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # acosh :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # atanh :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # log1p :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # expm1 :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # log1pexp :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # log1mexp :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # | |
| (In ty PGNum, In ty PGFloating) => Fractional (Expression outer commons grp schemas params from (null ty)) | |
Defined in Squeal.PostgreSQL.Expression Methods (/) :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # recip :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # fromRational :: Rational -> Expression outer commons grp schemas params from (null ty) # | |
| In ty PGNum => Num (Expression outer commons grp schemas params from (null ty)) | |
Defined in Squeal.PostgreSQL.Expression Methods (+) :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # (-) :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # (*) :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # negate :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # abs :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # signum :: Expression outer commons grp schemas params from (null ty) -> Expression outer commons grp schemas params from (null ty) # fromInteger :: Integer -> Expression outer commons grp schemas params from (null ty) # | |
| Ord (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods compare :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Ordering # (<) :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Bool # (<=) :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Bool # (>) :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Bool # (>=) :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Bool # max :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty # min :: Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty -> Expression outer commons grp schemas params from ty # | |
| Show (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods showsPrec :: Int -> Expression outer commons grp schemas params from ty -> ShowS # show :: Expression outer commons grp schemas params from ty -> String # showList :: [Expression outer commons grp schemas params from ty] -> ShowS # | |
| IsString (Expression outer commons grp schemas params from (null PGtext)) | |
Defined in Squeal.PostgreSQL.Expression Methods fromString :: String -> Expression outer commons grp schemas params from (null PGtext) # | |
| IsString (Expression outer commons grp schemas params from (null PGtsvector)) | |
Defined in Squeal.PostgreSQL.Expression Methods fromString :: String -> Expression outer commons grp schemas params from (null PGtsvector) # | |
| IsString (Expression outer commons grp schemas params from (null PGtsquery)) | |
Defined in Squeal.PostgreSQL.Expression Methods fromString :: String -> Expression outer commons grp schemas params from (null PGtsquery) # | |
| Generic (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Associated Types type Rep (Expression outer commons grp schemas params from ty) :: Type -> Type # Methods from :: Expression outer commons grp schemas params from ty -> Rep (Expression outer commons grp schemas params from ty) x # to :: Rep (Expression outer commons grp schemas params from ty) x -> Expression outer commons grp schemas params from ty # | |
| Semigroup (Expression outer commons grp schemas params from (null (PGvararray ty))) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression outer commons grp schemas params from (null (PGvararray ty)) -> Expression outer commons grp schemas params from (null (PGvararray ty)) -> Expression outer commons grp schemas params from (null (PGvararray ty)) # sconcat :: NonEmpty (Expression outer commons grp schemas params from (null (PGvararray ty))) -> Expression outer commons grp schemas params from (null (PGvararray ty)) # stimes :: Integral b => b -> Expression outer commons grp schemas params from (null (PGvararray ty)) -> Expression outer commons grp schemas params from (null (PGvararray ty)) # | |
| Semigroup (Expression outer commons grp schemas params from (null PGjsonb)) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression outer commons grp schemas params from (null PGjsonb) -> Expression outer commons grp schemas params from (null PGjsonb) -> Expression outer commons grp schemas params from (null PGjsonb) # sconcat :: NonEmpty (Expression outer commons grp schemas params from (null PGjsonb)) -> Expression outer commons grp schemas params from (null PGjsonb) # stimes :: Integral b => b -> Expression outer commons grp schemas params from (null PGjsonb) -> Expression outer commons grp schemas params from (null PGjsonb) # | |
| Semigroup (Expression outer commons grp schemas params from (null PGtext)) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression outer commons grp schemas params from (null PGtext) -> Expression outer commons grp schemas params from (null PGtext) -> Expression outer commons grp schemas params from (null PGtext) # sconcat :: NonEmpty (Expression outer commons grp schemas params from (null PGtext)) -> Expression outer commons grp schemas params from (null PGtext) # stimes :: Integral b => b -> Expression outer commons grp schemas params from (null PGtext) -> Expression outer commons grp schemas params from (null PGtext) # | |
| Semigroup (Expression outer commons grp schemas params from (null PGtsvector)) | |
Defined in Squeal.PostgreSQL.Expression Methods (<>) :: Expression outer commons grp schemas params from (null PGtsvector) -> Expression outer commons grp schemas params from (null PGtsvector) -> Expression outer commons grp schemas params from (null PGtsvector) # sconcat :: NonEmpty (Expression outer commons grp schemas params from (null PGtsvector)) -> Expression outer commons grp schemas params from (null PGtsvector) # stimes :: Integral b => b -> Expression outer commons grp schemas params from (null PGtsvector) -> Expression outer commons grp schemas params from (null PGtsvector) # | |
| Monoid (Expression outer commons grp schemas params from (null PGtext)) | |
Defined in Squeal.PostgreSQL.Expression Methods mempty :: Expression outer commons grp schemas params from (null PGtext) # mappend :: Expression outer commons grp schemas params from (null PGtext) -> Expression outer commons grp schemas params from (null PGtext) -> Expression outer commons grp schemas params from (null PGtext) # mconcat :: [Expression outer commons grp schemas params from (null PGtext)] -> Expression outer commons grp schemas params from (null PGtext) # | |
| Monoid (Expression outer commons grp schemas params from (null PGtsvector)) | |
Defined in Squeal.PostgreSQL.Expression Methods mempty :: Expression outer commons grp schemas params from (null PGtsvector) # mappend :: Expression outer commons grp schemas params from (null PGtsvector) -> Expression outer commons grp schemas params from (null PGtsvector) -> Expression outer commons grp schemas params from (null PGtsvector) # mconcat :: [Expression outer commons grp schemas params from (null PGtsvector)] -> Expression outer commons grp schemas params from (null PGtsvector) # | |
| NFData (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods rnf :: Expression outer commons grp schemas params from ty -> () # | |
| RenderSQL (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression Methods renderSQL :: Expression outer commons grp schemas params from ty -> ByteString # | |
| type Rep (Expression outer commons grp schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression type Rep (Expression outer commons grp schemas params from ty) = D1 (MetaData "Expression" "Squeal.PostgreSQL.Expression" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeExpression" PrefixI True) (S1 (MetaSel (Just "renderExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) | |
type Expr (x :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas 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 :: NullityType) (x2 :: NullityType) (y :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x1 | left input |
| -> Expression outer commons grp schemas params from x2 | right input |
| -> Expression outer commons grp schemas params from y | output |
A RankNType for binary operators.
type (:-->) (x :: NullityType) (y :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). Expression outer commons grp schemas params from x | input |
| -> Expression outer commons grp schemas params from y | output |
type FunctionN (xs :: [NullityType]) (y :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). NP (Expression outer commons grp schemas params from) xs | inputs |
| -> Expression outer commons grp schemas params from y | output |
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 FunctionVar (x0 :: NullityType) (x1 :: NullityType) (y :: NullityType) #
Arguments
| = forall (outer :: FromType) (commons :: FromType) (grp :: Grouping) (schemas :: SchemasType) (params :: [NullityType]) (from :: FromType). [Expression outer commons grp schemas params from x0] | inputs |
| -> Expression outer commons grp schemas params from x1 | must have at least 1 input |
| -> Expression outer commons grp schemas params from y | output |
A RankNType for functions with a variable-length list of
homogeneous arguments and at least 1 more argument.
class PGSubset (container :: k) where #
Contained by operators
Minimal complete definition
Nothing
Methods
(@>) :: Operator (null0 container) (null1 container) (Null PGbool) #
(<@) :: Operator (null0 container) (null1 container) (Null PGbool) #
Instances
| PGSubset PGtsquery | |
| PGSubset PGjsonb | |
| PGSubset (PGvararray ty :: PGType) | |
Defined in Squeal.PostgreSQL.Expression Methods (@>) :: Operator (null0 (PGvararray ty)) (null1 (PGvararray ty)) (Null PGbool) # (<@) :: Operator (null0 (PGvararray ty)) (null1 (PGvararray ty)) (Null PGbool) # | |
type family PG hask :: PGType #
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
>>>newtype MyDouble = My Double>>>:set -XTypeFamilies>>>type instance PG MyDouble = '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, NullityType)] = '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]
Equations
| RowPG hask = RowOf (RecordCodeOf hask) |
type family NullPG hask :: NullityType where ... #
NullPG turns a Haskell type into a NullityType.
>>>:kind! NullPG DoubleNullPG Double :: NullityType = 'NotNull 'PGfloat8>>>:kind! NullPG (Maybe Double)NullPG (Maybe Double) :: NullityType = 'Null 'PGfloat8
type family TuplePG hask :: [NullityType] where ... #
TuplePG turns a Haskell tuple type (including record types) into
the corresponding list of NullityTypes.
>>>:kind! TuplePG (Double, Maybe Char)TuplePG (Double, Maybe Char) :: [NullityType] = '[ 'NotNull 'PGfloat8, 'Null ('PGchar 1)]
Equations
| TuplePG hask = TupleOf (TupleCodeOf hask (Code hask)) |
type family TupleOf (tuple :: [Type]) :: [NullityType] where ... #
TupleOf turns a list of Haskell Types into a list of NullityTypes.
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 ': ([] :: [[Type]])) = 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) = constructors | |
| ConstructorsOf (Newtype _module _datatype constructor) = constructor ': ([] :: [ConstructorInfo]) |
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.
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 :: NullityType where ... #
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 |
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 }.
>>>import Control.Monad (void)>>>import Control.Monad.IO.Class (liftIO)>>>import Squeal.PostgreSQL>>>:{let roundTrip :: Query_ (Public '[]) (Only Money) (Only Money) roundTrip = values_ $ parameter @1 money `as` #fromOnly :}
>>>let input = Only (Money 20020)
>>>:{withConnection "host=localhost port=5432 dbname=exampledb" $ do result <- runQueryParams roundTrip input Just output <- firstRow result liftIO . print $ input == output :} True
The Json newtype is an indication that the Haskell
type it's applied to should be stored as a PGjson.
Instances
| FromJSON x => FromValue PGjson (Json x) | |
Defined in Squeal.PostgreSQL.Binary | |
| Eq hask => Eq (Json hask) | |
| Ord hask => Ord (Json hask) | |
| Read hask => Read (Json hask) | |
| Show hask => Show (Json hask) | |
| Generic (Json hask) | |
| ToJSON hask => Literal (Json hask) | |
| ToJSON x => ToParam (Json x) PGjson | |
| type Rep (Json hask) | |
Defined in Squeal.PostgreSQL.PG | |
| type PG (Json hask) | |
Defined in Squeal.PostgreSQL.PG | |
The Jsonb newtype is an indication that the Haskell
type it's applied to should be stored as a PGjsonb.
Instances
| FromJSON x => FromValue PGjsonb (Jsonb x) | |
Defined in Squeal.PostgreSQL.Binary | |
| Eq hask => Eq (Jsonb hask) | |
| Ord hask => Ord (Jsonb hask) | |
Defined in Squeal.PostgreSQL.PG | |
| Read hask => Read (Jsonb hask) | |
| Show hask => Show (Jsonb hask) | |
| Generic (Jsonb hask) | |
| ToJSON hask => Literal (Jsonb hask) | |
| ToJSON x => ToParam (Jsonb x) PGjsonb | |
| type Rep (Jsonb hask) | |
Defined in Squeal.PostgreSQL.PG | |
| type PG (Jsonb hask) | |
Defined in Squeal.PostgreSQL.PG | |
The Composite newtype is an indication that the Haskell
type it's applied to should be stored as a PGcomposite.
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.
Constructors
| Enumerated | |
Fields
| |
Instances
The VarArray newtype is an indication that the Haskell
type it's applied to should be stored as a PGvararray.
>>>: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
| Eq arr => Eq (FixArray arr) | |
| Ord arr => Ord (FixArray arr) | |
Defined in Squeal.PostgreSQL.PG | |
| Read arr => Read (FixArray arr) | |
| Show arr => Show (FixArray arr) | |
| Generic (FixArray arr) | |
| (ToFixArray x dims ty, ty ~ nullity pg, HasOid pg) => ToParam (FixArray x) (PGfixarray dims ty) | |
Defined in Squeal.PostgreSQL.Binary | |
| FromFixArray dims ty y => FromValue (PGfixarray dims ty) (FixArray y) | |
Defined in Squeal.PostgreSQL.Binary | |
| type Rep (FixArray arr) | |
Defined in Squeal.PostgreSQL.PG | |
| type PG (FixArray hask) |
|
Defined in Squeal.PostgreSQL.PG | |
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 NullityType | variable length array |
| PGfixarray [Nat] NullityType | 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 |
| UnsafePGType Symbol | an escape hatch for unsupported PostgreSQL types |
Instances
data NullityType #
NullityType 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 :: NullityType>>>:kind 'NotNull ('PGvarchar 50)'NotNull ('PGvarchar 50) :: NullityType
Instances
| (Has tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons (Grouped bys) schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| Aggregate (Distinction (Expression outer commons Ungrouped schemas params from)) (Distinction (NP (Expression outer commons Ungrouped schemas params from)) :: [NullityType] -> Type) (Expression outer commons (Grouped bys) schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods countStar :: Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # count :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (NotNull PGint8) # sum_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGSum ty)) # arrayAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null (PGvararray ty)) # jsonAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjson) # jsonbAgg :: Distinction (Expression outer commons Ungrouped schemas params from) ty -> Expression outer commons (Grouped bys) schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # bitOr :: In int PGIntegral => Distinction (Expression outer commons Ungrouped schemas params from) (null int) -> Expression outer commons (Grouped bys) schemas params from (Null int) # boolAnd :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # boolOr :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # every :: Distinction (Expression outer commons Ungrouped schemas params from) (null PGbool) -> Expression outer commons (Grouped bys) schemas params from (Null PGbool) # max_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # min_ :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null ty) # avg :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # corr :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarPop :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # covarSamp :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgX :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrAvgY :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrCount :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGint8) # regrIntercept :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrR2 :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSlope :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxx :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSxy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # regrSyy :: Distinction (NP (Expression outer commons Ungrouped schemas params from)) (null PGfloat8 ': (null PGfloat8 ': [])) -> Expression outer commons (Grouped bys) schemas params from (Null PGfloat8) # stddev :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # stddevSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # variance :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varPop :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # varSamp :: Distinction (Expression outer commons Ungrouped schemas params from) (null ty) -> Expression outer commons (Grouped bys) schemas params from (Null (PGAvg ty)) # | |
| (HasUnique tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons Ungrouped schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: NP (Expression outer commons (Grouped bys) schemas params from) tys # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons Ungrouped schemas params from) column # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons (Grouped bys) schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons (Grouped bys) schemas params from) column # | |
| (KnownSymbol alias, PGTyped schemas ty) => FieldTyped schemas (alias ::: ty) | |
Defined in Squeal.PostgreSQL.Definition Methods fieldtype :: Aliased (TypeExpression schemas) (alias ::: ty) # | |
| (KnownNat n, HasParameter (n - 1) params ty) => HasParameter n (ty' ': params) ty | |
Defined in Squeal.PostgreSQL.Expression.Parameter Methods parameter :: TypeExpression schemas ty -> Expression outer commons grp schemas (ty' ': params) from ty # | |
| HasParameter 1 (ty1 ': tys) ty1 | |
Defined in Squeal.PostgreSQL.Expression.Parameter Methods parameter :: TypeExpression schemas ty1 -> Expression outer commons grp schemas (ty1 ': tys) from ty1 # | |
| (KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (AlignedList (CommonTableExpression statement schemas params) commons commons1) | |
Defined in Squeal.PostgreSQL.Query Methods as :: statement commons schemas params common -> Alias cte -> AlignedList (CommonTableExpression statement schemas params) commons commons1 # | |
| Aggregate (Expression outer commons grp schemas params from) (NP (Expression outer commons grp schemas params from) :: [NullityType] -> Type) (WindowFunction outer commons grp schemas params from) | |
Defined in Squeal.PostgreSQL.Expression.Window Methods countStar :: WindowFunction outer commons grp schemas params from (NotNull PGint8) # count :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (NotNull PGint8) # sum_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGSum ty)) # arrayAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null (PGvararray ty)) # jsonAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjson) # jsonbAgg :: Expression outer commons grp schemas params from ty -> WindowFunction outer commons grp schemas params from (Null PGjsonb) # bitAnd :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # bitOr :: In int PGIntegral => Expression outer commons grp schemas params from (null int) -> WindowFunction outer commons grp schemas params from (Null int) # boolAnd :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # boolOr :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # every :: Expression outer commons grp schemas params from (null PGbool) -> WindowFunction outer commons grp schemas params from (Null PGbool) # max_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # min_ :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null ty) # avg :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # corr :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarPop :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # covarSamp :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgX :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrAvgY :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrCount :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGint8) # regrIntercept :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrR2 :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSlope :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxx :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSxy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # regrSyy :: NP (Expression outer commons grp schemas params from) (null PGfloat8 ': (null PGfloat8 ': [])) -> WindowFunction outer commons grp schemas params from (Null PGfloat8) # stddev :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # stddevSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # variance :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varPop :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # varSamp :: Expression outer commons grp schemas params from (null ty) -> WindowFunction outer commons grp schemas params from (Null (PGAvg ty)) # | |
| JsonBuildObject ([] :: [NullityType]) | |
Defined in Squeal.PostgreSQL.Expression.Json Methods jsonBuildObject :: FunctionN [] (null PGjson) # jsonbBuildObject :: FunctionN [] (null PGjsonb) # | |
| Additional (Selection outer commons grp schemas params from :: RowType -> Type) | |
| NFData (Distinction (Expression outer commons grp schemas params from) ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods rnf :: Distinction (Expression outer commons grp schemas params from) ty -> () # | |
| HasOid ty => HasAliasedOid (alias ::: nullity ty) | |
Defined in Squeal.PostgreSQL.Binary Methods aliasedOid :: Word32 # | |
| (JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject (NotNull key ': (value ': tys)) | |
Defined in Squeal.PostgreSQL.Expression.Json Methods jsonBuildObject :: FunctionN (NotNull key ': (value ': tys)) (null PGjson) # jsonbBuildObject :: FunctionN (NotNull key ': (value ': tys)) (null PGjsonb) # | |
| SListI tys => RenderSQL (Distinction (NP (Expression outer commons grp schemas params from)) tys) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (NP (Expression outer commons grp schemas params from)) tys -> ByteString # | |
| RenderSQL (Distinction (Expression outer commons grp schemas params from) ty) | |
Defined in Squeal.PostgreSQL.Expression.Aggregate Methods renderSQL :: Distinction (Expression outer commons grp schemas params from) ty -> ByteString # | |
| ToNullityParam x ty => ToField (alias ::: x) (alias ::: ty) | |
| FromValue pg y => FromField (column ::: NotNull pg) (column ::: y) | |
| FromValue pg y => FromField (column ::: Null pg) (column ::: Maybe y) | |
| ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> nullity0 ty0)) (alias1 ::: (def1 :=> nullity1 ty1)) | |
Defined in Squeal.PostgreSQL.Schema | |
| AddColumn (NoDef :=> Null ty) | |
Defined in Squeal.PostgreSQL.Definition | |
| AddColumn (Def :=> ty) | |
Defined in Squeal.PostgreSQL.Definition | |
| IsString (Selection outer commons grp schemas params from (("fromOnly" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))) | |
Defined in Squeal.PostgreSQL.Query | |
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
a ColumnConstraint with a NullityType to produce a ColumnType
or a TableConstraints and a ColumnsType to produce a TableType.
data ColumnConstraint #
ColumnConstraint 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
| ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> nullity0 ty0)) (alias1 ::: (def1 :=> nullity1 ty1)) | |
Defined in Squeal.PostgreSQL.Schema | |
| AddColumn (NoDef :=> Null ty) | |
Defined in Squeal.PostgreSQL.Definition | |
| AddColumn (Def :=> ty) | |
Defined in Squeal.PostgreSQL.Definition | |
type ColumnType = (ColumnConstraint, NullityType) #
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.
Constructors
| Check [Symbol] | |
| Unique [Symbol] | |
| PrimaryKey [Symbol] | |
| ForeignKey [Symbol] Symbol [Symbol] |
Instances
| SListI (TableToColumns table) => RenderSQL (ConflictClause tab commons schemas params table) | Render a |
Defined in Squeal.PostgreSQL.Manipulation Methods renderSQL :: ConflictClause tab commons schemas params table -> ByteString # | |
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) :: Constraint 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 RowType = [(Symbol, NullityType)] #
A RowType is a row of NullityType. They correspond to Haskell
record types by means of RowPG and are used in many places.
>>>:{type family PersonRow :: RowType where PersonRow = '[ "name" ::: 'NotNull 'PGtext , "age" ::: 'NotNull 'PGint4 , "dateOfBirth" ::: 'Null 'PGdate ] :}
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 ([] :: [(Symbol, ColumnType)]) = ([] :: [(Symbol, NullityType)]) | |
| ColumnsToRow ((column ::: (constraint :=> ty)) ': columns) = (column ::: ty) ': ColumnsToRow columns |
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 ': ([] :: [PGType])))))) #
Numeric Postgres types.
type PGFloating = PGfloat4 ': (PGfloat8 ': (PGnumeric ': ([] :: [PGType]))) #
Floating Postgres types.
type family PGTypeOf (ty :: NullityType) :: PGType where ... #
PGTypeOf forgets about NULL and any column constraints.
Equations
| PGTypeOf (nullity pg) = pg |
class SamePGType (ty0 :: (Symbol, ColumnType)) (ty1 :: (Symbol, ColumnType)) #
Equality constraint on the underlying PGType of two columns.
Instances
| ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> nullity0 ty0)) (alias1 ::: (def1 :=> nullity1 ty1)) | |
Defined in Squeal.PostgreSQL.Schema | |
type family AllNotNull (columns :: ColumnsType) :: Constraint where ... #
AllNotNull is a constraint that proves a ColumnsType has no NULLs.
Equations
| AllNotNull ([] :: [(Symbol, ColumnType)]) = () | |
| AllNotNull ((column ::: (def :=> NotNull ty)) ': columns) = AllNotNull columns |
type family NotAllNull (columns :: ColumnsType) :: Constraint where ... #
NotAllNull is a constraint that proves a ColumnsType has some
NOT NULL.
Equations
| NotAllNull ((column ::: (def :=> NotNull ty)) ': columns) = () | |
| NotAllNull ((column ::: (def :=> Null ty)) ': columns) = NotAllNull columns |
type family NullifyType (ty :: NullityType) :: NullityType where ... #
NullifyType is an idempotent that nullifies a NullityType.
Equations
| NullifyType (Null ty) = Null ty | |
| NullifyType (NotNull ty) = Null ty |
type family NullifyRow (columns :: RowType) :: RowType where ... #
NullifyRow is an idempotent that nullifies a RowType.
Equations
| NullifyRow ([] :: [(Symbol, NullityType)]) = ([] :: [(Symbol, NullityType)]) | |
| NullifyRow ((column ::: ty) ': columns) = (column ::: NullifyType ty) ': NullifyRow columns |
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 ([] :: [(Symbol, RowType)]) = ([] :: [(Symbol, RowType)]) | |
| NullifyFrom ((table ::: columns) ': tables) = (table ::: NullifyRow columns) ': NullifyFrom tables |
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) ': ([] :: [(Symbol, k)]) | |
| Create alias (x :: k) ((alias ::: y) ': xs :: [(Symbol, k)]) = (TypeError ((Text "Create: alias " :<>: ShowType alias) :<>: Text "already in use") :: [(Symbol, k)]) | |
| Create alias (y :: k) (x ': xs :: [(Symbol, k)]) = x ': Create 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 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.
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.
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 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-defined type, either a Table,
View or Typedef.
Instances
| Category Definition | |
Defined in Squeal.PostgreSQL.Definition | |
| (IndexedMonadTransPQ trans, Monad monad, forall (x0 :: SchemasType) (x1 :: SchemasType). x0 ~ x1 => Monad (trans x0 x1 monad)) => Category (Terminally trans monad :: SchemasType -> SchemasType -> Type) | |
Defined in Squeal.PostgreSQL.Migration Methods id :: Terminally trans monad a a # (.) :: Terminally trans monad b c -> Terminally trans monad a b -> Terminally trans monad a c # | |
| Migratory (Terminally PQ IO) | |
Defined in Squeal.PostgreSQL.Migration Methods migrateUp :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas0 schemas1 IO () # migrateDown :: AlignedList (Migration (Terminally PQ IO)) schemas0 schemas1 -> PQ schemas1 schemas0 IO () # | |
type SchemaType = [(Symbol, SchemumType)] #
The 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"] "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.
Equations
| Public schema = ("public" ::: schema) ': ([] :: [(Symbol, SchemaType)]) |
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.Schema | |
| labels ~ (label ': ([] :: [Symbol])) => IsPGlabel label (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Schema | |
| (KnownSymbol label, In label labels) => IsPGlabel label (Expression outer commons grp schemas params from (null (PGenum labels))) | |
Defined in Squeal.PostgreSQL.Expression Methods label :: Expression outer commons grp schemas params from (null (PGenum labels)) # | |
data PGlabel (label :: Symbol) #
Constructors
| PGlabel |
Instances
| label ~ label1 => IsPGlabel label (PGlabel label1) | |
Defined in Squeal.PostgreSQL.Schema | |
| labels ~ (label ': ([] :: [Symbol])) => IsPGlabel label (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Schema | |
| KnownSymbol label => RenderSQL (PGlabel label) | |
Defined in Squeal.PostgreSQL.Schema Methods renderSQL :: PGlabel label -> ByteString # | |
| All KnownSymbol labels => RenderSQL (NP PGlabel labels) | |
Defined in Squeal.PostgreSQL.Schema Methods renderSQL :: NP PGlabel labels -> ByteString # | |
type PGJsonType = PGjson ': (PGjsonb ': ([] :: [PGType])) #
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.Schema | |
| (TypeError ((Text "Cannot assign to " :<>: ShowType alias) :<>: Text " more than once") :: Constraint) => IsNotElem ((,) alias a :: (k2, k1)) True | |
Defined in Squeal.PostgreSQL.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.Schema | |
| (IsNotElem x (Elem x xs), AllUnique xs) => AllUnique (x ': xs :: [(Symbol, a)]) | |
Defined in Squeal.PostgreSQL.Schema | |
renderAliased :: (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.Alias | |
| (KnownSymbol table, KnownSymbol column, GroupedBy table column bys) => GroupedBy table column (tabcol ': bys :: [a]) | |
Defined in Squeal.PostgreSQL.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 table column (Alias table, Alias column) | |
| alias1 ~ alias2 => IsLabel alias1 (Alias alias2) | |
Defined in Squeal.PostgreSQL.Alias | |
| aliases ~ (alias ': ([] :: [Symbol])) => IsLabel alias (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Alias | |
| (alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) | |
| Eq (Alias alias) | |
| Ord (Alias alias) | |
Defined in Squeal.PostgreSQL.Alias | |
| Show (Alias alias) | |
| Generic (Alias alias) | |
| NFData (Alias alias) | |
Defined in Squeal.PostgreSQL.Alias | |
| KnownSymbol alias => RenderSQL (Alias alias) |
|
Defined in Squeal.PostgreSQL.Alias Methods renderSQL :: Alias alias -> ByteString # | |
| All KnownSymbol aliases => RenderSQL (NP Alias aliases) | |
Defined in Squeal.PostgreSQL.Alias Methods renderSQL :: NP Alias aliases -> ByteString # | |
| type Rep (Alias alias) | |
data Aliased (expression :: k -> Type) (aliased :: (Symbol, k)) :: forall k. (k -> Type) -> (Symbol, k) -> Type 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 (expression :: k -> Type) (aliased :: (Symbol, k)) (alias :: Symbol) (ty :: k). KnownSymbol alias => expression ty -> Alias alias -> Aliased expression ((,) alias ty) |
Instances
| (Has tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons (Grouped bys) schemas 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.Alias | |
| (KnownSymbol alias, tys ~ ((alias ::: ty) ': ([] :: [(Symbol, k)]))) => Aliasable alias (expression ty) (NP (Aliased expression) tys) | |
| (KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) | |
Defined in Squeal.PostgreSQL.Alias | |
| (HasUnique tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsLabel col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons Ungrouped schemas params from) column # | |
| (HasUnique tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons (Grouped bys) schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression Methods fromLabel :: Aliased (Expression outer commons (Grouped bys) schemas 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.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.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) ': ([] :: [(Symbol, k)]))) => Aliasable alias (expression ty) (NP (Aliased expression) tys) | |
| (KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) | |
Defined in Squeal.PostgreSQL.Alias | |
| (KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (AlignedList (CommonTableExpression statement schemas params) commons commons1) | |
Defined in Squeal.PostgreSQL.Query Methods as :: statement commons schemas params common -> Alias cte -> AlignedList (CommonTableExpression statement schemas params) commons commons1 # | |
| (KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (CommonTableExpression statement schemas params commons commons1) | |
Defined in Squeal.PostgreSQL.Query Methods as :: statement commons schemas params common -> Alias cte -> CommonTableExpression statement schemas params commons commons1 # | |
| (KnownSymbol col, row ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => Aliasable col (Expression outer commons grp schemas params from ty) (Selection outer commons grp schemas params from row) | |
Defined in Squeal.PostgreSQL.Query Methods as :: Expression outer commons grp schemas params from ty -> Alias col -> Selection outer commons grp schemas params from row # | |
type HasUnique (alias :: Symbol) (fields :: [(Symbol, k)]) (field :: k) = fields ~ ((alias ::: field) ': ([] :: [(Symbol, k)])) #
HasUnique alias fields field is a constraint that proves that
fields is a singleton of alias ::: field.
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.Alias | |
| (Has alias fields field, HasAll aliases fields subfields) => HasAll (alias ': aliases) (fields :: [(Symbol, k)]) ((alias ::: field) ': subfields :: [(Symbol, k)]) | |
Defined in Squeal.PostgreSQL.Alias | |
class IsQualified (table :: Symbol) (column :: 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 table column (Alias table, Alias column) | |
| (q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.Alias Methods (!) :: Alias q -> Alias a -> QualifiedAlias q' a' # | |
| (Has rel rels cols, Has col cols ty, bys ~ ((,) rel col ': ([] :: [(Symbol, Symbol)]))) => IsQualified rel col (NP (By rels) bys) | |
| (Has tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons Ungrouped schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, tys ~ (ty ': ([] :: [NullityType]))) => IsQualified tab col (NP (Expression outer commons (Grouped bys) schemas params from) tys) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, columns ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons Ungrouped schemas params from) column) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys, column ~ (col ::: ty)) => IsQualified tab col (Aliased (Expression outer commons (Grouped bys) schemas 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.Alias | |
| (Has tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)]))) => IsQualified tab col (Selection outer commons Ungrouped schemas params from row1) | |
| (Has tab (Join outer from) row0, Has col row0 ty, row1 ~ ((col ::: ty) ': ([] :: [(Symbol, NullityType)])), GroupedBy tab col bys) => IsQualified tab col (Selection outer commons (Grouped bys) schemas params from row1) | |
| (Has tab (Join outer from) row, Has col row ty) => IsQualified tab col (Expression outer commons Ungrouped schemas params from ty) | |
Defined in Squeal.PostgreSQL.Expression | |
| (Has tab (Join outer from) row, Has col row ty, GroupedBy tab col bys) => IsQualified tab col (Expression outer commons (Grouped bys) schemas 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.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.Alias | |
| (q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') | |
Defined in Squeal.PostgreSQL.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.Alias Methods fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) # | |
| Eq (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.Alias Methods (==) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # (/=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool # | |
| Ord (QualifiedAlias qualifier alias) | |
Defined in Squeal.PostgreSQL.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.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.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.Alias Methods rnf :: QualifiedAlias qualifier alias -> () # | |
| (KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) | |
Defined in Squeal.PostgreSQL.Alias Methods renderSQL :: QualifiedAlias q a -> ByteString # | |
| type Rep (QualifiedAlias qualifier alias) | |
single :: p x0 x1 -> AlignedList p x0 x1 #
A single step.
mapAligned :: (forall (z0 :: k) (z1 :: k). p z0 z1 -> q z0 z1) -> AlignedList p x0 x1 -> AlignedList q x0 x1 #
mapAligned applies a function to each element of an AlignedList.
extractList :: (forall (a0 :: k) (a1 :: k). p a0 a1 -> b) -> AlignedList p x0 x1 -> [b] #
extractList turns an AlignedList into a standard list.
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 outer commons schemas params :: [a] -> Type) | |
Defined in Squeal.PostgreSQL.Query Methods also :: FromClause outer commons schemas params ys -> FromClause outer commons schemas params xs -> FromClause outer commons schemas params (Join xs ys) # | |
| Additional (Selection outer commons grp schemas params from :: RowType -> Type) | |
data AlignedList (p :: k -> k -> Type) (x0 :: k) (x1 :: k) :: forall k. (k -> k -> Type) -> k -> k -> Type where #
An AlignedList is a type-aligned list or free category.
Constructors
| Done :: forall k (p :: k -> k -> Type) (x0 :: k) (x1 :: k). AlignedList p x0 x0 | |
| (:>>) :: forall k (p :: k -> k -> Type) (x0 :: k) (x1 :: k) (x2 :: k). p x0 x2 -> AlignedList p x2 x1 -> AlignedList p x0 x1 infixr 7 |
Instances
| Category (AlignedList p :: k -> k -> Type) | |
Defined in Squeal.PostgreSQL.List Methods id :: AlignedList p a a # (.) :: AlignedList p b c -> AlignedList p a b -> AlignedList p a c # | |
| (KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (AlignedList (CommonTableExpression statement schemas params) commons commons1) | |
Defined in Squeal.PostgreSQL.Query Methods as :: statement commons schemas params common -> Alias cte -> AlignedList (CommonTableExpression statement schemas params) commons commons1 # | |
| (forall (t0 :: k) (t1 :: k). RenderSQL (p t0 t1)) => RenderSQL (AlignedList p x0 x1) | |
Defined in Squeal.PostgreSQL.List Methods renderSQL :: AlignedList p x0 x1 -> ByteString # | |
type family In (x :: t) (xs :: [t]) :: Constraint where ... #
In x xs is a constraint that proves that x is in xs.
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
A class for rendering SQL
Methods
renderSQL :: sql -> ByteString #
Instances
module Control.Algebra