fused-effects-squeal-0.1.0.0: A fused-effects adapter for squeal-postgresql.

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Squeal

Contents

Synopsis

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 # 
Instance details

Defined in Control.Effect.Squeal

Methods

hmap :: Functor m => (forall x. m x -> n x) -> Squeal schemas m a -> Squeal schemas n a #

Effect (Squeal schemas :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Control.Effect.Squeal

Methods

thread :: (Functor ctx, Monad m) => ctx () -> (forall x. ctx (m x) -> n (ctx x)) -> Squeal schemas m a -> Squeal schemas n (ctx a) #

(MonadUnliftIO m, Algebra sig m) => Algebra ((Squeal schemas :: (Type -> Type) -> Type -> Type) :+: sig) (SquealC schemas m) Source # 
Instance details

Defined in Control.Carrier.Squeal

Methods

alg :: (Squeal schemas :+: sig) (SquealC schemas m) a -> SquealC schemas m a #

Functor m => Functor (Squeal schemas m) Source # 
Instance details

Defined in Control.Effect.Squeal

Methods

fmap :: (a -> b) -> Squeal schemas m a -> Squeal schemas m b #

(<$) :: a -> Squeal schemas m b -> Squeal schemas m a #

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 # 
Instance details

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 # 
Instance details

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 # 
Instance details

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 #

Methods

fromLabel :: a #

Instances
alias1 ~ alias2 => IsLabel alias1 (Alias alias2) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Alias alias2 #

(HasUnique rel rels cols, Has col cols ty, by ~ (,) rel col) => IsLabel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: By rels by #

(q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: NP (By rels) bys #

(HasUnique tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons Ungrouped schemas params from) tys) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: NP Alias aliases #

(alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Aliased Alias (alias1 ::: alias2) #

(q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: Selection outer commons Ungrouped schemas params from row1 #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: Selection outer commons (Grouped bys) schemas params from row1 #

(HasUnique tab (Join outer from) row, Has col row ty) => IsLabel col (Expression outer commons Ungrouped schemas params from ty) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: Expression outer commons (Grouped bys) schemas params from ty #

(>>>) :: Category cat => cat a b -> cat b c -> cat a c infixr 1 #

Left-to-right composition

(&) :: a -> (a -> b) -> b infixl 1 #

& is a reverse application operator. This provides notational convenience. Its precedence is one higher than that of the forward application operator $, which allows & to be nested in $.

>>> 5 & (+1) & show
"6"

Since: base-4.8.0.0

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

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftEq2 :: (a -> b -> Bool) -> (c -> d -> Bool) -> K a c -> K b d -> Bool #

Ord2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftCompare2 :: (a -> b -> Ordering) -> (c -> d -> Ordering) -> K a c -> K b d -> Ordering #

Read2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.4.0

Instance details

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

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftShowsPrec2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> Int -> K a b -> ShowS #

liftShowList2 :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> (Int -> b -> ShowS) -> ([b] -> ShowS) -> [K a b] -> ShowS #

NFData2 (K :: Type -> Type -> Type)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftRnf2 :: (a -> ()) -> (b -> ()) -> K a b -> () #

Functor (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

fmap :: (a0 -> b) -> K a a0 -> K a b #

(<$) :: a0 -> K a b -> K a a0 #

Monoid a => Applicative (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

pure :: a0 -> K a a0 #

(<*>) :: K a (a0 -> b) -> K a a0 -> K a b #

liftA2 :: (a0 -> b -> c) -> K a a0 -> K a b -> K a c #

(*>) :: K a a0 -> K a b -> K a b #

(<*) :: K a a0 -> K a b -> K a a0 #

Foldable (K a :: Type -> Type) 
Instance details

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 #

toList :: K a a0 -> [a0] #

null :: K a a0 -> Bool #

length :: K a a0 -> Int #

elem :: Eq a0 => a0 -> K a a0 -> Bool #

maximum :: Ord a0 => K a a0 -> a0 #

minimum :: Ord a0 => K a a0 -> a0 #

sum :: Num a0 => K a a0 -> a0 #

product :: Num a0 => K a a0 -> a0 #

Traversable (K a :: Type -> Type) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

traverse :: Applicative f => (a0 -> f b) -> K a a0 -> f (K a b) #

sequenceA :: Applicative f => K a (f a0) -> f (K a a0) #

mapM :: Monad m => (a0 -> m b) -> K a a0 -> m (K a b) #

sequence :: Monad m => K a (m a0) -> m (K a a0) #

Eq a => Eq1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftEq :: (a0 -> b -> Bool) -> K a a0 -> K a b -> Bool #

Ord a => Ord1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftCompare :: (a0 -> b -> Ordering) -> K a a0 -> K a b -> Ordering #

Read a => Read1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftReadsPrec :: (Int -> ReadS a0) -> ReadS [a0] -> Int -> ReadS (K a a0) #

liftReadList :: (Int -> ReadS a0) -> ReadS [a0] -> ReadS [K a a0] #

liftReadPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec (K a a0) #

liftReadListPrec :: ReadPrec a0 -> ReadPrec [a0] -> ReadPrec [K a a0] #

Show a => Show1 (K a :: Type -> Type)

Since: sop-core-0.2.4.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftShowsPrec :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> Int -> K a a0 -> ShowS #

liftShowList :: (Int -> a0 -> ShowS) -> ([a0] -> ShowS) -> [K a a0] -> ShowS #

NFData a => NFData1 (K a :: Type -> Type)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

liftRnf :: (a0 -> ()) -> K a a0 -> () #

Eq a => Eq (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

(==) :: K a b -> K a b -> Bool #

(/=) :: K a b -> K a b -> Bool #

Ord a => Ord (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

compare :: K a b -> K a b -> Ordering #

(<) :: K a b -> K a b -> Bool #

(<=) :: K a b -> K a b -> Bool #

(>) :: K a b -> K a b -> Bool #

(>=) :: K a b -> K a b -> Bool #

max :: K a b -> K a b -> K a b #

min :: K a b -> K a b -> K a b #

Read a => Read (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

readsPrec :: Int -> ReadS (K a b) #

readList :: ReadS [K a b] #

readPrec :: ReadPrec (K a b) #

readListPrec :: ReadPrec [K a b] #

Show a => Show (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Methods

showsPrec :: Int -> K a b -> ShowS #

show :: K a b -> String #

showList :: [K a b] -> ShowS #

Generic (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

Associated Types

type Rep (K a b) :: Type -> Type #

Methods

from :: K a b -> Rep (K a b) x #

to :: Rep (K a b) x -> K a b #

Semigroup a => Semigroup (K a b)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

(<>) :: K a b -> K a b -> K a b #

sconcat :: NonEmpty (K a b) -> K a b #

stimes :: Integral b0 => b0 -> K a b -> K a b #

Monoid a => Monoid (K a b)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

mempty :: K a b #

mappend :: K a b -> K a b -> K a b #

mconcat :: [K a b] -> K a b #

NFData a => NFData (K a b)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.BasicFunctors

Methods

rnf :: K a b -> () #

type Rep (K a b) 
Instance details

Defined in Data.SOP.BasicFunctors

type Rep (K a b) = D1 (MetaData "K" "Data.SOP.BasicFunctors" "sop-core-0.4.0.0-F1xCWaFkXPd3dWDWBPXHJg" True) (C1 (MetaCons "K" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 a)))
type Code (K a b) 
Instance details

Defined in Generics.SOP.Instances

type Code (K a b) = (a ': ([] :: [Type])) ': ([] :: [[Type]])
type DatatypeInfoOf (K a b) 
Instance details

Defined in Generics.SOP.Instances

type DatatypeInfoOf (K a b) = Newtype "Data.SOP.BasicFunctors" "K" (Constructor "K")

unK :: K a b -> a #

Extract the contents of a K value.

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 K a, 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.

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias rel -> Alias 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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons Ungrouped schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons (Grouped bys) schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

HTrans (NP :: (k1 -> Type) -> [k1] -> Type) (NP :: (k2 -> Type) -> [k2] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

htrans :: AllZipN (Prod NP) c xs ys => proxy c -> (forall (x :: k10) (y :: k20). c x y => f x -> g y) -> NP f xs -> NP g ys #

hcoerce :: (AllZipN (Prod NP) (LiftedCoercible f g) xs ys, HTrans NP NP) => NP f xs -> NP g ys #

HSequence (NP :: (k -> Type) -> [k] -> Type) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Data.SOP.NP

Methods

hcollapse :: SListIN NP xs => NP (K a) xs -> CollapseTo NP a #

HAp (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hap :: Prod NP (f -.-> g) xs -> NP f xs -> NP g xs #

HPure (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

Methods

hpure :: SListIN NP xs => (forall (a :: k0). f a) -> NP f xs #

hcpure :: AllN NP c xs => proxy c -> (forall (a :: k0). c a => f a) -> NP f xs #

(KnownSymbol alias, tys ~ ((alias ::: ty) ': ([] :: [(Symbol, k)]))) => Aliasable alias (expression ty) (NP (Aliased expression) tys) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

as :: expression ty -> Alias alias -> NP (Aliased expression) tys #

Additional (NP expr :: [a] -> Type) 
Instance details

Defined in Squeal.PostgreSQL.List

Methods

also :: NP expr ys -> NP expr xs -> NP expr (Join xs ys) #

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: NP (By rels) bys #

(HasUnique tab (Join outer from) row, Has col row ty, tys ~ (ty ': ([] :: [NullityType]))) => IsLabel col (NP (Expression outer commons Ungrouped schemas params from) tys) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

aliases ~ (alias ': ([] :: [Symbol])) => IsLabel alias (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: NP Alias aliases #

labels ~ (label ': ([] :: [Symbol])) => IsPGlabel label (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

label :: NP PGlabel labels #

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) 
Instance details

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) 
Instance details

Defined in Data.SOP.NP

Methods

(==) :: NP f xs -> NP f xs -> Bool #

(/=) :: NP f xs -> NP f xs -> Bool #

(All (Compose Eq f) xs, All (Compose Ord f) xs) => Ord (NP f xs) 
Instance details

Defined in Data.SOP.NP

Methods

compare :: NP f xs -> NP f xs -> Ordering #

(<) :: NP f xs -> NP f xs -> Bool #

(<=) :: NP f xs -> NP f xs -> Bool #

(>) :: NP f xs -> NP f xs -> Bool #

(>=) :: NP f xs -> NP f xs -> Bool #

max :: NP f xs -> NP f xs -> NP f xs #

min :: NP f xs -> NP f xs -> NP f xs #

All (Compose Show f) xs => Show (NP f xs) 
Instance details

Defined in Data.SOP.NP

Methods

showsPrec :: Int -> NP f xs -> ShowS #

show :: NP f xs -> String #

showList :: [NP f xs] -> ShowS #

All (Compose Semigroup f) xs => Semigroup (NP f xs)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.NP

Methods

(<>) :: NP f xs -> NP f xs -> NP f xs #

sconcat :: NonEmpty (NP f xs) -> NP f xs #

stimes :: Integral b => b -> NP f xs -> NP f xs #

(All (Compose Monoid f) xs, All (Compose Semigroup f) xs) => Monoid (NP f xs)

Since: sop-core-0.4.0.0

Instance details

Defined in Data.SOP.NP

Methods

mempty :: NP f xs #

mappend :: NP f xs -> NP f xs -> NP f xs #

mconcat :: [NP f xs] -> NP f xs #

All (Compose NFData f) xs => NFData (NP f xs)

Since: sop-core-0.2.5.0

Instance details

Defined in Data.SOP.NP

Methods

rnf :: NP f xs -> () #

All KnownSymbol labels => RenderSQL (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

renderSQL :: NP PGlabel labels -> ByteString #

All KnownSymbol aliases => RenderSQL (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString #

SListI tys => RenderSQL (Distinction (NP (Expression outer commons grp schemas params from)) tys) 
Instance details

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) 
Instance details

Defined in Data.SOP.NP

type Same (NP :: (k1 -> Type) -> [k1] -> Type) = (NP :: (k2 -> Type) -> [k2] -> Type)
type UnProd (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NS

type UnProd (NP :: (k -> Type) -> [k] -> Type) = (NS :: (k -> Type) -> [k] -> Type)
type Prod (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

type Prod (NP :: (k -> Type) -> [k] -> Type) = (NP :: (k -> Type) -> [k] -> Type)
type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a 
Instance details

Defined in Data.SOP.NP

type CollapseTo (NP :: (k -> Type) -> [k] -> Type) a = [a]
type SListIN (NP :: (k -> Type) -> [k] -> Type) 
Instance details

Defined in Data.SOP.NP

type SListIN (NP :: (k -> Type) -> [k] -> Type) = (SListI :: [k] -> Constraint)
type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) 
Instance details

Defined in Data.SOP.NP

type AllN (NP :: (k -> Type) -> [k] -> Type) (c :: k -> Constraint) = All c
type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) 
Instance details

Defined in Data.SOP.NP

type AllZipN (NP :: (k -> Type) -> [k] -> Type) (c :: a -> b -> Constraint) = AllZip c

data Result #

Result encapsulates the result of a query (or more precisely, of a single SQL command --- a query string given to sendQuery can contain multiple commands and thus return multiple instances of Result.

Instances
Eq Result 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

(==) :: Result -> Result -> Bool #

(/=) :: Result -> Result -> Bool #

Show Result 
Instance details

Defined in Database.PostgreSQL.LibPQ

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.

data Row #

Instances
Enum Row 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

succ :: Row -> Row #

pred :: Row -> Row #

toEnum :: Int -> Row #

fromEnum :: Row -> Int #

enumFrom :: Row -> [Row] #

enumFromThen :: Row -> Row -> [Row] #

enumFromTo :: Row -> Row -> [Row] #

enumFromThenTo :: Row -> Row -> Row -> [Row] #

Eq Row 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

(==) :: Row -> Row -> Bool #

(/=) :: Row -> Row -> Bool #

Num Row 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

(+) :: Row -> Row -> Row #

(-) :: Row -> Row -> Row #

(*) :: Row -> Row -> Row #

negate :: Row -> Row #

abs :: Row -> Row #

signum :: Row -> Row #

fromInteger :: Integer -> Row #

Ord Row 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

compare :: Row -> Row -> Ordering #

(<) :: Row -> Row -> Bool #

(<=) :: Row -> Row -> Bool #

(>) :: Row -> Row -> Bool #

(>=) :: Row -> Row -> Bool #

max :: Row -> Row -> Row #

min :: Row -> Row -> Row #

Show Row 
Instance details

Defined in Database.PostgreSQL.LibPQ

Methods

showsPrec :: Int -> Row -> ShowS #

show :: Row -> String #

showList :: [Row] -> ShowS #

data Connection #

Connection encapsulates a connection to the backend.

Instances
Eq Connection 
Instance details

Defined in Database.PostgreSQL.LibPQ.Internal

defaultMain #

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 

Fields

Instances
Generic (Migration p schemas0 schemas1) 
Instance details

Defined in Squeal.PostgreSQL.Migration

Associated Types

type Rep (Migration p schemas0 schemas1) :: Type -> Type #

Methods

from :: Migration p schemas0 schemas1 -> Rep (Migration p schemas0 schemas1) x #

to :: Rep (Migration p schemas0 schemas1) x -> Migration p schemas0 schemas1 #

type Rep (Migration p schemas0 schemas1) 
Instance details

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 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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.

ephemerally_ #

Arguments

:: (MonadUnliftIO tx, MonadPQ schemas tx) 
=> tx x

run inside an ephemeral transaction

-> tx x 

Run a computation ephemerally in defaultMode.

ephemerally #

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.

transactionallyRetry #

Arguments

:: (MonadUnliftIO tx, MonadPQ schemas tx) 
=> TransactionMode 
-> tx x

run inside a transaction

-> tx x 

transactionallyRetry a computation;

  • first begin,
  • then try the computation,
  • if it raises a serialization failure then rollback and restart the transaction,
  • if it raises any other exception then rollback and rethrow the exception,
  • otherwise commit and return the result.

transactionally_ #

Arguments

:: (MonadUnliftIO tx, MonadPQ schemas tx) 
=> tx x

run inside a transaction

-> tx x 

Run a computation transactionally_, in defaultMode.

transactionally #

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 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.

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.

Constructors

ReadWrite 
ReadOnly 
Instances
Eq AccessMode 
Instance details

Defined in Squeal.PostgreSQL.Transaction

Show AccessMode 
Instance details

Defined in Squeal.PostgreSQL.Transaction

RenderSQL AccessMode

Render an AccessMode.

Instance details

Defined in Squeal.PostgreSQL.Transaction

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 

class Literal hask where #

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'

Methods

literal :: hask -> Expr (null (PG hask)) #

Instances
Literal Bool 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Bool -> Expr (null (PG Bool)) #

Literal Char 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Char -> Expr (null (PG Char)) #

Literal Double 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Double -> Expr (null (PG Double)) #

Literal Float 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Float -> Expr (null (PG Float)) #

Literal Int16 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Int16 -> Expr (null (PG Int16)) #

Literal Int32 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Int32 -> Expr (null (PG Int32)) #

Literal Int64 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Int64 -> Expr (null (PG Int64)) #

Literal Text 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Text -> Expr (null (PG Text)) #

Literal Text 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Text -> Expr (null (PG Text)) #

Literal String 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: String -> Expr (null (PG String)) #

ToJSON hask => Literal (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Json hask -> Expr (null (PG (Json hask))) #

ToJSON hask => Literal (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Jsonb hask -> Expr (null (PG (Jsonb hask))) #

ToParam (Enumerated enum) (PG (Enumerated enum)) => Literal (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Enumerated enum -> Expr (null (PG (Enumerated enum))) #

destroyConnectionPool #

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.

usingConnectionPool #

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.

createConnectionPool #

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.

handleSqueal #

Arguments

:: MonadUnliftIO io 
=> (SquealException -> io a)

handler

-> io a 
-> io a 

catchSqueal #

Arguments

:: MonadUnliftIO io 
=> io a 
-> (SquealException -> io a)

handler

-> io a 

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.

firstRow #

Arguments

:: (FromRow columns y, MonadIO io) 
=> K Result columns

result

-> io (Maybe y) 

Get the first row if possible from a Result.

getRows #

Arguments

:: (FromRow columns y, MonadIO io) 
=> K Result columns

result

-> io [y] 

Get all rows from a Result.

nextRow #

Arguments

:: (FromRow columns y, MonadIO io) 
=> Row

total number of rows

-> K Result columns

result

-> Row

row number

-> io (Maybe (Row, y)) 

Intended to be used for unfolding in streaming libraries, nextRow takes a total number of rows (which can be found with ntuples) and a Result and given a row number if it's too large returns Nothing, otherwise returning the row along with the next row number.

getRow #

Arguments

:: (FromRow columns y, MonadIO io) 
=> Row

row number

-> K Result columns

result

-> io y 

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 #

Do connectdb and finish before and after a computation.

finish :: MonadIO io => K Connection schemas -> io () #

Closes the connection to the server.

connectdb #

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 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

hoist :: Monad m => (forall a. m a -> n a) -> PQ schemas0 schemas1 m b -> PQ schemas0 schemas1 n b #

(MonadIO io, schemas0 ~ schemas, schemas1 ~ schemas) => MonadPQ schemas (PQ schemas0 schemas1 io) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

lift :: Monad m => m a -> PQ schemas0 schemas1 m a #

schemas0 ~ schemas1 => MMonad (PQ schemas0 schemas1) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

embed :: Monad n => (forall a. m a -> PQ schemas0 schemas1 n a) -> PQ schemas0 schemas1 m b -> PQ schemas0 schemas1 n b #

(Monad m, schemas0 ~ schemas1) => Monad (PQ schemas0 schemas1 m) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

(>>=) :: PQ schemas0 schemas1 m a -> (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 b #

return :: a -> PQ schemas0 schemas1 m a #

fail :: String -> PQ schemas0 schemas1 m a #

Monad m => Functor (PQ schemas0 schemas1 m) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

fmap :: (a -> b) -> PQ schemas0 schemas1 m a -> PQ schemas0 schemas1 m b #

(<$) :: a -> PQ schemas0 schemas1 m b -> PQ schemas0 schemas1 m a #

(Monad m, schemas0 ~ schemas1) => MonadFail (PQ schemas0 schemas1 m) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

fail :: String -> PQ schemas0 schemas1 m a #

(Monad m, schemas0 ~ schemas1) => Applicative (PQ schemas0 schemas1 m) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

liftIO :: IO a -> PQ schema0 schema1 m a #

(MonadUnliftIO m, schemas0 ~ schemas1) => MonadUnliftIO (PQ schemas0 schemas1 m) 
Instance details

Defined in Squeal.PostgreSQL.PQ

Methods

askUnliftIO :: PQ schemas0 schemas1 m (UnliftIO (PQ schemas0 schemas1 m)) #

withRunInIO :: ((forall a. PQ schemas0 schemas1 m a -> IO a) -> IO b) -> PQ schemas0 schemas1 m b #

Migratory (Terminally PQ IO) 
Instance details

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.

Minimal complete definition

pqAp, pqBind, 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 
Instance details

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

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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 #

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 False
K "\NUL"
>>> toParam @Int16 @'PGint2 0
K "\NUL\NUL"
>>> toParam @Int32 @'PGint4 0
K "\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
ToParam Bool PGbool 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Bool -> K Encoding PGbool #

ToParam Double PGfloat8 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Float PGfloat4 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Int16 PGint2 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Int32 PGint4 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Int64 PGint8 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Word16 PGint2 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Word32 PGint4 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Word64 PGint8 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam ByteString PGbytea 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam ByteString PGbytea 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Scientific PGnumeric 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Text PGtext 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Text -> K Encoding PGtext #

ToParam UTCTime PGtimestamptz 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Value PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Value PGjson 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Text PGtext 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Text -> K Encoding PGtext #

ToParam String PGtext 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam UUID PGuuid 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: UUID -> K Encoding PGuuid #

ToParam Day PGdate 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Day -> K Encoding PGdate #

ToParam DiffTime PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam TimeOfDay PGtime 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam LocalTime PGtimestamp 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Money PGmoney 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToParam Char (PGchar 1) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Char -> K Encoding (PGchar 1) #

ToParam (NetAddr IP) PGinet 
Instance details

Defined in Squeal.PostgreSQL.Binary

ToJSON x => ToParam (Json x) PGjson 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Json x -> K Encoding PGjson #

ToJSON x => ToParam (Jsonb x) PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Jsonb x -> K Encoding PGjsonb #

(SListI fields, IsRecord x xs, AllZip ToField xs fields, All HasAliasedOid fields) => ToParam (Composite x) (PGcomposite fields) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Composite x -> K Encoding (PGcomposite fields) #

(IsEnumType x, HasDatatypeInfo x, LabelsPG x ~ labels) => ToParam (Enumerated x) (PGenum labels) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Enumerated x -> K Encoding (PGenum labels) #

(ToNullityParam x ty, ty ~ nullity pg, HasOid pg) => ToParam (VarArray [x]) (PGvararray ty) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: VarArray [x] -> K Encoding (PGvararray ty) #

(ToParam x pg, HasOid pg) => ToParam (VarArray (Vector (Maybe x))) (PGvararray (Null pg)) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: VarArray (Vector (Maybe x)) -> K Encoding (PGvararray (Null pg)) #

(ToParam x pg, HasOid pg) => ToParam (VarArray (Vector x)) (PGvararray (NotNull pg)) 
Instance details

Defined in Squeal.PostgreSQL.Binary

(ToFixArray x dims ty, ty ~ nullity pg, HasOid pg) => ToParam (FixArray x) (PGfixarray dims ty) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: FixArray x -> K Encoding (PGfixarray dims ty) #

ToParam (TimeOfDay, TimeZone) PGtimetz 
Instance details

Defined in Squeal.PostgreSQL.Binary

class HasOid (ty :: PGType) where #

The object identifier of a PGType.

>>> :set -XTypeApplications
>>> oid @'PGbool
16

Methods

oid :: Word32 #

Instances
HasOid PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGjson 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGinet 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGuuid 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGtimetz 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGtime 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGdate 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGtimestamptz 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGtimestamp 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGbytea 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGtext 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGfloat8 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGfloat4 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGnumeric 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGint8 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGint4 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGint2 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid PGbool 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid (PGvarchar n) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

HasOid (PGchar n) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

oid :: Word32 #

class HasAliasedOid (field :: (Symbol, NullityType)) where #

Lifts a HasOid constraint to a field.

Methods

aliasedOid :: Word32 #

Instances
HasOid ty => HasAliasedOid (alias ::: nullity ty) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toNullityParam :: x -> K (Maybe Encoding) (NotNull pg) #

ToParam x pg => ToNullityParam (Maybe x) (Null pg) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toNullityParam :: Maybe x -> K (Maybe Encoding) (Null pg) #

class ToField (x :: (Symbol, Type)) (field :: (Symbol, NullityType)) where #

A ToField constraint lifts the ToParam parser to an encoding of a (Symbol, Type) to a (Symbol, NullityType), encoding Nulls to Maybes. You should not define instances for FromField, just use the provided instances.

Methods

toField :: P x -> K (Maybe Encoding) field #

Instances
ToNullityParam x ty => ToField (alias ::: x) (alias ::: ty) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toField :: P (alias ::: x) -> K (Maybe Encoding) (alias ::: ty) #

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 
Instance details

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 
Instance details

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 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParams :: x -> NP (K (Maybe Encoding)) 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

fromValue :: Value y #

>>> newtype Id = Id { getId :: Int16 } deriving Show
>>> instance FromValue 'PGint2 Id where fromValue = Id <$> fromValue @'PGint2
Instances
FromValue PGjsonb Value 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGjson Value 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGuuid UUID 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value UUID #

FromValue PGinterval DiffTime 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGtime TimeOfDay 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGdate Day 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value Day #

FromValue PGtimestamptz UTCTime 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGtimestamp LocalTime 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGbytea ByteString 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGbytea ByteString 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGtext Text 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value Text #

FromValue PGtext Text 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value Text #

FromValue PGtext String 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGmoney Money 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGfloat8 Double 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGfloat4 Float 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGnumeric Scientific 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGint8 Int64 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGint4 Int32 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGint2 Int16 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGbool Bool 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value Bool #

FromJSON x => FromValue PGjsonb (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Jsonb x) #

FromJSON x => FromValue PGjson (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Json x) #

FromValue PGinet (NetAddr IP) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (NetAddr IP) #

FromValue PGtimetz (TimeOfDay, TimeZone) 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue (PGchar 1) Char 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value Char #

FromRow fields y => FromValue (PGcomposite fields) (Composite y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Composite y) #

(IsEnumType y, HasDatatypeInfo y, LabelsPG y ~ labels) => FromValue (PGenum labels) (Enumerated y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Enumerated y) #

FromValue pg y => FromValue (PGvararray (NotNull pg)) (VarArray (Vector y)) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray (Vector y)) #

FromValue pg y => FromValue (PGvararray (NotNull pg)) (VarArray [y]) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray [y]) #

FromValue pg y => FromValue (PGvararray (Null pg)) (VarArray (Vector (Maybe y))) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray (Vector (Maybe y))) #

FromValue pg y => FromValue (PGvararray (Null pg)) (VarArray [Maybe y]) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray [Maybe y]) #

FromFixArray dims ty y => FromValue (PGfixarray dims ty) (FixArray y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (FixArray y) #

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.

Methods

fromField :: K (Maybe ByteString) pg -> (Either Text :.: (P :: (Symbol, Type) -> Type)) y #

Instances
FromValue pg y => FromField (column ::: NotNull pg) (column ::: y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromField :: K (Maybe ByteString) (column ::: NotNull pg) -> (Either Text :.: P) (column ::: y) #

FromValue pg y => FromField (column ::: Null pg) (column ::: Maybe y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromField :: K (Maybe ByteString) (column ::: Null pg) -> (Either Text :.: P) (column ::: Maybe y) #

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 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromFixArray :: Array y #

FromValue pg y => FromFixArray ([] :: [Nat]) (Null pg) (Maybe y) 
Instance details

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 
Instance details

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"})
Instances
(SListI result, IsRecord y ys, AllZip FromField result ys) => FromRow result y 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromRow :: NP (K (Maybe ByteString)) result -> Either Text y #

newtype Only x #

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"})

Constructors

Only 

Fields

Instances
Functor Only 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fmap :: (a -> b) -> Only a -> Only b #

(<$) :: a -> Only b -> Only a #

Foldable Only 
Instance details

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 #

toList :: Only a -> [a] #

null :: Only a -> Bool #

length :: Only a -> Int #

elem :: Eq a => a -> Only a -> Bool #

maximum :: Ord a => Only a -> a #

minimum :: Ord a => Only a -> a #

sum :: Num a => Only a -> a #

product :: Num a => Only a -> a #

Traversable Only 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

traverse :: Applicative f => (a -> f b) -> Only a -> f (Only b) #

sequenceA :: Applicative f => Only (f a) -> f (Only a) #

mapM :: Monad m => (a -> m b) -> Only a -> m (Only b) #

sequence :: Monad m => Only (m a) -> m (Only a) #

Eq x => Eq (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

(==) :: Only x -> Only x -> Bool #

(/=) :: Only x -> Only x -> Bool #

Ord x => Ord (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

compare :: Only x -> Only x -> Ordering #

(<) :: Only x -> Only x -> Bool #

(<=) :: Only x -> Only x -> Bool #

(>) :: Only x -> Only x -> Bool #

(>=) :: Only x -> Only x -> Bool #

max :: Only x -> Only x -> Only x #

min :: Only x -> Only x -> Only x #

Read x => Read (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Show x => Show (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

showsPrec :: Int -> Only x -> ShowS #

show :: Only x -> String #

showList :: [Only x] -> ShowS #

Generic (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Associated Types

type Rep (Only x) :: Type -> Type #

Methods

from :: Only x -> Rep (Only x) x0 #

to :: Rep (Only x) x0 -> Only x #

Generic (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Associated Types

type Code (Only x) :: [[Type]] #

Methods

from :: Only x -> Rep (Only x) #

to :: Rep (Only x) -> Only x #

HasDatatypeInfo (Only x) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Binary

type Rep (Only x) = D1 (MetaData "Only" "Squeal.PostgreSQL.Binary" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Only" PrefixI True) (S1 (MetaSel (Just "fromOnly") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 x)))
type Code (Only x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

type Code (Only x) = GCode (Only x)
type DatatypeInfoOf (Only x) 
Instance details

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

dropType #

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));

createTypeCompositeFrom #

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);

createTypeComposite #

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);

createTypeEnumFrom #

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');

createTypeEnum #

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');

dropView #

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";

createView #

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;

setDefault #

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;

alterColumn #

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.

renameColumn #

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";

dropColumn #

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";

dropConstraint #

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";

addConstraint #

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));

alterTableRename #

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 #bar
ALTER TABLE "foo" RENAME TO "bar";

alterTable #

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.

dropTable #

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 definition
DROP 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 definition
DROP SCHEMA "muh_schema";

foreignKey #

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);

primaryKey #

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 definition
CREATE TABLE "tab" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_id" PRIMARY KEY ("id"));

unique #

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 definition
CREATE TABLE "tab" ("a" int NULL, "b" int NULL, CONSTRAINT "uq_a_b" UNIQUE ("a", "b"));

check #

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 Condition on those subcolumns

-> 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 definition
CREATE TABLE "tab" ("a" int NOT NULL, "b" int NOT NULL, CONSTRAINT "inequality" CHECK (("a" > "b")));

createTableIfNotExists #

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);

createTable #

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.

manipDefinition #

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.

Instances
Migratory Definition 
Instance details

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 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

id :: Definition a a #

(.) :: Definition b c -> Definition a b -> Definition a c #

Eq (Definition schemas0 schemas1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

(/=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

Ord (Definition schemas0 schemas1) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: Definition schemas0 schemas1 -> () #

RenderSQL (Definition schemas0 schemas1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: Definition schemas0 schemas1 -> ByteString #

type Rep (Definition schemas0 schemas1) 
Instance details

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.

Instances
Eq (TableConstraintExpression sch tab schemas constraint) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: TableConstraintExpression sch tab schemas constraint -> () #

RenderSQL (TableConstraintExpression sch tab schemas constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: TableConstraintExpression sch tab schemas constraint -> ByteString #

type Rep (TableConstraintExpression sch tab schemas constraint) 
Instance details

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
Eq OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Ord OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Show OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Generic OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep OnDeleteClause :: Type -> Type #

NFData OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: OnDeleteClause -> () #

RenderSQL OnDeleteClause

Render OnDeleteClause.

Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnDeleteClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnDeleteClause = D1 (MetaData "OnDeleteClause" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "OnDeleteNoAction" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "OnDeleteRestrict" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "OnDeleteCascade" PrefixI False) (U1 :: Type -> Type)))

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
Eq OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Ord OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Show OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Generic OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep OnUpdateClause :: Type -> Type #

NFData OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: OnUpdateClause -> () #

RenderSQL OnUpdateClause

Render OnUpdateClause.

Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnUpdateClause 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnUpdateClause = D1 (MetaData "OnUpdateClause" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "OnUpdateNoAction" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "OnUpdateRestrict" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "OnUpdateCascade" PrefixI False) (U1 :: Type -> Type)))

newtype AlterTable (sch :: Symbol) (tab :: Symbol) (schemas :: SchemasType) (table :: TableType) #

An AlterTable describes the alteration to perform on the columns of a table.

Instances
Eq (AlterTable sch tab schemas table) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: AlterTable sch tab schemas table -> () #

type Rep (AlterTable sch tab schemas table) 
Instance details

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

addColumn #

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (NoDef :=> Null ty) -> AlterTable sch tab schemas (constraints :=> Create column (NoDef :=> Null ty) columns) #

AddColumn (Def :=> ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (Def :=> ty) -> AlterTable sch tab schemas (constraints :=> Create column (Def :=> ty) columns) #

newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) #

An AlterColumn describes the alteration to perform on a single column.

Instances
Eq (AlterColumn schemas ty0 ty1) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: AlterColumn schemas ty0 ty1 -> () #

type Rep (AlterColumn schemas ty0 ty1) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

fieldtype :: Aliased (TypeExpression schemas) (alias ::: ty) #

newtype ColumnTypeExpression (schemas :: SchemasType) (ty :: ColumnType) #

ColumnTypeExpressions are used in createTable commands.

Instances
Eq (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(/=) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

Ord (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Ordering #

(<) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(<=) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(>) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(>=) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

max :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty #

min :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty #

Show (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> ColumnTypeExpression schemas ty -> ShowS #

show :: ColumnTypeExpression schemas ty -> String #

showList :: [ColumnTypeExpression schemas ty] -> ShowS #

Generic (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (ColumnTypeExpression schemas ty) :: Type -> Type #

Methods

from :: ColumnTypeExpression schemas ty -> Rep (ColumnTypeExpression schemas ty) x #

to :: Rep (ColumnTypeExpression schemas ty) x -> ColumnTypeExpression schemas ty #

NFData (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: ColumnTypeExpression schemas ty -> () #

RenderSQL (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: ColumnTypeExpression schemas ty -> ByteString #

type Rep (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (ColumnTypeExpression schemas ty) = D1 (MetaData "ColumnTypeExpression" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeColumnTypeExpression" PrefixI True) (S1 (MetaSel (Just "renderColumnTypeExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

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

Instances
JsonBuildObject ([] :: [NullityType]) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Json

(JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject (NotNull key ': (value ': tys)) 
Instance details

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.

field #

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"

row #

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 i
ROW(0, 1)

unnest :: SetOfFunction "unnest" (null (PGvararray ty)) (("unnest" ::: ty) ': ([] :: [(Symbol, NullityType)])) #

Expand an array to a set of rows

index #

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)))

array #

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]

generateSeriesTimestamp #

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

generateSeriesStep #

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

generateSeries #

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

unsafeSetOfFunctionN #

Arguments

:: (SListI tys, KnownSymbol fun) 
=> SetOfFunctionN fun tys setof

set returning function

Escape hatch for a set returning function with multiple argument.

unsafeSetOfFunction #

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.

notIn #

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)

in_ #

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)

subAny #

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")))

subAll #

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.

deleteFrom_ #

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.

deleteFrom #

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.

update_ #

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.

update #

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)]) #

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

  • commons :: FromType - scope for all common table expressions,
  • schemas :: SchemasType - scope for all tables and views,
  • params :: [NullityType] - scope for all parameters,
  • row :: RowType - return type of the Query.
Instances
With Manipulation 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

rnf :: Manipulation commons schemas params columns -> () #

RenderSQL (Manipulation commons schemas params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: Manipulation commons schemas params columns -> ByteString #

type Rep (Manipulation commons schemas params columns) 
Instance details

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

Values describes NP lists of Aliased Optional Expressions whose ColumnsType must match the tables'.

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

Select describes a subquery that permits use of Optional Expressions.

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

Subquery describes a subquery whose RowType must match the tables'.

Instances
RenderSQL (QueryClause commons schemas params columns) 
Instance details

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 Default value for a column.

Set :: forall k (expr :: k -> Type) (ty :: (ColumnConstraint, k)) (ty1 :: k) (def :: ColumnConstraint). expr ty1 -> Optional expr ((,) def ty1)

Set a value for a column.

Instances
(forall (x :: k). RenderSQL (expr x)) => RenderSQL (Optional expr ty) 
Instance details

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) 
Instance details

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 ConflictClause.

Instance details

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

OnConflict DoNothing simply avoids inserting a row as its alternative action.

DoUpdate

OnConflict DoUpdate updates the existing row that conflicts with the row proposed for insertion as its alternative action.

Fields

Instances
RenderSQL (ConflictAction tab commons schemas params columns) 
Instance details

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 ConflictTarget

Instance details

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 UsingClause

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 also list of table expressions, allowing columns from other tables to appear in the WHERE condition. This is similar to the list of tables that can be specified in the FROM Clause of a SELECT statement; for example, an alias for the table name can be specified. Do not repeat the target table in the Using list, unless you wish to set up a self-join.

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"

fullOuterJoin #

Arguments

:: FromClause outer commons schemas params right

right

-> Condition outer commons Ungrouped schemas params (Join left right)

on condition

-> 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.

rightOuterJoin #

Arguments

:: FromClause outer commons schemas params right

right

-> Condition outer commons Ungrouped schemas params (Join left right)

on condition

-> 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.

leftOuterJoin #

Arguments

:: FromClause outer commons schemas params right

right

-> Condition outer commons Ungrouped schemas params (Join left right)

on condition

-> 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.

innerJoin #

Arguments

:: FromClause outer commons schemas params right

right

-> Condition outer commons Ungrouped schemas params (Join left right)

on condition

-> 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.

crossJoin #

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)])) #

view derives a table from a View.

subquery :: Aliased (Query outer commons schemas params) query -> FromClause outer commons schemas params (query ': ([] :: [(Symbol, RowType)])) #

subquery derives a table from a Query.

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.

offset #

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.

limit #

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.

having #

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.

groupBy #

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.

where_ #

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.

from #

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.

values_ #

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.

values #

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 query
SELECT * FROM (VALUES (1, E'one')) AS t ("a", "b")

selectDistinct_ #

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.

selectDistinct #

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.

select_ #

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.

select #

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

  • outer :: FromType - outer scope for a correlated subquery,
  • commons :: FromType - scope for all common table expressions,
  • schemas :: SchemasType - scope for all tables and views,
  • params :: [NullityType] - scope for all parameters,
  • row :: RowType - return type of the Query.

Constructors

UnsafeQuery 
Instances
With (Query outer) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(==) :: 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 #

Ord (Query outer commons schemas params row) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

showsPrec :: Int -> Query outer commons schemas params row -> ShowS #

show :: Query outer commons schemas params row -> String #

showList :: [Query outer commons schemas params row] -> ShowS #

Generic (Query outer commons schemas params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Associated Types

type Rep (Query outer commons schemas params row) :: Type -> Type #

Methods

from :: Query outer commons schemas params row -> Rep (Query outer commons schemas params row) x #

to :: Rep (Query outer commons schemas params row) x -> Query outer commons schemas params row #

NFData (Query outer commons schemas params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

rnf :: Query outer commons schemas params row -> () #

RenderSQL (Query outer commons schemas params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: Query outer commons schemas params row -> ByteString #

type Rep (Query outer commons schemas params row) 
Instance details

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"))

Equations

Query_ schemas params row = Query ([] :: [(Symbol, RowType)]) ([] :: [(Symbol, RowType)]) schemas (TuplePG params) (RowPG row) 

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias tab -> Alias 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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias tab -> Alias 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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: Selection outer commons Ungrouped schemas params from row1 #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: Selection outer commons (Grouped bys) schemas params from row1 #

(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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

also :: Selection outer commons grp schemas params from ys -> Selection outer commons grp schemas params from xs -> Selection outer commons grp schemas params from (Join xs ys) #

IsString (Selection outer commons grp schemas params from (("fromOnly" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromString :: String -> Selection outer commons grp schemas params from (("fromOnly" ::: NotNull PGtext) ': []) #

RenderSQL (Selection outer commons grp schemas params from row) 
Instance details

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

  • fromClause :: FromClause outer commons schemas params 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.

  • whereClause :: [Condition outer commons Ungrouped schemas params from]

    optional search coditions, combined with .&&. After the processing of the fromClause is done, each row of the derived virtual table is checked against the search condition. If the result of the condition is true, the row is kept in the output table, otherwise it is discarded. The search condition typically references at least one column of the table generated in the fromClause; this is not required, but otherwise the WHERE clause will be fairly useless.

  • groupByClause :: GroupByClause grp from

    The groupByClause is used to group together those rows in a table that have the same values in all the columns listed. The order in which the columns are listed does not matter. The effect is to combine each set of rows having common values into one group row that represents all rows in the group. This is done to eliminate redundancy in the output and/or compute aggregates that apply to these groups.

  • havingClause :: HavingClause outer commons grp schemas params from

    If a table has been grouped using groupBy, but only certain groups are of interest, the havingClause can be used, much like a whereClause, to eliminate groups from the result. Expressions in the havingClause can refer both to grouped expressions and to ungrouped expressions (which necessarily involve an aggregate function).

  • orderByClause :: [SortExpression outer commons grp schemas params from]

    The orderByClause is for optional sorting. When more than one SortExpression is specified, the later (right) values are used to sort rows that are equal according to the earlier (left) values.

  • limitClause :: [Word64]

    The limitClause is combined with min to give a limit count if nonempty. If a limit count is given, no more than that many rows will be returned (but possibly fewer, if the query itself yields fewer rows).

  • offsetClause :: [Word64]

    The offsetClause is combined with + to give an offset count if nonempty. The offset count says to skip that many rows before beginning to return rows. The rows are skipped before the limit count is applied.

Instances
OrderBy TableExpression 
Instance details

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) 
Instance details

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 TableExpression

Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: TableExpression outer commons grp schemas params from -> ByteString #

type Rep (TableExpression outer commons grp schemas params from) 
Instance details

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.

Instances
Additional (FromClause outer commons schemas params :: [a] -> Type) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

rnf :: FromClause outer commons schemas params from -> () #

RenderSQL (FromClause outer commons schemas params from) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: FromClause outer commons schemas params from -> ByteString #

type Rep (FromClause outer commons schemas params from) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias rel -> Alias col -> By rels by #

(Has rel rels cols, Has col cols ty, bys ~ ((,) rel col ': ([] :: [(Symbol, Symbol)]))) => IsQualified rel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias rel -> Alias col -> NP (By rels) bys #

(HasUnique rel rels cols, Has col cols ty, by ~ (,) rel col) => IsLabel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: By rels by #

(HasUnique rel rels cols, Has col cols ty, bys ~ ((,) rel col ': ([] :: [(Symbol, Symbol)]))) => IsLabel col (NP (By rels) bys) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromLabel :: NP (By rels) bys #

Eq (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(==) :: By from by -> By from by -> Bool #

(/=) :: By from by -> By from by -> Bool #

Ord (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

compare :: By from by -> By from by -> Ordering #

(<) :: By from by -> By from by -> Bool #

(<=) :: By from by -> By from by -> Bool #

(>) :: By from by -> By from by -> Bool #

(>=) :: By from by -> By from by -> Bool #

max :: By from by -> By from by -> By from by #

min :: By from by -> By from by -> By from by #

Show (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

showsPrec :: Int -> By from by -> ShowS #

show :: By from by -> String #

showList :: [By from by] -> ShowS #

RenderSQL (By from by) 
Instance details

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 GroupByClause.

Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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 HavingClause.

Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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

with #

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 
Instance details

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) 
Instance details

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

lastValue :: WinFun1 ty ty #

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 5
ntile(5)

cumeDist :: WinFun0 (NotNull PGfloat8) #

cumulative distribution: (number of partition rows preceding or peer with current row) / total partition rows

>>> printSQL cumeDist
cume_dist()

percentRank :: WinFun0 (NotNull PGfloat8) #

relative rank of the current row: (rank - 1) / (total partition rows - 1)

>>> printSQL percentRank
percent_rank()

denseRank :: WinFun0 (NotNull PGint8) #

rank of the current row without gaps; this function counts peer groups

>>> printSQL denseRank
dense_rank()

rowNumber :: WinFun0 (NotNull PGint8) #

number of the current row within its partition, counting from 1

>>> printSQL rowNumber
row_number()

rank :: WinFun0 (NotNull PGint8) #

rank of the current row with gaps; same as rowNumber of its first peer

>>> printSQL rank
rank()

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

partitionBy #

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 
Instance details

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) 
Instance details

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.

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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(*)

count #

Arguments

:: expr1 ty

what to count

-> aggr (NotNull PGint8) 
>>> :{
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

bitAnd #

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")

bitOr #

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")

boolAnd #

Arguments

:: expr1 (null PGbool)

what to aggregate

-> aggr (Null PGbool) 

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")

boolOr #

Arguments

:: expr1 (null PGbool)

what to aggregate

-> aggr (Null PGbool) 

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")

every #

Arguments

:: expr1 (null PGbool)

what to aggregate

-> aggr (Null PGbool) 

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")

max_ #

Arguments

:: expr1 (null ty)

what to maximize

-> aggr (Null ty) 

maximum value of expression across all input values

min_ #

Arguments

:: expr1 (null ty)

what to minimize

-> aggr (Null ty) 

minimum value of expression across all input values

avg #

Arguments

:: expr1 (null ty)

what to average

-> aggr (Null (PGAvg ty)) 

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) 
Instance details

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) 
Instance details

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

Constructors

All (expr ty) 
Distinct (expr ty) 
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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

renderSQL :: Distinction (Expression outer commons grp schemas params from) ty -> ByteString #

type Rep (Distinction expr ty) 
Instance details

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 ... #

A type family that calculates PGSumPGType of a given argument PGType.

type family PGAvg (ty :: PGType) :: PGType where ... #

A type family that calculates PGAvg type of a 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)

isFalse :: null0 PGbool :--> null1 PGbool #

is false

>>> printSQL $ true & isFalse
(TRUE IS FALSE)

isNotTrue :: null0 PGbool :--> null1 PGbool #

is false or unknown

>>> printSQL $ true & isNotTrue
(TRUE IS NOT TRUE)

isTrue :: null0 PGbool :--> null1 PGbool #

is true

>>> printSQL $ true & isTrue
(TRUE IS 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

notBetween :: BetweenExpr #

>>> 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_] currentTimestamp
LEAST(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 expr
GREATEST(($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)

(.==) :: Operator (null0 ty) (null1 ty) (Null PGbool) infix 4 #

Comparison operations like .==, ./=, .>, .>=, .< and .<= will produce NULLs if one of their arguments is NULL.

>>> 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.

nullIf :: FunctionN (NotNull ty ': (NotNull ty ': ([] :: [NullityType]))) (Null ty) #

right inverse to fromNull, if its arguments are equal then nullIf gives NULL.

>>> :set -XTypeApplications -XDataKinds
>>> let expr = nullIf (false *: param @1) :: Expression outer commons grp schemas '[ 'NotNull 'PGbool] from ('Null 'PGbool)
>>> printSQL expr
NULLIF(FALSE, ($1 :: bool))

matchNull #

Arguments

:: Expression outer commons grp schemas params from nullty

what to convert NULL to

-> (Expression outer commons grp schemas params from (NotNull ty) -> Expression outer commons grp schemas params from nullty)

function to perform when NULL is absent

-> 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

isNotNull :: Null ty :--> null PGbool #

>>> printSQL $ null_ & isNotNull
NULL IS NOT NULL

isNull :: Null ty :--> null PGbool #

>>> printSQL $ null_ & isNull
NULL IS NULL

fromNull #

Arguments

:: Expression outer commons grp schemas params from (NotNull ty)

what to convert NULL to

-> 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] false
COALESCE(NULL, TRUE, FALSE)

notNull :: NotNull ty :--> Null ty #

analagous to Just

>>> printSQL $ notNull true
TRUE

null_ :: Expr (Null ty) #

analagous to Nothing

>>> printSQL null_
NULL

ifThenElse #

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

caseWhenThenElse #

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)

not_ :: null PGbool :--> null PGbool #

>>> printSQL $ not_ true
(NOT TRUE)

false :: Expr (null PGbool) #

>>> printSQL false
FALSE

true :: Expr (null PGbool) #

>>> printSQL true
TRUE

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)

param #

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 
Instance details

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 
Instance details

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) 
Instance details

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) 
Instance details

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 
Instance details

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 
Instance details

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')

upper :: null PGtext :--> null PGtext #

>>> printSQL $ upper "eeee"
upper(E'eeee')

lower :: null PGtext :--> null PGtext #

>>> printSQL $ lower "ARRRGGG"
lower(E'ARRRGGG')

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

toTSquery :: null PGtext :--> null PGtsquery #

normalize words and convert to tsquery

queryTree :: null PGtsquery :--> null PGtext #

get indexable part of a tsquery

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

plainToTSquery :: null PGtext :--> null PGtsquery #

produce tsquery ignoring punctuation

numnode :: null PGtsquery :--> null PGint4 #

number of lexemes plus operators in tsquery

tsvectorLength :: null PGtsvector :--> null PGint4 #

number of lexemes in tsvector

arrayToTSvector :: null (PGvararray (NotNull PGtext)) :--> null PGtsvector #

convert array of lexemes to tsvector

(<->) :: Operator (null PGtsquery) (null PGtsquery) (null PGtsquery) #

tsquery followed by tsquery

(.!) :: null PGtsquery :--> null PGtsquery #

negate a tsquery

(.|) :: Operator (null PGtsquery) (null PGtsquery) (null PGtsquery) #

OR tsquerys together

(.&) :: Operator (null PGtsquery) (null PGtsquery) (null PGtsquery) #

AND tsquerys together

(@@) :: Operator (null PGtsvector) (null PGtsquery) (Null PGbool) #

tsvector matches tsquery ?

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 now
now()

localTimestamp :: Expr (null PGtimestamp) #

>>> printSQL localTimestamp
LOCALTIMESTAMP

localTime :: Expr (null PGtime) #

>>> printSQL localTime
LOCALTIME

currentTimestamp :: Expr (null PGtimestamptz) #

>>> printSQL currentTimestamp
CURRENT_TIMESTAMP

currentTime :: Expr (null PGtimetz) #

>>> printSQL currentTime
CURRENT_TIME

currentDate :: Expr (null PGdate) #

>>> printSQL currentDate
CURRENT_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
TimeOp PGinterval PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

(+!) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

(!-) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

(!-!) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

TimeOp PGtimetz PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGtimetz) (null PGinterval) (null PGtimetz) #

(+!) :: Operator (null PGinterval) (null PGtimetz) (null PGtimetz) #

(!-) :: Operator (null PGtimetz) (null PGinterval) (null PGtimetz) #

(!-!) :: Operator (null PGtimetz) (null PGtimetz) (null PGinterval) #

TimeOp PGtime PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGtime) (null PGinterval) (null PGtime) #

(+!) :: Operator (null PGinterval) (null PGtime) (null PGtime) #

(!-) :: Operator (null PGtime) (null PGinterval) (null PGtime) #

(!-!) :: Operator (null PGtime) (null PGtime) (null PGinterval) #

TimeOp PGdate PGint4 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGdate) (null PGint4) (null PGdate) #

(+!) :: Operator (null PGint4) (null PGdate) (null PGdate) #

(!-) :: Operator (null PGdate) (null PGint4) (null PGdate) #

(!-!) :: Operator (null PGdate) (null PGdate) (null PGint4) #

TimeOp PGtimestamptz PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

TimeOp PGtimestamp PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGtimestamp) (null PGinterval) (null PGtimestamp) #

(+!) :: Operator (null PGinterval) (null PGtimestamp) (null PGtimestamp) #

(!-) :: Operator (null PGtimestamp) (null PGinterval) (null PGtimestamp) #

(!-!) :: Operator (null PGtimestamp) (null PGtimestamp) (null PGinterval) #

data TimeUnit #

A TimeUnit to use in interval_ construction.

Instances
Enum TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Eq TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Ord TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Read TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Show TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Generic TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Associated Types

type Rep TimeUnit :: Type -> Type #

Methods

from :: TimeUnit -> Rep TimeUnit x #

to :: Rep TimeUnit x -> TimeUnit #

Generic TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Associated Types

type Code TimeUnit :: [[Type]] #

HasDatatypeInfo TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Associated Types

type DatatypeInfoOf TimeUnit :: DatatypeInfo #

RenderSQL TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

type Rep TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

type Rep TimeUnit = D1 (MetaData "TimeUnit" "Squeal.PostgreSQL.Expression.Time" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (((C1 (MetaCons "Years" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Months" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Weeks" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "Days" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Hours" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Minutes" PrefixI False) (U1 :: Type -> Type)))) :+: ((C1 (MetaCons "Seconds" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Microseconds" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Milliseconds" PrefixI False) (U1 :: Type -> Type))) :+: (C1 (MetaCons "Decades" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Centuries" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Millennia" PrefixI False) (U1 :: Type -> Type)))))
type Code TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

type DatatypeInfoOf TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

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)

astype #

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)

cast #

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.

Instances
Eq (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

(==) :: TypeExpression schemas ty -> TypeExpression schemas ty -> Bool #

(/=) :: TypeExpression schemas ty -> TypeExpression schemas ty -> Bool #

Ord (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

compare :: TypeExpression schemas ty -> TypeExpression schemas ty -> Ordering #

(<) :: TypeExpression schemas ty -> TypeExpression schemas ty -> Bool #

(<=) :: TypeExpression schemas ty -> TypeExpression schemas ty -> Bool #

(>) :: TypeExpression schemas ty -> TypeExpression schemas ty -> Bool #

(>=) :: TypeExpression schemas ty -> TypeExpression schemas ty -> Bool #

max :: TypeExpression schemas ty -> TypeExpression schemas ty -> TypeExpression schemas ty #

min :: TypeExpression schemas ty -> TypeExpression schemas ty -> TypeExpression schemas ty #

Show (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

showsPrec :: Int -> TypeExpression schemas ty -> ShowS #

show :: TypeExpression schemas ty -> String #

showList :: [TypeExpression schemas ty] -> ShowS #

Generic (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Associated Types

type Rep (TypeExpression schemas ty) :: Type -> Type #

Methods

from :: TypeExpression schemas ty -> Rep (TypeExpression schemas ty) x #

to :: Rep (TypeExpression schemas ty) x -> TypeExpression schemas ty #

NFData (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

rnf :: TypeExpression schemas ty -> () #

RenderSQL (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

renderSQL :: TypeExpression schemas ty -> ByteString #

type Rep (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

type Rep (TypeExpression schemas ty) = D1 (MetaData "TypeExpression" "Squeal.PostgreSQL.Expression.Type" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeTypeExpression" PrefixI True) (S1 (MetaSel (Just "renderTypeExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

class PGTyped (schemas :: SchemasType) (ty :: NullityType) where #

pgtype is a demoted version of a PGType

Methods

pgtype :: TypeExpression schemas ty #

Instances
PGTyped schemas (null PGdate) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGdate) #

PGTyped schemas (null PGtime) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtime) #

PGTyped schemas (null PGtimetz) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtimetz) #

PGTyped schemas (null PGinterval) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGinterval) #

PGTyped schemas (null PGuuid) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGuuid) #

PGTyped schemas (null PGjson) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGjson) #

PGTyped schemas (null PGjsonb) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGjsonb) #

PGTyped schemas (null PGbool) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGbool) #

PGTyped schemas (null PGint2) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGint2) #

PGTyped schemas (null PGint4) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGint4) #

PGTyped schemas (null PGint8) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGint8) #

PGTyped schemas ty => PGTyped schemas (null (PGvararray ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null (PGvararray ty)) #

PGTyped schemas (null PGnumeric) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGnumeric) #

PGTyped schemas (null PGfloat4) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGfloat4) #

PGTyped schemas (null PGfloat8) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGfloat8) #

PGTyped schemas (null PGmoney) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGmoney) #

PGTyped schemas (null PGtext) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtext) #

(KnownNat n, 1 <= n) => PGTyped schemas (null (PGchar n)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null (PGchar n)) #

(KnownNat n, 1 <= n) => PGTyped schemas (null (PGvarchar n)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null (PGvarchar n)) #

PGTyped schemas (null PGbytea) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGbytea) #

PGTyped schemas (null PGtimestamp) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtimestamp) #

PGTyped schemas (null PGtimestamptz) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtimestamptz) #

(All KnownNat dims, PGTyped schemas ty) => PGTyped schemas (null (PGfixarray dims ty)) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null (PGfixarray dims ty)) #

PGTyped schemas (null PGtsvector) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtsvector) #

PGTyped schemas (null PGtsquery) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

pgtype :: TypeExpression schemas (null PGtsquery) #

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" true
f(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

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons Ungrouped schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons (Grouped bys) schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons Ungrouped schemas params from) column #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons (Grouped bys) schemas params from) column #

(Has tab (Join outer from) row, Has col row ty) => IsQualified tab col (Expression outer commons Ungrouped schemas params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression outer commons Ungrouped schemas params from ty #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression outer commons (Grouped bys) schemas params from ty #

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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))) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

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)) 
Instance details

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)) 
Instance details

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)) 
Instance details

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) 
Instance details

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) 
Instance details

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)) 
Instance details

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)) 
Instance details

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)) 
Instance details

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) 
Instance details

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))) 
Instance details

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)) 
Instance details

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)) 
Instance details

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)) 
Instance details

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)) 
Instance details

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)) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

rnf :: Expression outer commons grp schemas params from ty -> () #

RenderSQL (Expression outer commons grp schemas params from ty) 
Instance details

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) 
Instance details

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

A RankNType for functions with a single argument. These could be either function calls or unary operators. This is a subtype of the usual Haskell function type ->, indeed a subcategory as it is closed under the usual . and id.

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 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: Operator (null0 PGtsquery) (null1 PGtsquery) (Null PGbool) #

(<@) :: Operator (null0 PGtsquery) (null1 PGtsquery) (Null PGbool) #

PGSubset PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: Operator (null0 PGjsonb) (null1 PGjsonb) (Null PGbool) #

(<@) :: Operator (null0 PGjsonb) (null1 PGjsonb) (Null PGbool) #

PGSubset (PGvararray ty :: PGType) 
Instance details

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 LocalTime
PG LocalTime :: PGType
= 'PGtimestamp
>>> newtype MyDouble = My Double
>>> :set -XTypeFamilies
>>> type instance PG MyDouble = 'PGfloat8
Instances
type PG Bool

PGbool

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Bool = PGbool
type PG Char

PGchar 1

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Char = PGchar 1
type PG Double

PGfloat8

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Float

PGfloat4

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Int16

PGint2

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Int16 = PGint2
type PG Int32

PGint4

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Int32 = PGint4
type PG Int64

PGint8

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Int64 = PGint8
type PG Word16

PGint2

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Word32

PGint4

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Word64

PGint8

Instance details

Defined in Squeal.PostgreSQL.PG

type PG ByteString

PGbytea

Instance details

Defined in Squeal.PostgreSQL.PG

type PG ByteString

PGbytea

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Scientific

PGnumeric

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Text

PGtext

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Text = PGtext
type PG UTCTime

PGtimestamptz

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Value

PGjson

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Value = PGjson
type PG Text

PGtext

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Text = PGtext
type PG String

PGtext

Instance details

Defined in Squeal.PostgreSQL.PG

type PG UUID

PGuuid

Instance details

Defined in Squeal.PostgreSQL.PG

type PG UUID = PGuuid
type PG Day

PGdate

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Day = PGdate
type PG DiffTime

PGinterval

Instance details

Defined in Squeal.PostgreSQL.PG

type PG TimeOfDay

PGtime

Instance details

Defined in Squeal.PostgreSQL.PG

type PG LocalTime

PGtimestamp

Instance details

Defined in Squeal.PostgreSQL.PG

type PG Money

PGmoney

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (NetAddr IP)

PGinet

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (NetAddr IP) = PGinet
type PG (Json hask)

PGjson

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Json hask) = PGjson
type PG (Jsonb hask)

PGjsonb

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Jsonb hask) = PGjsonb
type PG (Composite hask)

PGcomposite (RowPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Composite hask) = PGcomposite (RowPG hask)
type PG (Enumerated hask)

PGenum (LabelsPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Enumerated hask) = PGenum (LabelsPG hask)
type PG (VarArray [hask]) 
Instance details

Defined in Squeal.PostgreSQL.PG

type PG (VarArray [hask]) = PGvararray (NullPG hask)
type PG (VarArray (Vector hask))

PGvararray (NullPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (VarArray (Vector hask)) = PGvararray (NullPG hask)
type PG (FixArray hask)

PGfixarray (DimPG hask) (FixPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (FixArray hask) = PGfixarray (DimPG hask) (FixPG hask)
type PG (TimeOfDay, TimeZone)

PGtimetz

Instance details

Defined in Squeal.PostgreSQL.PG

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 Schwarma
LabelsPG Schwarma :: [Type.ConstructorName]
= '["Beef", "Lamb", "Chicken"]

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 Person
RowPG Person :: [(Symbol, NullityType)]
= '["name" ::: 'NotNull 'PGtext, "age" ::: 'NotNull 'PGint4]

Equations

RowPG hask = RowOf (RecordCodeOf hask) 

type family RowOf (record :: [(Symbol, Type)]) :: RowType where ... #

RowOf applies NullPG to the fields of a list.

Equations

RowOf ([] :: [(Symbol, Type)]) = ([] :: [(Symbol, NullityType)]) 
RowOf ((col ::: ty) ': record) = (col ::: NullPG ty) ': RowOf record 

type family NullPG hask :: NullityType where ... #

NullPG turns a Haskell type into a NullityType.

>>> :kind! NullPG Double
NullPG Double :: NullityType
= 'NotNull 'PGfloat8
>>> :kind! NullPG (Maybe Double)
NullPG (Maybe Double) :: NullityType
= 'Null 'PGfloat8

Equations

NullPG (Maybe hask) = Null (PG hask) 
NullPG hask = NotNull (PG hask) 

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.

Equations

TupleOf ([] :: [Type]) = ([] :: [NullityType]) 
TupleOf (hask ': tuple) = NullPG hask ': TupleOf tuple 

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 ... #

FixPG extracts NullPG of the base type of nested homogeneous tuples.

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 

newtype Money #

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

Constructors

Money 

Fields

Instances
Eq Money 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: Money -> Money -> Bool #

(/=) :: Money -> Money -> Bool #

Ord Money 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: Money -> Money -> Ordering #

(<) :: Money -> Money -> Bool #

(<=) :: Money -> Money -> Bool #

(>) :: Money -> Money -> Bool #

(>=) :: Money -> Money -> Bool #

max :: Money -> Money -> Money #

min :: Money -> Money -> Money #

Read Money 
Instance details

Defined in Squeal.PostgreSQL.PG

Show Money 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> Money -> ShowS #

show :: Money -> String #

showList :: [Money] -> ShowS #

Generic Money 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep Money :: Type -> Type #

Methods

from :: Money -> Rep Money x #

to :: Rep Money x -> Money #

ToParam Money PGmoney 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue PGmoney Money 
Instance details

Defined in Squeal.PostgreSQL.Binary

type Rep Money 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep Money = D1 (MetaData "Money" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Money" PrefixI True) (S1 (MetaSel (Just "cents") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Int64)))
type PG Money

PGmoney

Instance details

Defined in Squeal.PostgreSQL.PG

newtype Json hask #

The Json newtype is an indication that the Haskell type it's applied to should be stored as a PGjson.

Constructors

Json 

Fields

Instances
FromJSON x => FromValue PGjson (Json x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Json x) #

Eq hask => Eq (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: Json hask -> Json hask -> Bool #

(/=) :: Json hask -> Json hask -> Bool #

Ord hask => Ord (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: Json hask -> Json hask -> Ordering #

(<) :: Json hask -> Json hask -> Bool #

(<=) :: Json hask -> Json hask -> Bool #

(>) :: Json hask -> Json hask -> Bool #

(>=) :: Json hask -> Json hask -> Bool #

max :: Json hask -> Json hask -> Json hask #

min :: Json hask -> Json hask -> Json hask #

Read hask => Read (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

readsPrec :: Int -> ReadS (Json hask) #

readList :: ReadS [Json hask] #

readPrec :: ReadPrec (Json hask) #

readListPrec :: ReadPrec [Json hask] #

Show hask => Show (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> Json hask -> ShowS #

show :: Json hask -> String #

showList :: [Json hask] -> ShowS #

Generic (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep (Json hask) :: Type -> Type #

Methods

from :: Json hask -> Rep (Json hask) x #

to :: Rep (Json hask) x -> Json hask #

ToJSON hask => Literal (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Json hask -> Expr (null (PG (Json hask))) #

ToJSON x => ToParam (Json x) PGjson 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Json x -> K Encoding PGjson #

type Rep (Json hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep (Json hask) = D1 (MetaData "Json" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Json" PrefixI True) (S1 (MetaSel (Just "getJson") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 hask)))
type PG (Json hask)

PGjson

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Json hask) = PGjson

newtype Jsonb hask #

The Jsonb newtype is an indication that the Haskell type it's applied to should be stored as a PGjsonb.

Constructors

Jsonb 

Fields

Instances
FromJSON x => FromValue PGjsonb (Jsonb x) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Jsonb x) #

Eq hask => Eq (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: Jsonb hask -> Jsonb hask -> Bool #

(/=) :: Jsonb hask -> Jsonb hask -> Bool #

Ord hask => Ord (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: Jsonb hask -> Jsonb hask -> Ordering #

(<) :: Jsonb hask -> Jsonb hask -> Bool #

(<=) :: Jsonb hask -> Jsonb hask -> Bool #

(>) :: Jsonb hask -> Jsonb hask -> Bool #

(>=) :: Jsonb hask -> Jsonb hask -> Bool #

max :: Jsonb hask -> Jsonb hask -> Jsonb hask #

min :: Jsonb hask -> Jsonb hask -> Jsonb hask #

Read hask => Read (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

readsPrec :: Int -> ReadS (Jsonb hask) #

readList :: ReadS [Jsonb hask] #

readPrec :: ReadPrec (Jsonb hask) #

readListPrec :: ReadPrec [Jsonb hask] #

Show hask => Show (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> Jsonb hask -> ShowS #

show :: Jsonb hask -> String #

showList :: [Jsonb hask] -> ShowS #

Generic (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep (Jsonb hask) :: Type -> Type #

Methods

from :: Jsonb hask -> Rep (Jsonb hask) x #

to :: Rep (Jsonb hask) x -> Jsonb hask #

ToJSON hask => Literal (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Jsonb hask -> Expr (null (PG (Jsonb hask))) #

ToJSON x => ToParam (Jsonb x) PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Jsonb x -> K Encoding PGjsonb #

type Rep (Jsonb hask) 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep (Jsonb hask) = D1 (MetaData "Jsonb" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Jsonb" PrefixI True) (S1 (MetaSel (Just "getJsonb") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 hask)))
type PG (Jsonb hask)

PGjsonb

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Jsonb hask) = PGjsonb

newtype Composite record #

The Composite newtype is an indication that the Haskell type it's applied to should be stored as a PGcomposite.

Constructors

Composite 

Fields

Instances
Eq record => Eq (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: Composite record -> Composite record -> Bool #

(/=) :: Composite record -> Composite record -> Bool #

Ord record => Ord (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: Composite record -> Composite record -> Ordering #

(<) :: Composite record -> Composite record -> Bool #

(<=) :: Composite record -> Composite record -> Bool #

(>) :: Composite record -> Composite record -> Bool #

(>=) :: Composite record -> Composite record -> Bool #

max :: Composite record -> Composite record -> Composite record #

min :: Composite record -> Composite record -> Composite record #

Read record => Read (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

readsPrec :: Int -> ReadS (Composite record) #

readList :: ReadS [Composite record] #

readPrec :: ReadPrec (Composite record) #

readListPrec :: ReadPrec [Composite record] #

Show record => Show (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> Composite record -> ShowS #

show :: Composite record -> String #

showList :: [Composite record] -> ShowS #

Generic (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep (Composite record) :: Type -> Type #

Methods

from :: Composite record -> Rep (Composite record) x #

to :: Rep (Composite record) x -> Composite record #

(SListI fields, IsRecord x xs, AllZip ToField xs fields, All HasAliasedOid fields) => ToParam (Composite x) (PGcomposite fields) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Composite x -> K Encoding (PGcomposite fields) #

FromRow fields y => FromValue (PGcomposite fields) (Composite y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Composite y) #

type Rep (Composite record) 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep (Composite record) = D1 (MetaData "Composite" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Composite" PrefixI True) (S1 (MetaSel (Just "getComposite") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 record)))
type PG (Composite hask)

PGcomposite (RowPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Composite hask) = PGcomposite (RowPG hask)

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
Eq enum => Eq (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: Enumerated enum -> Enumerated enum -> Bool #

(/=) :: Enumerated enum -> Enumerated enum -> Bool #

Ord enum => Ord (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: Enumerated enum -> Enumerated enum -> Ordering #

(<) :: Enumerated enum -> Enumerated enum -> Bool #

(<=) :: Enumerated enum -> Enumerated enum -> Bool #

(>) :: Enumerated enum -> Enumerated enum -> Bool #

(>=) :: Enumerated enum -> Enumerated enum -> Bool #

max :: Enumerated enum -> Enumerated enum -> Enumerated enum #

min :: Enumerated enum -> Enumerated enum -> Enumerated enum #

Read enum => Read (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.PG

Show enum => Show (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> Enumerated enum -> ShowS #

show :: Enumerated enum -> String #

showList :: [Enumerated enum] -> ShowS #

Generic (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep (Enumerated enum) :: Type -> Type #

Methods

from :: Enumerated enum -> Rep (Enumerated enum) x #

to :: Rep (Enumerated enum) x -> Enumerated enum #

ToParam (Enumerated enum) (PG (Enumerated enum)) => Literal (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Literal

Methods

literal :: Enumerated enum -> Expr (null (PG (Enumerated enum))) #

(IsEnumType x, HasDatatypeInfo x, LabelsPG x ~ labels) => ToParam (Enumerated x) (PGenum labels) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: Enumerated x -> K Encoding (PGenum labels) #

(IsEnumType y, HasDatatypeInfo y, LabelsPG y ~ labels) => FromValue (PGenum labels) (Enumerated y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (Enumerated y) #

type Rep (Enumerated enum) 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep (Enumerated enum) = D1 (MetaData "Enumerated" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "Enumerated" PrefixI True) (S1 (MetaSel (Just "getEnumerated") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 enum)))
type PG (Enumerated hask)

PGenum (LabelsPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (Enumerated hask) = PGenum (LabelsPG hask)

newtype VarArray arr #

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
Eq arr => Eq (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: VarArray arr -> VarArray arr -> Bool #

(/=) :: VarArray arr -> VarArray arr -> Bool #

Ord arr => Ord (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: VarArray arr -> VarArray arr -> Ordering #

(<) :: VarArray arr -> VarArray arr -> Bool #

(<=) :: VarArray arr -> VarArray arr -> Bool #

(>) :: VarArray arr -> VarArray arr -> Bool #

(>=) :: VarArray arr -> VarArray arr -> Bool #

max :: VarArray arr -> VarArray arr -> VarArray arr #

min :: VarArray arr -> VarArray arr -> VarArray arr #

Read arr => Read (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Show arr => Show (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> VarArray arr -> ShowS #

show :: VarArray arr -> String #

showList :: [VarArray arr] -> ShowS #

Generic (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep (VarArray arr) :: Type -> Type #

Methods

from :: VarArray arr -> Rep (VarArray arr) x #

to :: Rep (VarArray arr) x -> VarArray arr #

(ToNullityParam x ty, ty ~ nullity pg, HasOid pg) => ToParam (VarArray [x]) (PGvararray ty) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: VarArray [x] -> K Encoding (PGvararray ty) #

(ToParam x pg, HasOid pg) => ToParam (VarArray (Vector (Maybe x))) (PGvararray (Null pg)) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: VarArray (Vector (Maybe x)) -> K Encoding (PGvararray (Null pg)) #

(ToParam x pg, HasOid pg) => ToParam (VarArray (Vector x)) (PGvararray (NotNull pg)) 
Instance details

Defined in Squeal.PostgreSQL.Binary

FromValue pg y => FromValue (PGvararray (NotNull pg)) (VarArray (Vector y)) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray (Vector y)) #

FromValue pg y => FromValue (PGvararray (NotNull pg)) (VarArray [y]) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray [y]) #

FromValue pg y => FromValue (PGvararray (Null pg)) (VarArray (Vector (Maybe y))) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray (Vector (Maybe y))) #

FromValue pg y => FromValue (PGvararray (Null pg)) (VarArray [Maybe y]) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (VarArray [Maybe y]) #

type Rep (VarArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep (VarArray arr) = D1 (MetaData "VarArray" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "VarArray" PrefixI True) (S1 (MetaSel (Just "getVarArray") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 arr)))
type PG (VarArray [hask]) 
Instance details

Defined in Squeal.PostgreSQL.PG

type PG (VarArray [hask]) = PGvararray (NullPG hask)
type PG (VarArray (Vector hask))

PGvararray (NullPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (VarArray (Vector hask)) = PGvararray (NullPG hask)

newtype FixArray arr #

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) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

(==) :: FixArray arr -> FixArray arr -> Bool #

(/=) :: FixArray arr -> FixArray arr -> Bool #

Ord arr => Ord (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

compare :: FixArray arr -> FixArray arr -> Ordering #

(<) :: FixArray arr -> FixArray arr -> Bool #

(<=) :: FixArray arr -> FixArray arr -> Bool #

(>) :: FixArray arr -> FixArray arr -> Bool #

(>=) :: FixArray arr -> FixArray arr -> Bool #

max :: FixArray arr -> FixArray arr -> FixArray arr #

min :: FixArray arr -> FixArray arr -> FixArray arr #

Read arr => Read (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Show arr => Show (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Methods

showsPrec :: Int -> FixArray arr -> ShowS #

show :: FixArray arr -> String #

showList :: [FixArray arr] -> ShowS #

Generic (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

Associated Types

type Rep (FixArray arr) :: Type -> Type #

Methods

from :: FixArray arr -> Rep (FixArray arr) x #

to :: Rep (FixArray arr) x -> FixArray arr #

(ToFixArray x dims ty, ty ~ nullity pg, HasOid pg) => ToParam (FixArray x) (PGfixarray dims ty) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toParam :: FixArray x -> K Encoding (PGfixarray dims ty) #

FromFixArray dims ty y => FromValue (PGfixarray dims ty) (FixArray y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromValue :: Value (FixArray y) #

type Rep (FixArray arr) 
Instance details

Defined in Squeal.PostgreSQL.PG

type Rep (FixArray arr) = D1 (MetaData "FixArray" "Squeal.PostgreSQL.PG" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "FixArray" PrefixI True) (S1 (MetaSel (Just "getFixArray") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 arr)))
type PG (FixArray hask)

PGfixarray (DimPG hask) (FixPG hask)

Instance details

Defined in Squeal.PostgreSQL.PG

type PG (FixArray hask) = PGfixarray (DimPG hask) (FixPG hask)

data PGType #

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
PGSubset PGtsquery 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: Operator (null0 PGtsquery) (null1 PGtsquery) (Null PGbool) #

(<@) :: Operator (null0 PGtsquery) (null1 PGtsquery) (Null PGbool) #

PGSubset PGjsonb 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: Operator (null0 PGjsonb) (null1 PGjsonb) (Null PGbool) #

(<@) :: Operator (null0 PGjsonb) (null1 PGjsonb) (Null PGbool) #

TimeOp PGinterval PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

(+!) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

(!-) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

(!-!) :: Operator (null PGinterval) (null PGinterval) (null PGinterval) #

TimeOp PGtimetz PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGtimetz) (null PGinterval) (null PGtimetz) #

(+!) :: Operator (null PGinterval) (null PGtimetz) (null PGtimetz) #

(!-) :: Operator (null PGtimetz) (null PGinterval) (null PGtimetz) #

(!-!) :: Operator (null PGtimetz) (null PGtimetz) (null PGinterval) #

TimeOp PGtime PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGtime) (null PGinterval) (null PGtime) #

(+!) :: Operator (null PGinterval) (null PGtime) (null PGtime) #

(!-) :: Operator (null PGtime) (null PGinterval) (null PGtime) #

(!-!) :: Operator (null PGtime) (null PGtime) (null PGinterval) #

TimeOp PGdate PGint4 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGdate) (null PGint4) (null PGdate) #

(+!) :: Operator (null PGint4) (null PGdate) (null PGdate) #

(!-) :: Operator (null PGdate) (null PGint4) (null PGdate) #

(!-!) :: Operator (null PGdate) (null PGdate) (null PGint4) #

TimeOp PGtimestamptz PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

TimeOp PGtimestamp PGinterval 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

Methods

(!+) :: Operator (null PGtimestamp) (null PGinterval) (null PGtimestamp) #

(+!) :: Operator (null PGinterval) (null PGtimestamp) (null PGtimestamp) #

(!-) :: Operator (null PGtimestamp) (null PGinterval) (null PGtimestamp) #

(!-!) :: Operator (null PGtimestamp) (null PGtimestamp) (null PGinterval) #

PGSubset (PGvararray ty :: PGType) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(@>) :: Operator (null0 (PGvararray ty)) (null1 (PGvararray ty)) (Null PGbool) #

(<@) :: Operator (null0 (PGvararray ty)) (null1 (PGvararray ty)) (Null PGbool) #

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

Constructors

Null PGType

NULL may be present

NotNull PGType

NULL is absent

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons Ungrouped schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons (Grouped bys) schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons Ungrouped schemas params from) column #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons (Grouped bys) schemas params from) column #

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

fieldtype :: Aliased (TypeExpression schemas) (alias ::: ty) #

(KnownNat n, HasParameter (n - 1) params ty) => HasParameter n (ty' ': params) ty 
Instance details

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 
Instance details

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) 
Instance details

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) 
Instance details

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]) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Json

Additional (Selection outer commons grp schemas params from :: RowType -> Type) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

also :: Selection outer commons grp schemas params from ys -> Selection outer commons grp schemas params from xs -> Selection outer commons grp schemas params from (Join xs ys) #

NFData (Distinction (Expression outer commons grp schemas params from) ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

rnf :: Distinction (Expression outer commons grp schemas params from) ty -> () #

HasOid ty => HasAliasedOid (alias ::: nullity ty) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

aliasedOid :: Word32 #

(JsonBuildObject tys, In key PGJsonKey) => JsonBuildObject (NotNull key ': (value ': tys)) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

toField :: P (alias ::: x) -> K (Maybe Encoding) (alias ::: ty) #

FromValue pg y => FromField (column ::: NotNull pg) (column ::: y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromField :: K (Maybe ByteString) (column ::: NotNull pg) -> (Either Text :.: P) (column ::: y) #

FromValue pg y => FromField (column ::: Null pg) (column ::: Maybe y) 
Instance details

Defined in Squeal.PostgreSQL.Binary

Methods

fromField :: K (Maybe ByteString) (column ::: Null pg) -> (Either Text :.: P) (column ::: Maybe y) #

ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> nullity0 ty0)) (alias1 ::: (def1 :=> nullity1 ty1)) 
Instance details

Defined in Squeal.PostgreSQL.Schema

AddColumn (NoDef :=> Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (NoDef :=> Null ty) -> AlterTable sch tab schemas (constraints :=> Create column (NoDef :=> Null ty) columns) #

AddColumn (Def :=> ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (Def :=> ty) -> AlterTable sch tab schemas (constraints :=> Create column (Def :=> ty) columns) #

IsString (Selection outer commons grp schemas params from (("fromOnly" ::: NotNull PGtext) ': ([] :: [(Symbol, NullityType)]))) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

fromString :: String -> Selection outer commons grp schemas params from (("fromOnly" ::: NotNull PGtext) ': []) #

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

DEFAULT is available for inserts and updates

NoDef

DEFAULT is unavailable for inserts and updates

Instances
ty0 ~ ty1 => SamePGType (alias0 ::: (def0 :=> nullity0 ty0)) (alias1 ::: (def1 :=> nullity1 ty1)) 
Instance details

Defined in Squeal.PostgreSQL.Schema

AddColumn (NoDef :=> Null ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (NoDef :=> Null ty) -> AlterTable sch tab schemas (constraints :=> Create column (NoDef :=> Null ty) columns) #

AddColumn (Def :=> ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (Def :=> ty) -> AlterTable sch tab schemas (constraints :=> Create column (Def :=> ty) columns) #

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.

Instances
SListI (TableToColumns table) => RenderSQL (ConflictClause tab commons schemas params table)

Render a ConflictClause.

Instance details

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.

Equations

Uniquely key ((uq ::: Unique key) ': constraints) = () 
Uniquely key ((pk ::: PrimaryKey key) ': constraints) = () 
Uniquely key (_ ': constraints) = Uniquely key constraints 

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 PGIntegral = PGint2 ': (PGint4 ': (PGint8 ': ([] :: [PGType]))) #

Integral 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)) 
Instance details

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.

Equations

Drop alias ((alias ::: x) ': xs :: [(Symbol, k)]) = xs 
Drop alias (x ': xs :: [(Symbol, k)]) = x ': Drop alias xs 

type family Alter (alias :: Symbol) (x :: k) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Alter alias x xs replaces the type associated with an alias in xs with the type x and is used in alterTable and alterColumn.

Equations

Alter alias (x1 :: k) ((alias ::: x0) ': xs :: [(Symbol, k)]) = (alias ::: x1) ': xs 
Alter alias (x1 :: k) (x0 ': xs :: [(Symbol, k)]) = x0 ': Alter alias x1 xs 

type family Rename (alias0 :: Symbol) (alias1 :: Symbol) (xs :: [(Symbol, k)]) :: [(Symbol, k)] where ... #

Rename alias0 alias1 xs replaces the alias alias0 by alias1 in xs and is used in alterTableRename and renameColumn.

Equations

Rename alias0 alias1 ((alias0 ::: x0) ': xs :: [(Symbol, k)]) = (alias1 ::: x0) ': xs 
Rename alias0 alias1 (x ': xs :: [(Symbol, k)]) = x ': Rename alias0 alias1 xs 

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 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

id :: Definition a a #

(.) :: Definition b c -> Definition a b -> Definition a c #

(IndexedMonadTransPQ trans, Monad monad, forall (x0 :: SchemasType) (x1 :: SchemasType). x0 ~ x1 => Monad (trans x0 x1 monad)) => Category (Terminally trans monad :: SchemasType -> SchemasType -> Type) 
Instance details

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) 
Instance details

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"`.

Methods

label :: expr #

Instances
label ~ label1 => IsPGlabel label (PGlabel label1) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

label :: PGlabel label1 #

labels ~ (label ': ([] :: [Symbol])) => IsPGlabel label (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

label :: NP PGlabel labels #

(KnownSymbol label, In label labels) => IsPGlabel label (Expression outer commons grp schemas params from (null (PGenum labels))) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

label :: Expression outer commons grp schemas params from (null (PGenum labels)) #

data PGlabel (label :: Symbol) #

A PGlabel unit type with an IsPGlabel instance

Constructors

PGlabel 
Instances
label ~ label1 => IsPGlabel label (PGlabel label1) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

label :: PGlabel label1 #

labels ~ (label ': ([] :: [Symbol])) => IsPGlabel label (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

label :: NP PGlabel labels #

KnownSymbol label => RenderSQL (PGlabel label) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

renderSQL :: PGlabel label -> ByteString #

All KnownSymbol labels => RenderSQL (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

renderSQL :: NP PGlabel labels -> ByteString #

type PGJsonKey = PGint2 ': (PGint4 ': (PGtext ': ([] :: [PGType]))) #

Is a type a valid JSON key?

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 
Instance details

Defined in Squeal.PostgreSQL.Schema

(TypeError ((Text "Cannot assign to " :<>: ShowType alias) :<>: Text " more than once") :: Constraint) => IsNotElem ((,) alias a :: (k2, k1)) True 
Instance details

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)]) 
Instance details

Defined in Squeal.PostgreSQL.Schema

(IsNotElem x (Elem x xs), AllUnique xs) => AllUnique (x ': xs :: [(Symbol, a)]) 
Instance details

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\""

type (:::) (alias :: Symbol) (ty :: k) = (,) alias ty infixr 6 #

The alias operator ::: is like a promoted version of As, a type level pair between an alias and some type.

data Grouping #

Grouping is an auxiliary namespace, created by GROUP BY clauses (group), and used for typesafe aggregation

Constructors

Ungrouped

no aggregation permitted

Grouped [(Symbol, Symbol)]

aggregation required for any column which is not grouped

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)]) 
Instance details

Defined in Squeal.PostgreSQL.Alias

(KnownSymbol table, KnownSymbol column, GroupedBy table column bys) => GroupedBy table column (tabcol ': bys :: [a]) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(!) :: Alias table -> Alias column -> (Alias table, Alias column) #

alias1 ~ alias2 => IsLabel alias1 (Alias alias2) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Alias alias2 #

aliases ~ (alias ': ([] :: [Symbol])) => IsLabel alias (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: NP Alias aliases #

(alias0 ~ alias1, alias0 ~ alias2, KnownSymbol alias2) => IsLabel alias0 (Aliased Alias (alias1 ::: alias2)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Aliased Alias (alias1 ::: alias2) #

Eq (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(==) :: Alias alias -> Alias alias -> Bool #

(/=) :: Alias alias -> Alias alias -> Bool #

Ord (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

compare :: Alias alias -> Alias alias -> Ordering #

(<) :: Alias alias -> Alias alias -> Bool #

(<=) :: Alias alias -> Alias alias -> Bool #

(>) :: Alias alias -> Alias alias -> Bool #

(>=) :: Alias alias -> Alias alias -> Bool #

max :: Alias alias -> Alias alias -> Alias alias #

min :: Alias alias -> Alias alias -> Alias alias #

Show (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

showsPrec :: Int -> Alias alias -> ShowS #

show :: Alias alias -> String #

showList :: [Alias alias] -> ShowS #

Generic (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Associated Types

type Rep (Alias alias) :: Type -> Type #

Methods

from :: Alias alias -> Rep (Alias alias) x #

to :: Rep (Alias alias) x -> Alias alias #

NFData (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

rnf :: Alias alias -> () #

KnownSymbol alias => RenderSQL (Alias alias)
>>> printSQL (#jimbob :: Alias "jimbob")
"jimbob"
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

renderSQL :: Alias alias -> ByteString #

All KnownSymbol aliases => RenderSQL (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString #

type Rep (Alias alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

type Rep (Alias alias) = D1 (MetaData "Alias" "Squeal.PostgreSQL.Alias" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "Alias" PrefixI False) (U1 :: Type -> Type))

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons Ungrouped schemas params from) column #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons (Grouped bys) schemas params from) column #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) #

(KnownSymbol alias, tys ~ ((alias ::: ty) ': ([] :: [(Symbol, k)]))) => Aliasable alias (expression ty) (NP (Aliased expression) tys) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

as :: expression ty -> Alias alias -> NP (Aliased expression) tys #

(KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

as :: expression ty -> Alias alias -> Aliased expression aliased #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

fromLabel :: NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(HasUnique tab (Join outer from) row, Has col row ty, column ~ (col ::: ty)) => IsLabel col (Aliased (Expression outer commons Ungrouped schemas params from) column) 
Instance details

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) 
Instance details

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)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Aliased Alias (alias1 ::: alias2) #

(q ~ "public", a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsLabel a0 (Aliased (QualifiedAlias q) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) #

Eq (expression ty) => Eq (Aliased expression (alias ::: ty)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(==) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

(/=) :: Aliased expression (alias ::: ty) -> Aliased expression (alias ::: ty) -> Bool #

Ord (expression ty) => Ord (Aliased expression (alias ::: ty)) 
Instance details

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)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

showsPrec :: Int -> Aliased expression (alias ::: ty) -> ShowS #

show :: Aliased expression (alias ::: ty) -> String #

showList :: [Aliased expression (alias ::: ty)] -> ShowS #

class KnownSymbol alias => Aliasable (alias :: Symbol) expression aliased | aliased -> expression, aliased -> alias where #

The Aliasable class provides a way to scrap your Nils in an NP list of Aliased expressions.

Methods

as :: expression -> Alias alias -> aliased #

Instances
(KnownSymbol alias, tys ~ ((alias ::: ty) ': ([] :: [(Symbol, k)]))) => Aliasable alias (expression ty) (NP (Aliased expression) tys) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

as :: expression ty -> Alias alias -> NP (Aliased expression) tys #

(KnownSymbol alias, aliased ~ (alias ::: ty)) => Aliasable alias (expression ty) (Aliased expression aliased) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

as :: expression ty -> Alias alias -> Aliased expression aliased #

(KnownSymbol cte, commons1 ~ ((cte ::: common) ': commons)) => Aliasable cte (statement commons schemas params common) (AlignedList (CommonTableExpression statement schemas params) commons commons1) 
Instance details

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) 
Instance details

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) 
Instance details

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.

Instances
Has alias fields field => HasIn (fields :: [(Symbol, k)]) (alias ::: field :: (Symbol, k)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

class All KnownSymbol aliases => HasAll (aliases :: [Symbol]) (fields :: [(Symbol, kind)]) (subfields :: [(Symbol, kind)]) | aliases fields -> subfields #

HasAll extends Has to take lists of aliases and fields and infer a list of subfields.

Instances
HasAll ([] :: [Symbol]) (fields :: [(Symbol, kind)]) ([] :: [(Symbol, kind)]) 
Instance details

Defined in Squeal.PostgreSQL.Alias

(Has alias fields field, HasAll aliases fields subfields) => HasAll (alias ': aliases) (fields :: [(Symbol, k)]) ((alias ::: field) ': subfields :: [(Symbol, k)]) 
Instance details

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.

Methods

(!) :: Alias table -> Alias column -> expression infixl 9 #

Instances
(Has rel rels cols, Has col cols ty, by ~ (,) rel col) => IsQualified rel col (By rels by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias rel -> Alias col -> By rels by #

IsQualified table column (Alias table, Alias column) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(!) :: Alias table -> Alias column -> (Alias table, Alias column) #

(q ~ q', a ~ a') => IsQualified q a (QualifiedAlias q' a') 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias rel -> Alias 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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons Ungrouped schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons Ungrouped schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Expression outer commons (Grouped bys) schemas params from) tys #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> NP (Aliased (Expression outer commons (Grouped bys) schemas params from)) columns #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons Ungrouped schemas params from) column #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Aliased (Expression outer commons (Grouped bys) schemas params from) column #

(q0 ~ q1, a0 ~ a1, a1 ~ a2, KnownSymbol a2) => IsQualified q0 a0 (Aliased (QualifiedAlias q1) (a1 ::: a2)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias tab -> Alias 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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

(!) :: Alias tab -> Alias 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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression outer commons Ungrouped schemas params from ty #

(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) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

(!) :: Alias tab -> Alias col -> Expression outer commons (Grouped bys) schemas params from ty #

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') 
Instance details

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)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(!) :: Alias q0 -> Alias a0 -> Aliased (QualifiedAlias q1) (a1 ::: a2) #

(q' ~ "public", a ~ a') => IsLabel a (QualifiedAlias q' a') 
Instance details

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)) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

fromLabel :: Aliased (QualifiedAlias q) (a1 ::: a2) #

Eq (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

(==) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

(/=) :: QualifiedAlias qualifier alias -> QualifiedAlias qualifier alias -> Bool #

Ord (QualifiedAlias qualifier alias) 
Instance details

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

rnf :: QualifiedAlias qualifier alias -> () #

(KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) 
Instance details

Defined in Squeal.PostgreSQL.Alias

type Rep (QualifiedAlias qualifier alias) 
Instance details

Defined in Squeal.PostgreSQL.Alias

type Rep (QualifiedAlias qualifier alias) = D1 (MetaData "QualifiedAlias" "Squeal.PostgreSQL.Alias" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "QualifiedAlias" PrefixI False) (U1 :: Type -> Type))

(*:) :: f x -> f y -> NP f (x ': (y ': ([] :: [k]))) infixl 9 #

A useful operator for ending an NP list of length at least 2 without Nil.

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.

disjoin :: SListI xs => NP expr (Join xs ys) -> (NP expr xs, NP expr ys) #

disjoin is a utility function for splitting an NP list into pieces.

type family Join (xs :: [a]) (ys :: [a]) :: [a] where ... #

Join is simply promoted ++ and is used in JOINs in FromClauses.

Equations

Join ([] :: [a]) (ys :: [a]) = ys 
Join (x ': xs :: [a]) (ys :: [a]) = x ': Join xs ys 

class Additional (expr :: [a] -> Type) where #

The Additional class is for appending type-level list parameterized constructors such as NP, Selection, and FromClause.

Methods

also :: expr ys -> expr xs -> expr (Join xs ys) #

Instances
Additional (NP expr :: [a] -> Type) 
Instance details

Defined in Squeal.PostgreSQL.List

Methods

also :: NP expr ys -> NP expr xs -> NP expr (Join xs ys) #

Additional (FromClause outer commons schemas params :: [a] -> Type) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

also :: Selection outer commons grp schemas params from ys -> Selection outer commons grp schemas params from xs -> Selection outer commons grp schemas params from (Join xs ys) #

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) 
Instance details

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) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.List

Methods

renderSQL :: AlignedList p x0 x1 -> ByteString #

type family Elem (x :: k) (xs :: [k]) :: Bool where ... #

Elem is a promoted elem.

Equations

Elem (x :: k) ([] :: [k]) = False 
Elem (x :: a) (x ': xs :: [a]) = True 
Elem (x :: k) (_ ': xs :: [k]) = Elem x xs 

type family In (x :: t) (xs :: [t]) :: Constraint where ... #

In x xs is a constraint that proves that x is in xs.

Equations

In (x :: t) (xs :: [t]) = If (Elem x xs) () (TypeError ((ShowType x :<>: Text "is not in ") :<>: ShowType xs) :: Constraint) 

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

Equations

Length (x ': xs :: [k]) = 1 + Length xs 
Length ([] :: [k]) = 0 

printSQL :: (RenderSQL sql, MonadIO io) => sql -> io () #

Print SQL.

class RenderSQL sql where #

A class for rendering SQL

Methods

renderSQL :: sql -> ByteString #

Instances
RenderSQL TransactionMode

Render a TransactionMode.

Instance details

Defined in Squeal.PostgreSQL.Transaction

RenderSQL IsolationLevel

Render an IsolationLevel.

Instance details

Defined in Squeal.PostgreSQL.Transaction

RenderSQL AccessMode

Render an AccessMode.

Instance details

Defined in Squeal.PostgreSQL.Transaction

RenderSQL DeferrableMode

Render a DeferrableMode.

Instance details

Defined in Squeal.PostgreSQL.Transaction

RenderSQL OnDeleteClause

Render OnDeleteClause.

Instance details

Defined in Squeal.PostgreSQL.Definition

RenderSQL OnUpdateClause

Render OnUpdateClause.

Instance details

Defined in Squeal.PostgreSQL.Definition

RenderSQL TimeUnit 
Instance details

Defined in Squeal.PostgreSQL.Expression.Time

KnownSymbol label => RenderSQL (PGlabel label) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

renderSQL :: PGlabel label -> ByteString #

KnownSymbol alias => RenderSQL (Alias alias)
>>> printSQL (#jimbob :: Alias "jimbob")
"jimbob"
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

renderSQL :: Alias alias -> ByteString #

RenderSQL (Definition schemas0 schemas1) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: Definition schemas0 schemas1 -> ByteString #

RenderSQL (ColumnTypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: ColumnTypeExpression schemas ty -> ByteString #

RenderSQL (ConflictTarget constraints)

Render a ConflictTarget

Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: ConflictTarget constraints -> ByteString #

RenderSQL (By from by) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: By from by -> ByteString #

RenderSQL (GroupByClause grp from)

Renders a GroupByClause.

Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: GroupByClause grp from -> ByteString #

RenderSQL (TypeExpression schemas ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Type

Methods

renderSQL :: TypeExpression schemas ty -> ByteString #

(KnownSymbol q, KnownSymbol a) => RenderSQL (QualifiedAlias q a) 
Instance details

Defined in Squeal.PostgreSQL.Alias

All KnownSymbol labels => RenderSQL (NP PGlabel labels) 
Instance details

Defined in Squeal.PostgreSQL.Schema

Methods

renderSQL :: NP PGlabel labels -> ByteString #

All KnownSymbol aliases => RenderSQL (NP Alias aliases) 
Instance details

Defined in Squeal.PostgreSQL.Alias

Methods

renderSQL :: NP Alias aliases -> ByteString #

(forall (x :: k). RenderSQL (expr x)) => RenderSQL (Optional expr ty) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: Optional expr ty -> ByteString #

SListI tys => RenderSQL (Distinction (NP (Expression outer commons grp schemas params from)) tys) 
Instance details

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) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Aggregate

Methods

renderSQL :: Distinction (Expression outer commons grp schemas params from) ty -> ByteString #

RenderSQL (TableConstraintExpression sch tab schemas constraint) 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: TableConstraintExpression sch tab schemas constraint -> ByteString #

RenderSQL (Manipulation commons schemas params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: Manipulation commons schemas params columns -> ByteString #

RenderSQL (QueryClause commons schemas params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: QueryClause commons schemas params columns -> ByteString #

(forall (t0 :: k) (t1 :: k). RenderSQL (p t0 t1)) => RenderSQL (AlignedList p x0 x1) 
Instance details

Defined in Squeal.PostgreSQL.List

Methods

renderSQL :: AlignedList p x0 x1 -> ByteString #

RenderSQL (ReturningClause commons schemas params from row) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: ReturningClause commons schemas params from row -> ByteString #

RenderSQL (ConflictAction tab commons schemas params columns) 
Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: ConflictAction tab commons schemas params columns -> ByteString #

RenderSQL (Query outer commons schemas params row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: Query outer commons schemas params row -> ByteString #

(forall (c :: FromType) (s :: SchemasType) (p :: [NullityType]) (r :: RowType). RenderSQL (statement c s p r)) => RenderSQL (CommonTableExpression statement schemas params commons0 commons1) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: CommonTableExpression statement schemas params commons0 commons1 -> ByteString #

SListI (TableToColumns table) => RenderSQL (ConflictClause tab commons schemas params table)

Render a ConflictClause.

Instance details

Defined in Squeal.PostgreSQL.Manipulation

Methods

renderSQL :: ConflictClause tab commons schemas params table -> ByteString #

RenderSQL (TableExpression outer commons grp schemas params from)

Render a TableExpression

Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: TableExpression outer commons grp schemas params from -> ByteString #

RenderSQL (HavingClause outer commons grp schemas params from)

Render a HavingClause.

Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: HavingClause outer commons grp schemas params from -> ByteString #

RenderSQL (WindowDefinition outer commons schemas from grp params) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowDefinition outer commons schemas from grp params -> ByteString #

RenderSQL (SortExpression outer commons grp schemas params from) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Sort

Methods

renderSQL :: SortExpression outer commons grp schemas params from -> ByteString #

RenderSQL (Selection outer commons grp schemas params from row) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: Selection outer commons grp schemas params from row -> ByteString #

RenderSQL (WindowFunction outer commons grp schemas params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression.Window

Methods

renderSQL :: WindowFunction outer commons grp schemas params from ty -> ByteString #

RenderSQL (Expression outer commons grp schemas params from ty) 
Instance details

Defined in Squeal.PostgreSQL.Expression

Methods

renderSQL :: Expression outer commons grp schemas params from ty -> ByteString #

RenderSQL (FromClause outer commons schemas params from) 
Instance details

Defined in Squeal.PostgreSQL.Query

Methods

renderSQL :: FromClause outer commons schemas params from -> ByteString #

type Pool = Pool #