{-# LANGUAGE LiberalTypeSynonyms #-}
{-# LANGUAGE ImpredicativeTypes #-}
module PgSchema.DML.Select.Types
where
import Control.Monad.RWS
import Data.Kind
import Data.Proxy
import Data.Singletons (demote)
import Data.List as L
import Data.List.NonEmpty as NE
import Data.String
import Data.Text(Text)
import Database.PostgreSQL.Simple.ToField
import PgSchema.Schema
import PgSchema.Types
import GHC.Generics
import GHC.Natural
import GHC.TypeLits
import PgSchema.Utils.Internal
import PgSchema.Utils.TF
data QueryParam sch t = QueryParam
{ forall sch (t :: NameNSK). QueryParam sch t -> [CondWithPath sch t]
qpConds :: ![CondWithPath sch t]
, forall sch (t :: NameNSK). QueryParam sch t -> [OrdWithPath sch t]
qpOrds :: ![OrdWithPath sch t]
, forall sch (t :: NameNSK).
QueryParam sch t -> [LimOffWithPath sch t]
qpLOs :: ![LimOffWithPath sch t]
, forall sch (t :: NameNSK). QueryParam sch t -> [DistWithPath sch t]
qpDistinct :: ![DistWithPath sch t]
}
qpEmpty :: forall sch t. QueryParam sch t
qpEmpty :: forall sch (t :: NameNSK). QueryParam sch t
qpEmpty = [CondWithPath sch t]
-> [OrdWithPath sch t]
-> [LimOffWithPath sch t]
-> [DistWithPath sch t]
-> QueryParam sch t
forall sch (t :: NameNSK).
[CondWithPath sch t]
-> [OrdWithPath sch t]
-> [LimOffWithPath sch t]
-> [DistWithPath sch t]
-> QueryParam sch t
QueryParam [] [] [] []
type MonadQP sch t path = (TabPath sch t path, ToStar path) => RWS (Proxy path) () (QueryParam sch t) ()
qRoot :: RWS (Proxy '[]) () (QueryParam sch t) () -> QueryParam sch t
qRoot :: forall {a} sch (t :: NameNSK).
RWS (Proxy '[]) () (QueryParam sch t) () -> QueryParam sch t
qRoot RWS (Proxy '[]) () (QueryParam sch t) ()
m = (QueryParam sch t, ()) -> QueryParam sch t
forall a b. (a, b) -> a
fst ((QueryParam sch t, ()) -> QueryParam sch t)
-> (QueryParam sch t, ()) -> QueryParam sch t
forall a b. (a -> b) -> a -> b
$ RWS (Proxy '[]) () (QueryParam sch t) ()
-> Proxy '[] -> QueryParam sch t -> (QueryParam sch t, ())
forall r w s a. RWS r w s a -> r -> s -> (s, w)
execRWS RWS (Proxy '[]) () (QueryParam sch t) ()
m Proxy '[]
forall {k} (t :: k). Proxy t
Proxy QueryParam sch t
forall sch (t :: NameNSK). QueryParam sch t
qpEmpty
qPath :: forall sch t path path'.
forall (p :: Symbol) ->
(TabPath sch t path', ToStar path', path' ~ path ++ '[p]) =>
MonadQP sch t path' -> MonadQP sch t path
qPath :: forall sch (t :: NameNSK) (path :: [Symbol]) (path' :: [Symbol]).
forall (p :: Symbol) ->
(TabPath sch t path', ToStar path', path' ~ (path ++ '[p])) =>
MonadQP sch t path' -> MonadQP sch t path
qPath _p MonadQP sch t path'
m = do
s <- RWST (Proxy path) () (QueryParam sch t) Identity (QueryParam sch t)
forall s (m :: * -> *). MonadState s m => m s
get
put $ fst $ execRWS m Proxy s
qWhere :: forall sch t path. Cond sch (TabOnPath sch t path) -> MonadQP sch t path
qWhere :: forall sch (t :: NameNSK) (path :: [Symbol]).
Cond sch (TabOnPath sch t path) -> MonadQP sch t path
qWhere Cond sch (TabOnPath sch t path)
c = (QueryParam sch t -> QueryParam sch t)
-> RWST (Proxy path) () (QueryParam sch t) Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \QueryParam sch t
qp -> QueryParam sch t
qp { qpConds = CondWithPath @path c : qp.qpConds }
qOrderBy :: forall sch t path. [OrdFld sch (TabOnPath sch t path)] -> MonadQP sch t path
qOrderBy :: forall sch (t :: NameNSK) (path :: [Symbol]).
[OrdFld sch (TabOnPath sch t path)] -> MonadQP sch t path
qOrderBy [OrdFld sch (TabOnPath sch t path)]
ofs = (QueryParam sch t -> QueryParam sch t)
-> RWST (Proxy path) () (QueryParam sch t) Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \QueryParam sch t
qp -> QueryParam sch t
qp { qpOrds = OrdWithPath @path ofs : qp.qpOrds }
qDistinct :: forall sch t path t'. TabOnPath2 sch t path ~ '(t', 'RelMany) =>
MonadQP sch t path
qDistinct :: forall sch (t :: NameNSK) (path :: [Symbol]) (t' :: NameNSK).
(TabOnPath2 sch t path ~ '(t', 'RelMany)) =>
MonadQP sch t path
qDistinct = (QueryParam sch t -> QueryParam sch t)
-> RWST (Proxy path) () (QueryParam sch t) Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \QueryParam sch t
qp -> QueryParam sch t
qp { qpDistinct = DistWithPath @path Distinct : qp.qpDistinct }
qDistinctOn :: forall sch t path. [OrdFld sch (TabOnPath sch t path)] -> MonadQP sch t path
qDistinctOn :: forall sch (t :: NameNSK) (path :: [Symbol]).
[OrdFld sch (TabOnPath sch t path)] -> MonadQP sch t path
qDistinctOn [OrdFld sch (TabOnPath sch t path)]
ofs = (QueryParam sch t -> QueryParam sch t)
-> RWST (Proxy path) () (QueryParam sch t) Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \QueryParam sch t
qp -> QueryParam sch t
qp { qpDistinct = DistWithPath @path (DistinctOn ofs) : qp.qpDistinct }
qLimit :: forall sch t path. Snd (TabOnPath2 sch t path) ~ RelMany
=> Natural -> MonadQP sch t path
qLimit :: forall sch (t :: NameNSK) (path :: [Symbol]).
(Snd (TabOnPath2 sch t path) ~ 'RelMany) =>
Natural -> MonadQP sch t path
qLimit Natural
n = (QueryParam sch t -> QueryParam sch t)
-> RWST (Proxy path) () (QueryParam sch t) Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \QueryParam sch t
qp -> QueryParam sch t
qp { qpLOs = mk qp.qpLOs }
where
mk :: [LimOffWithPath sch t] -> [LimOffWithPath sch t]
mk [LimOffWithPath sch t]
xs = case (LimOffWithPath sch t -> Bool)
-> [LimOffWithPath sch t]
-> ([LimOffWithPath sch t], [LimOffWithPath sch t])
forall a. (a -> Bool) -> [a] -> ([a], [a])
L.break LimOffWithPath sch t -> Bool
eq [LimOffWithPath sch t]
xs of
([LimOffWithPath sch t]
xs1, []) -> LimOffWithPath sch t
new LimOffWithPath sch t
-> [LimOffWithPath sch t] -> [LimOffWithPath sch t]
forall a. a -> [a] -> [a]
: [LimOffWithPath sch t]
xs1
([LimOffWithPath sch t]
xs1, LimOffWithPath sch t
x:[LimOffWithPath sch t]
xs2) -> [LimOffWithPath sch t]
xs1 [LimOffWithPath sch t]
-> [LimOffWithPath sch t] -> [LimOffWithPath sch t]
forall a. Semigroup a => a -> a -> a
<> [LimOffWithPath sch t -> LimOffWithPath sch t
upd LimOffWithPath sch t
x] [LimOffWithPath sch t]
-> [LimOffWithPath sch t] -> [LimOffWithPath sch t]
forall a. Semigroup a => a -> a -> a
<> [LimOffWithPath sch t]
xs2
eq :: LimOffWithPath sch t -> Bool
eq (LimOffWithPath @p LO
_) = forall (a :: [Symbol]).
(SingKind [Symbol], SingI a) =>
Demote [Symbol]
forall {k} (a :: k). (SingKind k, SingI a) => Demote k
demote @p Demote [Symbol] -> Demote [Symbol] -> Bool
forall a. Eq a => a -> a -> Bool
== forall (a :: [Symbol]).
(SingKind [Symbol], SingI a) =>
Demote [Symbol]
forall {k} (a :: k). (SingKind k, SingI a) => Demote k
demote @path
upd :: LimOffWithPath sch t -> LimOffWithPath sch t
upd (LimOffWithPath @p LO
lo) = forall (fld :: [Symbol]) sch (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
forall {k} (fld :: [Symbol]) (sch :: k) (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
LimOffWithPath @p LO
lo{ limit = Just n }
new :: LimOffWithPath sch t
new = forall (fld :: [Symbol]) sch (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
forall {k} (fld :: [Symbol]) (sch :: k) (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
LimOffWithPath @path LO { limit :: Maybe Natural
limit = Natural -> Maybe Natural
forall a. a -> Maybe a
Just Natural
n, offset :: Maybe Natural
offset = Maybe Natural
forall a. Maybe a
Nothing }
qOffset :: forall sch t path. Snd (TabOnPath2 sch t path) ~ RelMany
=> Natural -> MonadQP sch t path
qOffset :: forall sch (t :: NameNSK) (path :: [Symbol]).
(Snd (TabOnPath2 sch t path) ~ 'RelMany) =>
Natural -> MonadQP sch t path
qOffset Natural
n = (QueryParam sch t -> QueryParam sch t)
-> RWST (Proxy path) () (QueryParam sch t) Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \QueryParam sch t
qp -> QueryParam sch t
qp { qpLOs = mk qp.qpLOs }
where
mk :: [LimOffWithPath sch t] -> [LimOffWithPath sch t]
mk [LimOffWithPath sch t]
xs = case (LimOffWithPath sch t -> Bool)
-> [LimOffWithPath sch t]
-> ([LimOffWithPath sch t], [LimOffWithPath sch t])
forall a. (a -> Bool) -> [a] -> ([a], [a])
L.break LimOffWithPath sch t -> Bool
eq [LimOffWithPath sch t]
xs of
([LimOffWithPath sch t]
xs1, []) -> LimOffWithPath sch t
new LimOffWithPath sch t
-> [LimOffWithPath sch t] -> [LimOffWithPath sch t]
forall a. a -> [a] -> [a]
: [LimOffWithPath sch t]
xs1
([LimOffWithPath sch t]
xs1, LimOffWithPath sch t
x:[LimOffWithPath sch t]
xs2) -> [LimOffWithPath sch t]
xs1 [LimOffWithPath sch t]
-> [LimOffWithPath sch t] -> [LimOffWithPath sch t]
forall a. Semigroup a => a -> a -> a
<> [LimOffWithPath sch t -> LimOffWithPath sch t
upd LimOffWithPath sch t
x] [LimOffWithPath sch t]
-> [LimOffWithPath sch t] -> [LimOffWithPath sch t]
forall a. Semigroup a => a -> a -> a
<> [LimOffWithPath sch t]
xs2
eq :: LimOffWithPath sch t -> Bool
eq (LimOffWithPath @p LO
_) = forall (a :: [Symbol]).
(SingKind [Symbol], SingI a) =>
Demote [Symbol]
forall {k} (a :: k). (SingKind k, SingI a) => Demote k
demote @p Demote [Symbol] -> Demote [Symbol] -> Bool
forall a. Eq a => a -> a -> Bool
== forall (a :: [Symbol]).
(SingKind [Symbol], SingI a) =>
Demote [Symbol]
forall {k} (a :: k). (SingKind k, SingI a) => Demote k
demote @path
upd :: LimOffWithPath sch t -> LimOffWithPath sch t
upd (LimOffWithPath @p LO
lo) = forall (fld :: [Symbol]) sch (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
forall {k} (fld :: [Symbol]) (sch :: k) (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
LimOffWithPath @p LO
lo{offset = Just n}
new :: LimOffWithPath sch t
new = forall (fld :: [Symbol]) sch (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
forall {k} (fld :: [Symbol]) (sch :: k) (t :: NameNSK).
(TabPath sch t fld, ToStar fld,
Snd (TabOnPath2 sch t fld) ~ 'RelMany) =>
LO -> LimOffWithPath sch t
LimOffWithPath @path LO { offset :: Maybe Natural
offset = Natural -> Maybe Natural
forall a. a -> Maybe a
Just Natural
n, limit :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Nothing }
data CondWithPath sch t where
CondWithPath :: forall (path :: [Symbol]) sch t. ToStar path
=> Cond sch (TabOnPath sch t path) -> CondWithPath sch t
data OrdWithPath sch t where
OrdWithPath :: forall (path :: [Symbol]) sch t. ToStar path
=> [OrdFld sch (TabOnPath sch t path)] -> OrdWithPath sch t
data DistWithPath sch t where
DistWithPath :: forall (path :: [Symbol]) sch t. ToStar path
=> Dist sch (TabOnPath sch t path) -> DistWithPath sch t
data LimOffWithPath sch t where
LimOffWithPath :: forall (path :: [Symbol]) sch t.
(TabPath sch t path, ToStar path, Snd (TabOnPath2 sch t path) ~ 'RelMany)
=> LO -> LimOffWithPath sch t
data Cmp = (:=) | (:<=) | (:>=) | (:>) | (:<) | Like | ILike
deriving (Int -> Cmp -> ShowS
[Cmp] -> ShowS
Cmp -> String
(Int -> Cmp -> ShowS)
-> (Cmp -> String) -> ([Cmp] -> ShowS) -> Show Cmp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cmp -> ShowS
showsPrec :: Int -> Cmp -> ShowS
$cshow :: Cmp -> String
show :: Cmp -> String
$cshowList :: [Cmp] -> ShowS
showList :: [Cmp] -> ShowS
Show, Cmp -> Cmp -> Bool
(Cmp -> Cmp -> Bool) -> (Cmp -> Cmp -> Bool) -> Eq Cmp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Cmp -> Cmp -> Bool
== :: Cmp -> Cmp -> Bool
$c/= :: Cmp -> Cmp -> Bool
/= :: Cmp -> Cmp -> Bool
Eq, (forall x. Cmp -> Rep Cmp x)
-> (forall x. Rep Cmp x -> Cmp) -> Generic Cmp
forall x. Rep Cmp x -> Cmp
forall x. Cmp -> Rep Cmp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. Cmp -> Rep Cmp x
from :: forall x. Cmp -> Rep Cmp x
$cto :: forall x. Rep Cmp x -> Cmp
to :: forall x. Rep Cmp x -> Cmp
Generic)
data BoolOp = And | Or deriving (Int -> BoolOp -> ShowS
[BoolOp] -> ShowS
BoolOp -> String
(Int -> BoolOp -> ShowS)
-> (BoolOp -> String) -> ([BoolOp] -> ShowS) -> Show BoolOp
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BoolOp -> ShowS
showsPrec :: Int -> BoolOp -> ShowS
$cshow :: BoolOp -> String
show :: BoolOp -> String
$cshowList :: [BoolOp] -> ShowS
showList :: [BoolOp] -> ShowS
Show, BoolOp -> BoolOp -> Bool
(BoolOp -> BoolOp -> Bool)
-> (BoolOp -> BoolOp -> Bool) -> Eq BoolOp
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BoolOp -> BoolOp -> Bool
== :: BoolOp -> BoolOp -> Bool
$c/= :: BoolOp -> BoolOp -> Bool
/= :: BoolOp -> BoolOp -> Bool
Eq, (forall x. BoolOp -> Rep BoolOp x)
-> (forall x. Rep BoolOp x -> BoolOp) -> Generic BoolOp
forall x. Rep BoolOp x -> BoolOp
forall x. BoolOp -> Rep BoolOp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. BoolOp -> Rep BoolOp x
from :: forall x. BoolOp -> Rep BoolOp x
$cto :: forall x. Rep BoolOp x -> BoolOp
to :: forall x. Rep BoolOp x -> BoolOp
Generic)
showCmp :: IsString s => Cmp -> s
showCmp :: forall s. IsString s => Cmp -> s
showCmp = \case
Cmp
(:=) -> s
"="
Cmp
(:<=) -> s
"<="
Cmp
(:>=) -> s
">="
Cmp
(:<) -> s
"<"
Cmp
(:>) -> s
">"
Cmp
Like -> s
"like"
Cmp
ILike -> s
"ilike"
type CondMonad = RWS (Text, NonEmpty Int) [SomeToField] Int
data SomeToField where
SomeToField :: (ToField a, Show a) => a -> SomeToField
deriving instance Show SomeToField
instance ToField SomeToField where
toField :: SomeToField -> Action
toField (SomeToField a
v) = a -> Action
forall a. ToField a => a -> Action
toField a
v
type CDBField sch tab fld fd = (CDBFieldInfo sch tab fld
, TDBFieldInfo sch tab fld ~ 'RFPlain fd )
type CDBValue sch tab fld fd v =
(CDBField sch tab fld fd, ToField v, Show v, CanConvert sch tab fld fd v)
type CDBFieldNullable sch tab fld fd =
( CDBField sch tab fld fd, FdNullable fd ~ 'True)
data Cond (sch::Type) (tab::NameNSK) where
EmptyCond :: Cond sch tab
Cmp :: forall fld v sch tab fd. CDBValue sch tab fld fd v => Cmp -> v -> Cond sch tab
In :: forall fld v sch tab fd. CDBValue sch tab fld fd v => NonEmpty v -> Cond sch tab
InArr :: forall fld v sch tab fd. CDBValue sch tab fld fd v => [v] -> Cond sch tab
Null :: forall fld sch tab fd. CDBFieldNullable sch tab fld fd => Cond sch tab
Not :: Cond sch tab -> Cond sch tab
BoolOp :: BoolOp -> Cond sch tab -> Cond sch tab -> Cond sch tab
Child :: forall sch ref. CRelDef sch ref =>
TabParam sch (RdFrom (TRelDef sch ref)) -> Cond sch (RdFrom (TRelDef sch ref))
-> Cond sch (RdTo (TRelDef sch ref))
Parent :: forall sch ref . CRelDef sch ref =>
Cond sch (RdTo (TRelDef sch ref)) -> Cond sch (RdFrom (TRelDef sch ref))
UnsafeCond :: CondMonad Text -> Cond sch tab
instance Semigroup (Cond sch tab) where
Cond sch tab
c1 <> :: Cond sch tab -> Cond sch tab -> Cond sch tab
<> Cond sch tab
c2 = Cond sch tab
c1 Cond sch tab -> Cond sch tab -> Cond sch tab
forall sch (tab :: NameNSK).
Cond sch tab -> Cond sch tab -> Cond sch tab
&&& Cond sch tab
c2
instance Monoid (Cond sch tab) where
mempty :: Cond sch tab
mempty = Cond sch tab
forall sch (tab :: NameNSK). Cond sch tab
EmptyCond
data TabParam sch tab = TabParam
{ forall sch (tab :: NameNSK). TabParam sch tab -> Cond sch tab
cond :: Cond sch tab
, forall sch (tab :: NameNSK). TabParam sch tab -> [OrdFld sch tab]
order :: [OrdFld sch tab]
, forall sch (tab :: NameNSK). TabParam sch tab -> LO
lo :: LO }
defTabParam :: TabParam sch tab
defTabParam :: forall sch (tab :: NameNSK). TabParam sch tab
defTabParam = Cond sch tab -> [OrdFld sch tab] -> LO -> TabParam sch tab
forall sch (tab :: NameNSK).
Cond sch tab -> [OrdFld sch tab] -> LO -> TabParam sch tab
TabParam Cond sch tab
forall a. Monoid a => a
mempty [OrdFld sch tab]
forall a. Monoid a => a
mempty LO
defLO
{-# INLINE pnull #-}
pnull :: forall sch tab fd. forall name -> CDBFieldNullable sch tab name fd => Cond sch tab
pnull :: forall sch (tab :: NameNSK) (fd :: FldDef' Symbol).
forall (name :: Symbol) ->
CDBFieldNullable sch tab name fd => Cond sch tab
pnull name = forall (fld :: Symbol) sch (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBFieldNullable sch tab fld fd =>
Cond sch tab
Null @name
{-# INLINE pchild #-}
pchild :: forall sch . forall ref -> CRelDef sch ref =>
TabParam sch (RdFrom (TRelDef sch ref)) -> Cond sch (RdFrom (TRelDef sch ref))
-> Cond sch (RdTo (TRelDef sch ref))
pchild :: forall sch.
forall (ref :: NameNSK) ->
CRelDef sch ref =>
TabParam sch (RdFrom (TRelDef sch ref))
-> Cond sch (RdFrom (TRelDef sch ref))
-> Cond sch (RdTo (TRelDef sch ref))
pchild name = forall sch.
forall (ref :: NameNSK) ->
CRelDef sch ref =>
TabParam sch (RdFrom (TRelDef sch ref))
-> Cond sch (RdFrom (TRelDef sch ref))
-> Cond sch (RdTo (TRelDef sch ref))
Child @sch @name
{-# INLINE pparent #-}
pparent :: forall sch. forall ref -> CRelDef sch ref =>
Cond sch (RdTo (TRelDef sch ref)) -> Cond sch (RdFrom (TRelDef sch ref))
pparent :: forall sch.
forall (ref :: NameNSK) ->
CRelDef sch ref =>
Cond sch (RdTo (TRelDef sch ref))
-> Cond sch (RdFrom (TRelDef sch ref))
pparent name = forall sch.
forall (ref :: NameNSK) ->
CRelDef sch ref =>
Cond sch (RdTo (TRelDef sch ref))
-> Cond sch (RdFrom (TRelDef sch ref))
Parent @sch @name
{-# INLINE pnot #-}
pnot :: Cond sch tab -> Cond sch tab
pnot :: forall sch (tab :: NameNSK). Cond sch tab -> Cond sch tab
pnot = Cond sch tab -> Cond sch tab
forall sch (tab :: NameNSK). Cond sch tab -> Cond sch tab
Not
{-# INLINE pUnsafeCond #-}
pUnsafeCond :: CondMonad Text -> Cond sch tab
pUnsafeCond :: forall sch (tab :: NameNSK). CondMonad Text -> Cond sch tab
pUnsafeCond = CondMonad Text -> Cond sch tab
forall sch (tab :: NameNSK). CondMonad Text -> Cond sch tab
UnsafeCond
{-# INLINE pin #-}
pin :: forall name -> forall sch tab fd v. CDBValue sch tab name fd v
=> NonEmpty v -> Cond sch tab
pin :: forall (name :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab name fd v =>
NonEmpty v -> Cond sch tab
pin name = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
NonEmpty fd -> Cond sch tab
In @name
{-# INLINE pinArr #-}
pinArr :: forall name -> forall sch tab fd v. CDBValue sch tab name fd v
=> [v] -> Cond sch tab
pinArr :: forall (name :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab name fd v =>
[v] -> Cond sch tab
pinArr name = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
[fd] -> Cond sch tab
InArr @name
(&&&) :: Cond sch tab -> Cond sch tab -> Cond sch tab
(|||) :: Cond sch tab -> Cond sch tab -> Cond sch tab
Cond sch tab
EmptyCond &&& :: forall sch (tab :: NameNSK).
Cond sch tab -> Cond sch tab -> Cond sch tab
&&& Cond sch tab
cond = Cond sch tab
cond
Cond sch tab
cond &&& Cond sch tab
EmptyCond = Cond sch tab
cond
Cond sch tab
c1 &&& Cond sch tab
c2 = BoolOp -> Cond sch tab -> Cond sch tab -> Cond sch tab
forall sch (tab :: NameNSK).
BoolOp -> Cond sch tab -> Cond sch tab -> Cond sch tab
BoolOp BoolOp
And Cond sch tab
c1 Cond sch tab
c2
Cond sch tab
EmptyCond ||| :: forall sch (tab :: NameNSK).
Cond sch tab -> Cond sch tab -> Cond sch tab
||| Cond sch tab
cond = Cond sch tab
cond
Cond sch tab
cond ||| Cond sch tab
EmptyCond = Cond sch tab
cond
Cond sch tab
c1 ||| Cond sch tab
c2 = BoolOp -> Cond sch tab -> Cond sch tab -> Cond sch tab
forall sch (tab :: NameNSK).
BoolOp -> Cond sch tab -> Cond sch tab -> Cond sch tab
BoolOp BoolOp
Or Cond sch tab
c1 Cond sch tab
c2
infixl 2 |||
infixl 3 &&&
{-# INLINE (<?) #-}
{-# INLINE (>?) #-}
{-# INLINE (<=?) #-}
{-# INLINE (>=?) #-}
{-# INLINE (=?) #-}
{-# INLINE (~=?) #-}
{-# INLINE (~~?) #-}
(<?),(>?),(<=?),(>=?),(=?)
:: forall fld -> forall sch tab fd v. CDBValue sch tab fld fd v => v -> Cond sch tab
x <? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
<? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
(:<) v
b
x >? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
>? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
(:>) v
b
x <=? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
<=? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
(:<=) v
b
x >=? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
>=? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
(:>=) v
b
x =? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
=? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
(:=) v
b
(~=?),(~~?)
:: forall fld -> forall sch tab fd v. CDBValue sch tab fld fd v => v -> Cond sch tab
x ~=? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
~=? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
Like v
b
x ~~? :: forall (fld :: Symbol) ->
forall sch (tab :: NameNSK) (fd :: FldDef' Symbol) v.
CDBValue sch tab fld fd v =>
v -> Cond sch tab
~~? v
b = forall (fld :: Symbol) fd sch (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBValue sch tab fld fd fd =>
Cmp -> fd -> Cond sch tab
Cmp @x Cmp
ILike v
b
infix 4 <?, >?, <=?, >=?, =?, ~=?, ~~?
data OrdDirection = Asc | Desc deriving Int -> OrdDirection -> ShowS
[OrdDirection] -> ShowS
OrdDirection -> String
(Int -> OrdDirection -> ShowS)
-> (OrdDirection -> String)
-> ([OrdDirection] -> ShowS)
-> Show OrdDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OrdDirection -> ShowS
showsPrec :: Int -> OrdDirection -> ShowS
$cshow :: OrdDirection -> String
show :: OrdDirection -> String
$cshowList :: [OrdDirection] -> ShowS
showList :: [OrdDirection] -> ShowS
Show
data OrdFld sch tab where
OrdFld :: forall fld sch tab fd. CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
UnsafeOrd :: CondMonad (Text, OrdDirection) -> OrdFld sch tab
data Dist sch tab where
Distinct :: Dist sch tab
DistinctOn :: [OrdFld sch tab] -> Dist sch tab
{-# INLINE ordf #-}
ordf
:: forall fld -> forall sch tab fd. CDBField sch tab fld fd
=> OrdDirection -> OrdFld sch tab
ordf :: forall {k}.
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
ordf fld = forall {k}.
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
forall (fld :: Symbol) (sch :: k) (tab :: NameNSK)
(fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
OrdFld @fld
{-# INLINE ascf #-}
ascf :: forall fld -> forall sch tab fd. CDBField sch tab fld fd => OrdFld sch tab
ascf :: forall {k}.
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdFld sch tab
ascf fld = OrdDirection -> OrdFld sch tab
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
forall {k}.
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
ordf fld OrdDirection
Asc
{-# INLINE descf #-}
descf :: forall fld -> forall sch tab fd. CDBField sch tab fld fd => OrdFld sch tab
descf :: forall {k}.
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdFld sch tab
descf fld = OrdDirection -> OrdFld sch tab
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
forall {k}.
forall (fld :: Symbol) ->
forall (sch :: k) (tab :: NameNSK) (fd :: FldDef' Symbol).
CDBField sch tab fld fd =>
OrdDirection -> OrdFld sch tab
ordf fld OrdDirection
Desc
data LO = LO
{ LO -> Maybe Natural
limit :: Maybe Natural
, LO -> Maybe Natural
offset :: Maybe Natural }
deriving Int -> LO -> ShowS
[LO] -> ShowS
LO -> String
(Int -> LO -> ShowS)
-> (LO -> String) -> ([LO] -> ShowS) -> Show LO
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LO -> ShowS
showsPrec :: Int -> LO -> ShowS
$cshow :: LO -> String
show :: LO -> String
$cshowList :: [LO] -> ShowS
showList :: [LO] -> ShowS
Show
defLO :: LO
defLO :: LO
defLO = Maybe Natural -> Maybe Natural -> LO
LO Maybe Natural
forall a. Maybe a
Nothing Maybe Natural
forall a. Maybe a
Nothing
lo1 :: LO
lo1 :: LO
lo1 = Maybe Natural -> Maybe Natural -> LO
LO (Natural -> Maybe Natural
forall a. a -> Maybe a
Just Natural
1) Maybe Natural
forall a. Maybe a
Nothing