packages feed

esqueleto 3.4.3.0 → 3.5.0.0

raw patch · 23 files changed

+2017/−1824 lines, 23 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Database.Esqueleto.Experimental: [CrossJoinFromLateral] :: (SqlSelect b r, ToAlias b, ToAliasReference b) => From a -> (a -> SqlQuery b) -> From (a :& b)
- Database.Esqueleto.Experimental: [CrossJoinFrom] :: From a -> From b -> From (a :& b)
- Database.Esqueleto.Experimental: [FromCte] :: Ident -> a -> From a
- Database.Esqueleto.Experimental: [FullJoinFrom] :: (ToMaybe a, ToMaybe b) => From a -> (From b, (ToMaybeT a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> From (ToMaybeT a :& ToMaybeT b)
- Database.Esqueleto.Experimental: [InnerJoinFromLateral] :: (SqlSelect b r, ToAlias b, ToAliasReference b) => From a -> (a -> SqlQuery b, (a :& b) -> SqlExpr (Value Bool)) -> From (a :& b)
- Database.Esqueleto.Experimental: [InnerJoinFrom] :: From a -> (From b, (a :& b) -> SqlExpr (Value Bool)) -> From (a :& b)
- Database.Esqueleto.Experimental: [LeftJoinFromLateral] :: (SqlSelect b r, ToAlias b, ToAliasReference b, ToMaybe b) => From a -> (a -> SqlQuery b, (a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> From (a :& ToMaybeT b)
- Database.Esqueleto.Experimental: [LeftJoinFrom] :: ToMaybe b => From a -> (From b, (a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> From (a :& ToMaybeT b)
- Database.Esqueleto.Experimental: [RightJoinFrom] :: ToMaybe a => From a -> (From b, (ToMaybeT a :& b) -> SqlExpr (Value Bool)) -> From (ToMaybeT a :& b)
- Database.Esqueleto.Experimental: [SqlSetOperation] :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlSetOperation a -> From a
- Database.Esqueleto.Experimental: [SubQuery] :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a
- Database.Esqueleto.Experimental: [Table] :: PersistEntity ent => From (SqlExpr (Entity ent))
- Database.Esqueleto.Experimental: class ToFrom a where {
- Database.Esqueleto.Experimental: data From a
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b) => Database.Esqueleto.Experimental.ToAlias (a, b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAlias c) => Database.Esqueleto.Experimental.ToAlias (a, b, c)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAlias d) => Database.Esqueleto.Experimental.ToAlias (a, b, c, d)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAlias d, Database.Esqueleto.Experimental.ToAlias e) => Database.Esqueleto.Experimental.ToAlias (a, b, c, d, e)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAlias d, Database.Esqueleto.Experimental.ToAlias e, Database.Esqueleto.Experimental.ToAlias f) => Database.Esqueleto.Experimental.ToAlias (a, b, c, d, e, f)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAlias d, Database.Esqueleto.Experimental.ToAlias e, Database.Esqueleto.Experimental.ToAlias f, Database.Esqueleto.Experimental.ToAlias g) => Database.Esqueleto.Experimental.ToAlias (a, b, c, d, e, f, g)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAlias d, Database.Esqueleto.Experimental.ToAlias e, Database.Esqueleto.Experimental.ToAlias f, Database.Esqueleto.Experimental.ToAlias g, Database.Esqueleto.Experimental.ToAlias h) => Database.Esqueleto.Experimental.ToAlias (a, b, c, d, e, f, g, h)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Internal.Internal.SqlSelect a r) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.SqlQuery a)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b) => Database.Esqueleto.Experimental.ToAliasReference (a, b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference c) => Database.Esqueleto.Experimental.ToAliasReference (a, b, c)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference d) => Database.Esqueleto.Experimental.ToAliasReference (a, b, c, d)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference e) => Database.Esqueleto.Experimental.ToAliasReference (a, b, c, d, e)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference e, Database.Esqueleto.Experimental.ToAliasReference f) => Database.Esqueleto.Experimental.ToAliasReference (a, b, c, d, e, f)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference e, Database.Esqueleto.Experimental.ToAliasReference f, Database.Esqueleto.Experimental.ToAliasReference g) => Database.Esqueleto.Experimental.ToAliasReference (a, b, c, d, e, f, g)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference e, Database.Esqueleto.Experimental.ToAliasReference f, Database.Esqueleto.Experimental.ToAliasReference g, Database.Esqueleto.Experimental.ToAliasReference h) => Database.Esqueleto.Experimental.ToAliasReference (a, b, c, d, e, f, g, h)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFrom b, Database.Esqueleto.Experimental.ToFromT (Database.Esqueleto.Internal.Internal.CrossJoin a b) GHC.Types.~ (Database.Esqueleto.Experimental.ToFromT a Database.Esqueleto.Experimental.:& Database.Esqueleto.Experimental.ToFromT b)) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.CrossJoin a b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a', Database.Esqueleto.Experimental.ToFrom b, Database.Esqueleto.Experimental.ToFromT b GHC.Types.~ b') => Database.Esqueleto.Experimental.ToInnerJoin Database.Esqueleto.Experimental.NotLateral a b (a' Database.Esqueleto.Experimental.:& b')
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a', Database.Esqueleto.Experimental.ToFrom b, Database.Esqueleto.Experimental.ToFromT b GHC.Types.~ b', Database.Esqueleto.Experimental.ToMaybe a', ma GHC.Types.~ Database.Esqueleto.Experimental.ToMaybeT a', Database.Esqueleto.Experimental.ToMaybe b', mb GHC.Types.~ Database.Esqueleto.Experimental.ToMaybeT b', Database.Esqueleto.Experimental.ErrorOnLateral b) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.FullOuterJoin a (b, (ma Database.Esqueleto.Experimental.:& mb) -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool)))
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a', Database.Esqueleto.Experimental.ToFrom b, Database.Esqueleto.Experimental.ToFromT b GHC.Types.~ b', Database.Esqueleto.Experimental.ToMaybe b', mb GHC.Types.~ Database.Esqueleto.Experimental.ToMaybeT b') => Database.Esqueleto.Experimental.ToLeftJoin Database.Esqueleto.Experimental.NotLateral a b (a' Database.Esqueleto.Experimental.:& mb)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a', Database.Esqueleto.Experimental.ToMaybe a', ma GHC.Types.~ Database.Esqueleto.Experimental.ToMaybeT a', Database.Esqueleto.Experimental.ToFrom b, Database.Esqueleto.Experimental.ToFromT b GHC.Types.~ b', Database.Esqueleto.Experimental.ErrorOnLateral b) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.RightOuterJoin a (b, (ma Database.Esqueleto.Experimental.:& b') -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool)))
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a', Database.Esqueleto.Internal.Internal.SqlSelect b r, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAliasReference b) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.CrossJoin a (a' -> Database.Esqueleto.Internal.Internal.SqlQuery b))
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a', Database.Esqueleto.Internal.Internal.SqlSelect b r, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToMaybe b, mb GHC.Types.~ Database.Esqueleto.Experimental.ToMaybeT b) => Database.Esqueleto.Experimental.ToLeftJoin Database.Esqueleto.Experimental.Lateral a (a' -> Database.Esqueleto.Internal.Internal.SqlQuery b) (a' Database.Esqueleto.Experimental.:& mb)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b) => Database.Esqueleto.Experimental.ToMaybe (a Database.Esqueleto.Experimental.:& b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b) => Database.Esqueleto.Experimental.ToMaybe (a, b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe c) => Database.Esqueleto.Experimental.ToMaybe (a, b, c)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe d) => Database.Esqueleto.Experimental.ToMaybe (a, b, c, d)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe e) => Database.Esqueleto.Experimental.ToMaybe (a, b, c, d, e)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe e, Database.Esqueleto.Experimental.ToMaybe f) => Database.Esqueleto.Experimental.ToMaybe (a, b, c, d, e, f)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe e, Database.Esqueleto.Experimental.ToMaybe f, Database.Esqueleto.Experimental.ToMaybe g) => Database.Esqueleto.Experimental.ToMaybe (a, b, c, d, e, f, g)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe e, Database.Esqueleto.Experimental.ToMaybe f, Database.Esqueleto.Experimental.ToMaybe g, Database.Esqueleto.Experimental.ToMaybe h) => Database.Esqueleto.Experimental.ToMaybe (a, b, c, d, e, f, g, h)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c) => Database.Esqueleto.Experimental.ToSetOperation (Database.Esqueleto.Experimental.Except a b) c
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c) => Database.Esqueleto.Experimental.ToSetOperation (Database.Esqueleto.Experimental.Intersect a b) c
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c) => Database.Esqueleto.Experimental.ToSetOperation (Database.Esqueleto.Experimental.Union a b) c
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c) => Database.Esqueleto.Experimental.ToSetOperation (Database.Esqueleto.Experimental.UnionAll a b) c
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect a r, Database.Esqueleto.Experimental.ToAlias a, Database.Esqueleto.Experimental.ToAliasReference a) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Experimental.SqlSetOperation a)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect a ra, Database.Esqueleto.Internal.Internal.SqlSelect b rb) => Database.Esqueleto.Internal.Internal.SqlSelect (a Database.Esqueleto.Experimental.:& b) (ra Database.Esqueleto.Experimental.:& rb)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect b r, Database.Esqueleto.Experimental.ToAlias b, Database.Esqueleto.Experimental.ToAliasReference b, Database.Esqueleto.Experimental.ToFrom a, Database.Esqueleto.Experimental.ToFromT a GHC.Types.~ a') => Database.Esqueleto.Experimental.ToInnerJoin Database.Esqueleto.Experimental.Lateral a (a' -> Database.Esqueleto.Internal.Internal.SqlQuery b) (a' Database.Esqueleto.Experimental.:& b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect c r, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c, c GHC.Types.~ Database.Esqueleto.Experimental.SetOperationT a) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Experimental.Except a b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect c r, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c, c GHC.Types.~ Database.Esqueleto.Experimental.SetOperationT a) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Experimental.Intersect a b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect c r, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c, c GHC.Types.~ Database.Esqueleto.Experimental.SetOperationT a) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Experimental.Union a b)
- Database.Esqueleto.Experimental: instance (Database.Esqueleto.Internal.Internal.SqlSelect c r, Database.Esqueleto.Experimental.ToAlias c, Database.Esqueleto.Experimental.ToAliasReference c, Database.Esqueleto.Experimental.ToSetOperation a c, Database.Esqueleto.Experimental.ToSetOperation b c, c GHC.Types.~ Database.Esqueleto.Experimental.SetOperationT a) => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Experimental.UnionAll a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.RecursiveCteUnion (a -> b -> Database.Esqueleto.Experimental.Union a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.RecursiveCteUnion (a -> b -> Database.Esqueleto.Experimental.UnionAll a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToAlias (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToAlias (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToAlias (Database.Esqueleto.Internal.Internal.SqlExpr (GHC.Maybe.Maybe (Database.Persist.Class.PersistEntity.Entity a)))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToAliasReference (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToAliasReference (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToAliasReference (Database.Esqueleto.Internal.Internal.SqlExpr (GHC.Maybe.Maybe (Database.Persist.Class.PersistEntity.Entity a)))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Experimental.From a)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.FullOuterJoin a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.InnerJoin a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.LeftOuterJoin a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.RightOuterJoin a b)
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToInnerJoin (Database.Esqueleto.Experimental.IsLateral b) a b b' => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.InnerJoin a (b, b' -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool)))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToLeftJoin (Database.Esqueleto.Experimental.IsLateral b) a b b' => Database.Esqueleto.Experimental.ToFrom (Database.Esqueleto.Internal.Internal.LeftOuterJoin a (b, b' -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool)))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToMaybe (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToMaybe (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToMaybe (Database.Esqueleto.Internal.Internal.SqlExpr (GHC.Maybe.Maybe a))
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToSetOperation (Database.Esqueleto.Experimental.SqlSetOperation a) a
- Database.Esqueleto.Experimental: instance Database.Esqueleto.Experimental.ToSetOperation (Database.Esqueleto.Internal.Internal.SqlQuery a) a
- Database.Esqueleto.Experimental: toFrom :: ToFrom a => a -> From (ToFromT a)
- Database.Esqueleto.Internal.Internal: FromIdent :: Ident -> FromClause
- Database.Esqueleto.Internal.Internal: FromQuery :: Ident -> (IdentInfo -> (Builder, [PersistValue])) -> SubQueryType -> FromClause
- Database.Esqueleto.Internal.Internal: [EAliasedEntityReference] :: Ident -> Ident -> SqlExpr (Entity val)
- Database.Esqueleto.Internal.Internal: [EAliasedEntity] :: Ident -> Ident -> SqlExpr (Entity val)
- Database.Esqueleto.Internal.Internal: [EAliasedValue] :: Ident -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Internal: [ECompositeKey] :: (IdentInfo -> [Builder]) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Internal: [EDistinctOn] :: SqlExpr (Value a) -> SqlExpr DistinctOn
- Database.Esqueleto.Internal.Internal: [EEmptyList] :: SqlExpr (ValueList a)
- Database.Esqueleto.Internal.Internal: [EEntity] :: Ident -> SqlExpr (Entity val)
- Database.Esqueleto.Internal.Internal: [EInsertFinal] :: PersistEntity a => SqlExpr (Insertion a) -> SqlExpr InsertFinal
- Database.Esqueleto.Internal.Internal: [EInsert] :: Proxy a -> (IdentInfo -> (Builder, [PersistValue])) -> SqlExpr (Insertion a)
- Database.Esqueleto.Internal.Internal: [EList] :: SqlExpr (Value a) -> SqlExpr (ValueList a)
- Database.Esqueleto.Internal.Internal: [EMaybe] :: SqlExpr a -> SqlExpr (Maybe a)
- Database.Esqueleto.Internal.Internal: [EOrderBy] :: OrderByType -> SqlExpr (Value a) -> SqlExpr OrderBy
- Database.Esqueleto.Internal.Internal: [EOrderRandom] :: SqlExpr OrderBy
- Database.Esqueleto.Internal.Internal: [EPreprocessedFrom] :: a -> FromClause -> SqlExpr (PreprocessedFrom a)
- Database.Esqueleto.Internal.Internal: [ERaw] :: NeedParens -> (IdentInfo -> (Builder, [PersistValue])) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Internal: [ESet] :: (SqlExpr (Entity val) -> SqlExpr (Value ())) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Internal: [EValueReference] :: Ident -> (IdentInfo -> Ident) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Internal: aliasedValueIdentToRawSql :: Ident -> IdentInfo -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Internal: ifNotEmptyList :: SqlExpr (ValueList a) -> Bool -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Internal: instance Database.Esqueleto.Internal.Internal.SqlSelect (Database.Esqueleto.Internal.Internal.SqlExpr Database.Esqueleto.Internal.Internal.InsertFinal) Database.Esqueleto.Internal.Internal.InsertFinal
- Database.Esqueleto.Internal.Internal: valueReferenceToRawSql :: Ident -> (IdentInfo -> Ident) -> IdentInfo -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Internal: valueToRawSqlParens :: UnexpectedValueError -> SqlExpr (Value a) -> IdentInfo -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Language: (!=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (%) :: SqlString s => SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: (&&.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (*.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Language: (++.) :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: (+.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Language: (-.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Language: (/.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Language: (<#) :: (a -> b) -> SqlExpr (Value a) -> SqlExpr (Insertion b)
- Database.Esqueleto.Internal.Language: (<&>) :: SqlExpr (Insertion (a -> b)) -> SqlExpr (Value a) -> SqlExpr (Insertion b)
- Database.Esqueleto.Internal.Language: (<.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (<=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Language: (==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (>.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (>=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: (?.) :: (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ))
- Database.Esqueleto.Internal.Language: (^.) :: forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ)
- Database.Esqueleto.Internal.Language: (||.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: -- | e.g. <tt>type BaseEnt MyBase = MyChild</tt>
- Database.Esqueleto.Internal.Language: CrossJoin :: a -> b -> CrossJoin a b
- Database.Esqueleto.Internal.Language: CrossJoinKind :: JoinKind
- Database.Esqueleto.Internal.Language: ForShare :: LockingKind
- Database.Esqueleto.Internal.Language: ForUpdate :: LockingKind
- Database.Esqueleto.Internal.Language: ForUpdateSkipLocked :: LockingKind
- Database.Esqueleto.Internal.Language: FullOuterJoin :: a -> b -> FullOuterJoin a b
- Database.Esqueleto.Internal.Language: FullOuterJoinKind :: JoinKind
- Database.Esqueleto.Internal.Language: InnerJoin :: a -> b -> InnerJoin a b
- Database.Esqueleto.Internal.Language: InnerJoinKind :: JoinKind
- Database.Esqueleto.Internal.Language: LeftOuterJoin :: a -> b -> LeftOuterJoin a b
- Database.Esqueleto.Internal.Language: LeftOuterJoinKind :: JoinKind
- Database.Esqueleto.Internal.Language: LockInShareMode :: LockingKind
- Database.Esqueleto.Internal.Language: OnClauseWithoutMatchingJoinException :: String -> OnClauseWithoutMatchingJoinException
- Database.Esqueleto.Internal.Language: RightOuterJoin :: a -> b -> RightOuterJoin a b
- Database.Esqueleto.Internal.Language: RightOuterJoinKind :: JoinKind
- Database.Esqueleto.Internal.Language: Value :: a -> Value a
- Database.Esqueleto.Internal.Language: ValueList :: a -> ValueList a
- Database.Esqueleto.Internal.Language: [SomeValue] :: SqlExpr (Value a) -> SomeValue
- Database.Esqueleto.Internal.Language: [unValue] :: Value a -> a
- Database.Esqueleto.Internal.Language: asc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy
- Database.Esqueleto.Internal.Language: avg_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b))
- Database.Esqueleto.Internal.Language: between :: PersistField a => SqlExpr (Value a) -> (SqlExpr (Value a), SqlExpr (Value a)) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: case_ :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: castNum :: (Num a, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Language: castNumM :: (Num a, Num b) => SqlExpr (Value (Maybe a)) -> SqlExpr (Value (Maybe b))
- Database.Esqueleto.Internal.Language: castString :: (SqlString s, SqlString r) => SqlExpr (Value s) -> SqlExpr (Value r)
- Database.Esqueleto.Internal.Language: ceiling_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Language: class BackendCompatible sup sub
- Database.Esqueleto.Internal.Language: class From a
- Database.Esqueleto.Internal.Language: class FromPreprocess a
- Database.Esqueleto.Internal.Language: class IsJoinKind join
- Database.Esqueleto.Internal.Language: class PersistField a => SqlString a
- Database.Esqueleto.Internal.Language: class ToBaseId ent where {
- Database.Esqueleto.Internal.Language: class ToSomeValues a
- Database.Esqueleto.Internal.Language: coalesce :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value (Maybe a))
- Database.Esqueleto.Internal.Language: coalesceDefault :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: concat_ :: SqlString s => [SqlExpr (Value s)] -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: count :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: countDistinct :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: countRows :: Num a => SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: data CrossJoin a b
- Database.Esqueleto.Internal.Language: data DistinctOn
- Database.Esqueleto.Internal.Language: data FullOuterJoin a b
- Database.Esqueleto.Internal.Language: data InnerJoin a b
- Database.Esqueleto.Internal.Language: data Insertion a
- Database.Esqueleto.Internal.Language: data JoinKind
- Database.Esqueleto.Internal.Language: data LeftOuterJoin a b
- Database.Esqueleto.Internal.Language: data LockingKind
- Database.Esqueleto.Internal.Language: data OnClauseWithoutMatchingJoinException
- Database.Esqueleto.Internal.Language: data OrderBy
- Database.Esqueleto.Internal.Language: data PreprocessedFrom a
- Database.Esqueleto.Internal.Language: data RightOuterJoin a b
- Database.Esqueleto.Internal.Language: data SomeValue
- Database.Esqueleto.Internal.Language: data Update typ
- Database.Esqueleto.Internal.Language: desc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy
- Database.Esqueleto.Internal.Language: distinct :: SqlQuery a -> SqlQuery a
- Database.Esqueleto.Internal.Language: distinctOn :: [SqlExpr DistinctOn] -> SqlQuery a -> SqlQuery a
- Database.Esqueleto.Internal.Language: distinctOnOrderBy :: [SqlExpr OrderBy] -> SqlQuery a -> SqlQuery a
- Database.Esqueleto.Internal.Language: don :: SqlExpr (Value a) -> SqlExpr DistinctOn
- Database.Esqueleto.Internal.Language: else_ :: expr a -> expr a
- Database.Esqueleto.Internal.Language: exists :: SqlQuery () -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: floor_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Language: from :: From a => (a -> SqlQuery b) -> SqlQuery b
- Database.Esqueleto.Internal.Language: groupBy :: ToSomeValues a => a -> SqlQuery ()
- Database.Esqueleto.Internal.Language: having :: SqlExpr (Value Bool) -> SqlQuery ()
- Database.Esqueleto.Internal.Language: ilike :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: in_ :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: infix 4 !=.
- Database.Esqueleto.Internal.Language: infixl 2 `FullOuterJoin`
- Database.Esqueleto.Internal.Language: infixl 6 -.
- Database.Esqueleto.Internal.Language: infixl 7 *.
- Database.Esqueleto.Internal.Language: infixl 9 ^.
- Database.Esqueleto.Internal.Language: infixr 2 `ilike`
- Database.Esqueleto.Internal.Language: infixr 3 /=.
- Database.Esqueleto.Internal.Language: infixr 5 ++.
- Database.Esqueleto.Internal.Language: isNothing :: PersistField typ => SqlExpr (Value (Maybe typ)) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: joinV :: SqlExpr (Value (Maybe (Maybe typ))) -> SqlExpr (Value (Maybe typ))
- Database.Esqueleto.Internal.Language: just :: SqlExpr (Value typ) -> SqlExpr (Value (Maybe typ))
- Database.Esqueleto.Internal.Language: justList :: SqlExpr (ValueList typ) -> SqlExpr (ValueList (Maybe typ))
- Database.Esqueleto.Internal.Language: left_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: length_ :: (SqlString s, Num a) => SqlExpr (Value s) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: like :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: limit :: Int64 -> SqlQuery ()
- Database.Esqueleto.Internal.Language: locking :: LockingKind -> SqlQuery ()
- Database.Esqueleto.Internal.Language: lower_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: ltrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: max_ :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe a))
- Database.Esqueleto.Internal.Language: min_ :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe a))
- Database.Esqueleto.Internal.Language: newtype Value a
- Database.Esqueleto.Internal.Language: newtype ValueList a
- Database.Esqueleto.Internal.Language: notExists :: SqlQuery () -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: notIn :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: not_ :: SqlExpr (Value Bool) -> SqlExpr (Value Bool)
- Database.Esqueleto.Internal.Language: nothing :: SqlExpr (Value (Maybe typ))
- Database.Esqueleto.Internal.Language: offset :: Int64 -> SqlQuery ()
- Database.Esqueleto.Internal.Language: on :: SqlExpr (Value Bool) -> SqlQuery ()
- Database.Esqueleto.Internal.Language: orderBy :: [SqlExpr OrderBy] -> SqlQuery ()
- Database.Esqueleto.Internal.Language: projectBackend :: BackendCompatible sup sub => sub -> sup
- Database.Esqueleto.Internal.Language: rand :: SqlExpr OrderBy
- Database.Esqueleto.Internal.Language: random_ :: (PersistField a, Num a) => SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: reifyJoinKind :: IsJoinKind join => join a b -> JoinKind
- Database.Esqueleto.Internal.Language: right_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: round_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Language: rtrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery ()
- Database.Esqueleto.Internal.Language: smartJoin :: IsJoinKind join => a -> b -> join a b
- Database.Esqueleto.Internal.Language: subList_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)
- Database.Esqueleto.Internal.Language: subSelect :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value (Maybe a))
- Database.Esqueleto.Internal.Language: subSelectCount :: (Num a, PersistField a) => SqlQuery ignored -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: subSelectForeign :: (BackendCompatible SqlBackend (PersistEntityBackend val1), PersistEntity val1, PersistEntity val2, PersistField a) => SqlExpr (Entity val2) -> EntityField val2 (Key val1) -> (SqlExpr (Entity val1) -> SqlExpr (Value a)) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: subSelectList :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)
- Database.Esqueleto.Internal.Language: subSelectMaybe :: PersistField a => SqlQuery (SqlExpr (Value (Maybe a))) -> SqlExpr (Value (Maybe a))
- Database.Esqueleto.Internal.Language: subSelectUnsafe :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: sub_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Language: sum_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b))
- Database.Esqueleto.Internal.Language: then_ :: ()
- Database.Esqueleto.Internal.Language: toBaseId :: ToBaseId ent => SqlExpr (Value (Key ent)) -> SqlExpr (Value (Key (BaseEnt ent)))
- Database.Esqueleto.Internal.Language: toBaseIdWitness :: ToBaseId ent => Key (BaseEnt ent) -> Key ent
- Database.Esqueleto.Internal.Language: toSomeValues :: ToSomeValues a => a -> [SomeValue]
- Database.Esqueleto.Internal.Language: trim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: type family BaseEnt ent :: *;
- Database.Esqueleto.Internal.Language: upper_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
- Database.Esqueleto.Internal.Language: val :: PersistField typ => typ -> SqlExpr (Value typ)
- Database.Esqueleto.Internal.Language: valList :: PersistField typ => [typ] -> SqlExpr (ValueList typ)
- Database.Esqueleto.Internal.Language: when_ :: expr (Value Bool) -> () -> expr a -> (expr (Value Bool), expr a)
- Database.Esqueleto.Internal.Language: where_ :: SqlExpr (Value Bool) -> SqlQuery ()
- Database.Esqueleto.Internal.Language: withNonNull :: PersistField typ => SqlExpr (Value (Maybe typ)) -> (SqlExpr (Value typ) -> SqlQuery a) -> SqlQuery a
- Database.Esqueleto.Internal.Language: }
- Database.Esqueleto.Internal.Sql: DELETE :: Mode
- Database.Esqueleto.Internal.Sql: I :: Text -> Ident
- Database.Esqueleto.Internal.Sql: INSERT_INTO :: Mode
- Database.Esqueleto.Internal.Sql: Never :: NeedParens
- Database.Esqueleto.Internal.Sql: Parens :: NeedParens
- Database.Esqueleto.Internal.Sql: SELECT :: Mode
- Database.Esqueleto.Internal.Sql: UPDATE :: Mode
- Database.Esqueleto.Internal.Sql: [EAliasedEntityReference] :: Ident -> Ident -> SqlExpr (Entity val)
- Database.Esqueleto.Internal.Sql: [EAliasedEntity] :: Ident -> Ident -> SqlExpr (Entity val)
- Database.Esqueleto.Internal.Sql: [EAliasedValue] :: Ident -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Sql: [ECompositeKey] :: (IdentInfo -> [Builder]) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Sql: [EDistinctOn] :: SqlExpr (Value a) -> SqlExpr DistinctOn
- Database.Esqueleto.Internal.Sql: [EEmptyList] :: SqlExpr (ValueList a)
- Database.Esqueleto.Internal.Sql: [EEntity] :: Ident -> SqlExpr (Entity val)
- Database.Esqueleto.Internal.Sql: [EInsertFinal] :: PersistEntity a => SqlExpr (Insertion a) -> SqlExpr InsertFinal
- Database.Esqueleto.Internal.Sql: [EInsert] :: Proxy a -> (IdentInfo -> (Builder, [PersistValue])) -> SqlExpr (Insertion a)
- Database.Esqueleto.Internal.Sql: [EList] :: SqlExpr (Value a) -> SqlExpr (ValueList a)
- Database.Esqueleto.Internal.Sql: [EMaybe] :: SqlExpr a -> SqlExpr (Maybe a)
- Database.Esqueleto.Internal.Sql: [EOrderBy] :: OrderByType -> SqlExpr (Value a) -> SqlExpr OrderBy
- Database.Esqueleto.Internal.Sql: [EOrderRandom] :: SqlExpr OrderBy
- Database.Esqueleto.Internal.Sql: [EPreprocessedFrom] :: a -> FromClause -> SqlExpr (PreprocessedFrom a)
- Database.Esqueleto.Internal.Sql: [ERaw] :: NeedParens -> (IdentInfo -> (Builder, [PersistValue])) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Sql: [ESet] :: (SqlExpr (Entity val) -> SqlExpr (Value ())) -> SqlExpr (Update val)
- Database.Esqueleto.Internal.Sql: [EValueReference] :: Ident -> (IdentInfo -> Ident) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Sql: associateJoin :: forall e1 e0. Ord (Key e0) => [(Entity e0, e1)] -> Map (Key e0) (e0, [e1])
- Database.Esqueleto.Internal.Sql: builderToText :: Builder -> Text
- Database.Esqueleto.Internal.Sql: class SqlSelect a r | a -> r, r -> a
- Database.Esqueleto.Internal.Sql: class UnsafeSqlFunctionArgument a
- Database.Esqueleto.Internal.Sql: data IdentState
- Database.Esqueleto.Internal.Sql: data Mode
- Database.Esqueleto.Internal.Sql: data NeedParens
- Database.Esqueleto.Internal.Sql: data SqlExpr a
- Database.Esqueleto.Internal.Sql: data SqlQuery a
- Database.Esqueleto.Internal.Sql: delete :: MonadIO m => SqlQuery () -> SqlWriteT m ()
- Database.Esqueleto.Internal.Sql: deleteCount :: MonadIO m => SqlQuery () -> SqlWriteT m Int64
- Database.Esqueleto.Internal.Sql: deleteKey :: (PersistStore backend, BaseBackend backend ~ PersistEntityBackend val, MonadIO m, PersistEntity val) => Key val -> ReaderT backend m ()
- Database.Esqueleto.Internal.Sql: initialIdentState :: IdentState
- Database.Esqueleto.Internal.Sql: insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m ()
- Database.Esqueleto.Internal.Sql: insertSelectCount :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m Int64
- Database.Esqueleto.Internal.Sql: makeOrderByNoNewline :: IdentInfo -> [OrderByClause] -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Sql: newtype Ident
- Database.Esqueleto.Internal.Sql: parens :: Builder -> Builder
- Database.Esqueleto.Internal.Sql: rawEsqueleto :: (MonadIO m, SqlSelect a r, BackendCompatible SqlBackend backend) => Mode -> SqlQuery a -> ReaderT backend m Int64
- Database.Esqueleto.Internal.Sql: rawSelectSource :: (SqlSelect a r, MonadIO m1, MonadIO m2) => Mode -> SqlQuery a -> SqlReadT m1 (Acquire (ConduitT () r m2 ()))
- Database.Esqueleto.Internal.Sql: renderExpr :: SqlBackend -> SqlExpr (Value Bool) -> Text
- Database.Esqueleto.Internal.Sql: renderQueryDelete :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- Database.Esqueleto.Internal.Sql: renderQueryInsertInto :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- Database.Esqueleto.Internal.Sql: renderQuerySelect :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- Database.Esqueleto.Internal.Sql: renderQueryToText :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => Mode -> SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- Database.Esqueleto.Internal.Sql: renderQueryUpdate :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
- Database.Esqueleto.Internal.Sql: runSource :: Monad m => ConduitT () r (ReaderT backend m) () -> ReaderT backend m [r]
- Database.Esqueleto.Internal.Sql: select :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r]
- Database.Esqueleto.Internal.Sql: selectSource :: (SqlSelect a r, BackendCompatible SqlBackend backend, IsPersistBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend, MonadResource m) => SqlQuery a -> ConduitT () r (ReaderT backend m) ()
- Database.Esqueleto.Internal.Sql: sqlInsertInto :: SqlSelect a r => IdentInfo -> a -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Sql: sqlSelectColCount :: SqlSelect a r => Proxy a -> Int
- Database.Esqueleto.Internal.Sql: sqlSelectCols :: SqlSelect a r => IdentInfo -> a -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Sql: sqlSelectProcessRow :: SqlSelect a r => [PersistValue] -> Either Text r
- Database.Esqueleto.Internal.Sql: toArgList :: UnsafeSqlFunctionArgument a => a -> [SqlExpr (Value ())]
- Database.Esqueleto.Internal.Sql: toRawSql :: (SqlSelect a r, BackendCompatible SqlBackend backend) => Mode -> (backend, IdentState) -> SqlQuery a -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Sql: type IdentInfo = (SqlBackend, IdentState)
- Database.Esqueleto.Internal.Sql: type OrderByClause = SqlExpr OrderBy
- Database.Esqueleto.Internal.Sql: type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend)
- Database.Esqueleto.Internal.Sql: uncommas' :: Monoid a => [(Builder, a)] -> (Builder, a)
- Database.Esqueleto.Internal.Sql: unsafeSqlBinOp :: Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c)
- Database.Esqueleto.Internal.Sql: unsafeSqlBinOpComposite :: Builder -> Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c)
- Database.Esqueleto.Internal.Sql: unsafeSqlCase :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Sql: unsafeSqlCastAs :: Text -> SqlExpr (Value a) -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Sql: unsafeSqlExtractSubField :: UnsafeSqlFunctionArgument a => Builder -> a -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Sql: unsafeSqlFunction :: UnsafeSqlFunctionArgument a => Builder -> a -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Sql: unsafeSqlValue :: Builder -> SqlExpr (Value a)
- Database.Esqueleto.Internal.Sql: update :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m ()
- Database.Esqueleto.Internal.Sql: updateCount :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m Int64
- Database.Esqueleto.Internal.Sql: valJ :: PersistField (Key entity) => Value (Key entity) -> SqlExpr (Value (Key entity))
- Database.Esqueleto.Internal.Sql: valkey :: (ToBackendKey SqlBackend entity, PersistField (Key entity)) => Int64 -> SqlExpr (Value (Key entity))
- Database.Esqueleto.Internal.Sql: veryUnsafeCoerceSqlExprValue :: SqlExpr (Value a) -> SqlExpr (Value b)
- Database.Esqueleto.Internal.Sql: veryUnsafeCoerceSqlExprValueList :: SqlExpr (ValueList a) -> SqlExpr (Value a)
+ Database.Esqueleto.Experimental: From :: SqlQuery (a, RawFn) -> From a
+ Database.Esqueleto.Experimental: SubQuery :: a -> SubQuery a
+ Database.Esqueleto.Experimental: Table :: Table a
+ Database.Esqueleto.Experimental: [unFrom] :: From a -> SqlQuery (a, RawFn)
+ Database.Esqueleto.Experimental: class ToSqlSetOperation a r | a -> r
+ Database.Esqueleto.Experimental: crossJoin :: (ToFrom a a', ToFrom b b') => a -> b -> From (a' :& b')
+ Database.Esqueleto.Experimental: crossJoinLateral :: (ToFrom a a', SqlSelect b r, ToAlias b, ToAliasReference b) => a -> (a' -> SqlQuery b) -> From (a' :& b)
+ Database.Esqueleto.Experimental: data Table a
+ Database.Esqueleto.Experimental: fullOuterJoin :: (ToFrom a a', ToFrom b b', ToMaybe a', ToMaybe b', HasOnClause rhs (ToMaybeT a' :& ToMaybeT b'), rhs ~ (b, (ToMaybeT a' :& ToMaybeT b') -> SqlExpr (Value Bool))) => a -> rhs -> From (ToMaybeT a' :& ToMaybeT b')
+ Database.Esqueleto.Experimental: innerJoin :: (ToFrom a a', ToFrom b b', HasOnClause rhs (a' :& b'), rhs ~ (b, (a' :& b') -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& b')
+ Database.Esqueleto.Experimental: innerJoinLateral :: (ToFrom a a', HasOnClause rhs (a' :& b), SqlSelect b r, ToAlias b, ToAliasReference b, rhs ~ (a' -> SqlQuery b, (a' :& b) -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& b)
+ Database.Esqueleto.Experimental: leftJoin :: (ToFrom a a', ToFrom b b', ToMaybe b', HasOnClause rhs (a' :& ToMaybeT b'), rhs ~ (b, (a' :& ToMaybeT b') -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& ToMaybeT b')
+ Database.Esqueleto.Experimental: leftJoinLateral :: (ToFrom a a', SqlSelect b r, HasOnClause rhs (a' :& ToMaybeT b), ToAlias b, ToAliasReference b, ToMaybe b, rhs ~ (a' -> SqlQuery b, (a' :& ToMaybeT b) -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& ToMaybeT b)
+ Database.Esqueleto.Experimental: newtype From a
+ Database.Esqueleto.Experimental: newtype SubQuery a
+ Database.Esqueleto.Experimental: rightJoin :: (ToFrom a a', ToFrom b b', ToMaybe a', HasOnClause rhs (ToMaybeT a' :& b'), rhs ~ (b, (ToMaybeT a' :& b') -> SqlExpr (Value Bool))) => a -> rhs -> From (ToMaybeT a' :& b')
+ Database.Esqueleto.Experimental: selectQuery :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a
+ Database.Esqueleto.Experimental: table :: forall ent. PersistEntity ent => From (SqlExpr (Entity ent))
+ Database.Esqueleto.Experimental: toSqlSetOperation :: ToSqlSetOperation a r => a -> SqlSetOperation r
+ Database.Esqueleto.Experimental.From: From :: SqlQuery (a, RawFn) -> From a
+ Database.Esqueleto.Experimental.From: SubQuery :: a -> SubQuery a
+ Database.Esqueleto.Experimental.From: Table :: Table a
+ Database.Esqueleto.Experimental.From: [unFrom] :: From a -> SqlQuery (a, RawFn)
+ Database.Esqueleto.Experimental.From: class ToFrom a r | a -> r
+ Database.Esqueleto.Experimental.From: data Table a
+ Database.Esqueleto.Experimental.From: from :: ToFrom a a' => a -> SqlQuery a'
+ Database.Esqueleto.Experimental.From: instance (Database.Esqueleto.Internal.Internal.SqlSelect a r, Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Experimental.From.SubQuery (Database.Esqueleto.Internal.Internal.SqlQuery a)) a
+ Database.Esqueleto.Experimental.From: instance (Database.Esqueleto.Internal.Internal.SqlSelect a r, Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Internal.Internal.SqlQuery a) a
+ Database.Esqueleto.Experimental.From: instance Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Experimental.From.From a) a
+ Database.Esqueleto.Experimental.From: instance Database.Persist.Class.PersistEntity.PersistEntity ent => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Experimental.From.Table ent) (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity ent))
+ Database.Esqueleto.Experimental.From: newtype From a
+ Database.Esqueleto.Experimental.From: newtype SubQuery a
+ Database.Esqueleto.Experimental.From: selectQuery :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a
+ Database.Esqueleto.Experimental.From: table :: forall ent. PersistEntity ent => From (SqlExpr (Entity ent))
+ Database.Esqueleto.Experimental.From: toFrom :: ToFrom a r => a -> From r
+ Database.Esqueleto.Experimental.From: type RawFn = NeedParens -> IdentInfo -> (Builder, [PersistValue])
+ Database.Esqueleto.Experimental.From.CommonTableExpression: UnionKind :: Builder -> UnionKind
+ Database.Esqueleto.Experimental.From.CommonTableExpression: [unUnionKind] :: UnionKind -> Builder
+ Database.Esqueleto.Experimental.From.CommonTableExpression: instance Database.Esqueleto.Experimental.From.SqlSetOperation.UnionAll_ Database.Esqueleto.Experimental.From.CommonTableExpression.UnionKind
+ Database.Esqueleto.Experimental.From.CommonTableExpression: instance Database.Esqueleto.Experimental.From.SqlSetOperation.Union_ Database.Esqueleto.Experimental.From.CommonTableExpression.UnionKind
+ Database.Esqueleto.Experimental.From.CommonTableExpression: newtype UnionKind
+ Database.Esqueleto.Experimental.From.CommonTableExpression: with :: (ToAlias a, ToAliasReference a, SqlSelect a r) => SqlQuery a -> SqlQuery (From a)
+ Database.Esqueleto.Experimental.From.CommonTableExpression: withRecursive :: (ToAlias a, ToAliasReference a, SqlSelect a r) => SqlQuery a -> UnionKind -> (From a -> SqlQuery a) -> SqlQuery (From a)
+ Database.Esqueleto.Experimental.From.Join: (:&) :: a -> b -> (:&) a b
+ Database.Esqueleto.Experimental.From.Join: class DoCrossJoin lateral lhs rhs res | lateral lhs rhs -> res
+ Database.Esqueleto.Experimental.From.Join: class DoInnerJoin lateral lhs rhs res | lateral rhs lhs -> res
+ Database.Esqueleto.Experimental.From.Join: class DoLeftJoin lateral lhs rhs res | lateral rhs lhs -> res
+ Database.Esqueleto.Experimental.From.Join: class ValidOnClause a
+ Database.Esqueleto.Experimental.From.Join: crossJoin :: (ToFrom a a', ToFrom b b') => a -> b -> From (a' :& b')
+ Database.Esqueleto.Experimental.From.Join: crossJoinLateral :: (ToFrom a a', SqlSelect b r, ToAlias b, ToAliasReference b) => a -> (a' -> SqlQuery b) -> From (a' :& b)
+ Database.Esqueleto.Experimental.From.Join: data (:&) a b
+ Database.Esqueleto.Experimental.From.Join: data Lateral
+ Database.Esqueleto.Experimental.From.Join: data NotLateral
+ Database.Esqueleto.Experimental.From.Join: doCrossJoin :: DoCrossJoin lateral lhs rhs res => Proxy lateral -> lhs -> rhs -> From res
+ Database.Esqueleto.Experimental.From.Join: doInnerJoin :: DoInnerJoin lateral lhs rhs res => Proxy lateral -> lhs -> rhs -> From res
+ Database.Esqueleto.Experimental.From.Join: doLeftJoin :: DoLeftJoin lateral lhs rhs res => Proxy lateral -> lhs -> rhs -> From res
+ Database.Esqueleto.Experimental.From.Join: fromJoin :: Builder -> RawFn -> RawFn -> Maybe (SqlExpr (Value Bool)) -> RawFn
+ Database.Esqueleto.Experimental.From.Join: fullOuterJoin :: (ToFrom a a', ToFrom b b', ToMaybe a', ToMaybe b', HasOnClause rhs (ToMaybeT a' :& ToMaybeT b'), rhs ~ (b, (ToMaybeT a' :& ToMaybeT b') -> SqlExpr (Value Bool))) => a -> rhs -> From (ToMaybeT a' :& ToMaybeT b')
+ Database.Esqueleto.Experimental.From.Join: infix 9 `on`
+ Database.Esqueleto.Experimental.From.Join: infixl 2 `fullOuterJoin`
+ Database.Esqueleto.Experimental.From.Join: innerJoin :: (ToFrom a a', ToFrom b b', HasOnClause rhs (a' :& b'), rhs ~ (b, (a' :& b') -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& b')
+ Database.Esqueleto.Experimental.From.Join: innerJoinLateral :: (ToFrom a a', HasOnClause rhs (a' :& b), SqlSelect b r, ToAlias b, ToAliasReference b, rhs ~ (a' -> SqlQuery b, (a' :& b) -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& b)
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.Join.DoCrossJoin lateral lhs rhs r, Database.Esqueleto.Experimental.From.Join.IsLateral rhs GHC.Types.~ lateral) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Internal.Internal.CrossJoin lhs rhs) r
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.Join.DoInnerJoin lateral lhs rhs r, lateral GHC.Types.~ Database.Esqueleto.Experimental.From.Join.IsLateral rhs) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Internal.Internal.InnerJoin lhs rhs) r
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.Join.DoLeftJoin lateral lhs rhs r, lateral GHC.Types.~ Database.Esqueleto.Experimental.From.Join.IsLateral rhs) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Internal.Internal.LeftOuterJoin lhs rhs) r
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Experimental.From.ToFrom b b') => Database.Esqueleto.Experimental.From.Join.DoCrossJoin Database.Esqueleto.Experimental.From.Join.NotLateral a b (a' Database.Esqueleto.Experimental.From.Join.:& b')
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Experimental.From.ToFrom b b', Database.Esqueleto.Experimental.From.Join.HasOnClause rhs (a' Database.Esqueleto.Experimental.From.Join.:& b'), rhs GHC.Types.~ (b, (a' Database.Esqueleto.Experimental.From.Join.:& b') -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool))) => Database.Esqueleto.Experimental.From.Join.DoInnerJoin Database.Esqueleto.Experimental.From.Join.NotLateral a rhs (a' Database.Esqueleto.Experimental.From.Join.:& b')
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Experimental.From.ToFrom b b', Database.Esqueleto.Experimental.ToMaybe.ToMaybe a', Database.Esqueleto.Experimental.ToMaybe.ToMaybeT a' GHC.Types.~ ma, Database.Esqueleto.Experimental.From.Join.HasOnClause rhs (ma Database.Esqueleto.Experimental.From.Join.:& b'), Database.Esqueleto.Experimental.From.Join.ErrorOnLateral b, rhs GHC.Types.~ (b, (ma Database.Esqueleto.Experimental.From.Join.:& b') -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool))) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Internal.Internal.RightOuterJoin a rhs) (ma Database.Esqueleto.Experimental.From.Join.:& b')
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Experimental.From.ToFrom b b', Database.Esqueleto.Experimental.ToMaybe.ToMaybe a', Database.Esqueleto.Experimental.ToMaybe.ToMaybeT a' GHC.Types.~ ma, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b', Database.Esqueleto.Experimental.ToMaybe.ToMaybeT b' GHC.Types.~ mb, Database.Esqueleto.Experimental.From.Join.HasOnClause rhs (ma Database.Esqueleto.Experimental.From.Join.:& mb), Database.Esqueleto.Experimental.From.Join.ErrorOnLateral b, rhs GHC.Types.~ (b, (ma Database.Esqueleto.Experimental.From.Join.:& mb) -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool))) => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Internal.Internal.FullOuterJoin a rhs) (ma Database.Esqueleto.Experimental.From.Join.:& mb)
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Experimental.From.ToFrom b b', Database.Esqueleto.Experimental.ToMaybe.ToMaybe b', Database.Esqueleto.Experimental.ToMaybe.ToMaybeT b' GHC.Types.~ mb, Database.Esqueleto.Experimental.From.Join.HasOnClause rhs (a' Database.Esqueleto.Experimental.From.Join.:& mb), rhs GHC.Types.~ (b, (a' Database.Esqueleto.Experimental.From.Join.:& mb) -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool))) => Database.Esqueleto.Experimental.From.Join.DoLeftJoin Database.Esqueleto.Experimental.From.Join.NotLateral a rhs (a' Database.Esqueleto.Experimental.From.Join.:& mb)
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, d GHC.Types.~ (a' Database.Esqueleto.Experimental.From.Join.:& Database.Esqueleto.Experimental.ToMaybe.ToMaybeT b), Database.Esqueleto.Internal.Internal.SqlSelect b r, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b) => Database.Esqueleto.Experimental.From.Join.DoLeftJoin Database.Esqueleto.Experimental.From.Join.Lateral a (a' -> Database.Esqueleto.Internal.Internal.SqlQuery b, d -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool)) d
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Internal.Internal.SqlSelect b r, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b) => Database.Esqueleto.Experimental.From.Join.DoCrossJoin Database.Esqueleto.Experimental.From.Join.Lateral a (a' -> Database.Esqueleto.Internal.Internal.SqlQuery b) (a' Database.Esqueleto.Experimental.From.Join.:& b)
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.From.ToFrom a a', Database.Esqueleto.Internal.Internal.SqlSelect b r, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, d GHC.Types.~ (a' Database.Esqueleto.Experimental.From.Join.:& b)) => Database.Esqueleto.Experimental.From.Join.DoInnerJoin Database.Esqueleto.Experimental.From.Join.Lateral a (a' -> Database.Esqueleto.Internal.Internal.SqlQuery b, d -> Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value GHC.Types.Bool)) d
+ Database.Esqueleto.Experimental.From.Join: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a Database.Esqueleto.Experimental.From.Join.:& b)
+ Database.Esqueleto.Experimental.From.Join: instance Database.Esqueleto.Experimental.From.Join.ValidOnClause (a -> Database.Esqueleto.Internal.Internal.SqlQuery b)
+ Database.Esqueleto.Experimental.From.Join: instance Database.Esqueleto.Experimental.From.ToFrom a a' => Database.Esqueleto.Experimental.From.Join.ValidOnClause a
+ Database.Esqueleto.Experimental.From.Join: leftJoin :: (ToFrom a a', ToFrom b b', ToMaybe b', HasOnClause rhs (a' :& ToMaybeT b'), rhs ~ (b, (a' :& ToMaybeT b') -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& ToMaybeT b')
+ Database.Esqueleto.Experimental.From.Join: leftJoinLateral :: (ToFrom a a', SqlSelect b r, HasOnClause rhs (a' :& ToMaybeT b), ToAlias b, ToAliasReference b, ToMaybe b, rhs ~ (a' -> SqlQuery b, (a' :& ToMaybeT b) -> SqlExpr (Value Bool))) => a -> rhs -> From (a' :& ToMaybeT b)
+ Database.Esqueleto.Experimental.From.Join: on :: ValidOnClause a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool))
+ Database.Esqueleto.Experimental.From.Join: rightJoin :: (ToFrom a a', ToFrom b b', ToMaybe a', HasOnClause rhs (ToMaybeT a' :& b'), rhs ~ (b, (ToMaybeT a' :& b') -> SqlExpr (Value Bool))) => a -> rhs -> From (ToMaybeT a' :& b')
+ Database.Esqueleto.Experimental.From.Join: type family IsLateral a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: Except :: a -> b -> Except a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: Intersect :: a -> b -> Intersect a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: SqlSetOperation :: (NeedParens -> SqlQuery (a, IdentInfo -> (Builder, [PersistValue]))) -> SqlSetOperation a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: Union :: a -> b -> Union a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: UnionAll :: a -> b -> UnionAll a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: [unSqlSetOperation] :: SqlSetOperation a -> NeedParens -> SqlQuery (a, IdentInfo -> (Builder, [PersistValue]))
+ Database.Esqueleto.Experimental.From.SqlSetOperation: class ToSqlSetOperation a r | a -> r
+ Database.Esqueleto.Experimental.From.SqlSetOperation: class UnionAll_ a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: class Union_ a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: data Except a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: data Intersect a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: data Union a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: data UnionAll a b
+ Database.Esqueleto.Experimental.From.SqlSetOperation: except_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance (Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation a c, Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation b c, res GHC.Types.~ Database.Esqueleto.Experimental.From.SqlSetOperation.SqlSetOperation c) => Database.Esqueleto.Experimental.From.SqlSetOperation.UnionAll_ (a -> b -> res)
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance (Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation a c, Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation b c, res GHC.Types.~ Database.Esqueleto.Experimental.From.SqlSetOperation.SqlSetOperation c) => Database.Esqueleto.Experimental.From.SqlSetOperation.Union_ (a -> b -> res)
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance (Database.Esqueleto.Internal.Internal.SqlSelect a r, Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a) => Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation (Database.Esqueleto.Internal.Internal.SqlQuery a) a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation (Database.Esqueleto.Experimental.From.SqlSetOperation.SqlSetOperation a) a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation a a' => Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation (Database.Esqueleto.Experimental.From.SqlSetOperation.Except a a) a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation a a' => Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation (Database.Esqueleto.Experimental.From.SqlSetOperation.Intersect a a) a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation a a' => Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation (Database.Esqueleto.Experimental.From.SqlSetOperation.Union a a) a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation a a' => Database.Esqueleto.Experimental.From.SqlSetOperation.ToSqlSetOperation (Database.Esqueleto.Experimental.From.SqlSetOperation.UnionAll a a) a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: instance Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a => Database.Esqueleto.Experimental.From.ToFrom (Database.Esqueleto.Experimental.From.SqlSetOperation.SqlSetOperation a) a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: intersect_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: mkSetOperation :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => Builder -> a -> b -> SqlSetOperation a'
+ Database.Esqueleto.Experimental.From.SqlSetOperation: newtype SqlSetOperation a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: pattern SelectQuery :: p -> p
+ Database.Esqueleto.Experimental.From.SqlSetOperation: toSqlSetOperation :: ToSqlSetOperation a r => a -> SqlSetOperation r
+ Database.Esqueleto.Experimental.From.SqlSetOperation: unionAll_ :: UnionAll_ a => a
+ Database.Esqueleto.Experimental.From.SqlSetOperation: union_ :: Union_ a => a
+ Database.Esqueleto.Experimental.ToAlias: class ToAlias a
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b)
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAlias.ToAlias c) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b, c)
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAlias.ToAlias c, Database.Esqueleto.Experimental.ToAlias.ToAlias d) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b, c, d)
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAlias.ToAlias c, Database.Esqueleto.Experimental.ToAlias.ToAlias d, Database.Esqueleto.Experimental.ToAlias.ToAlias e) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b, c, d, e)
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAlias.ToAlias c, Database.Esqueleto.Experimental.ToAlias.ToAlias d, Database.Esqueleto.Experimental.ToAlias.ToAlias e, Database.Esqueleto.Experimental.ToAlias.ToAlias f) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b, c, d, e, f)
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAlias.ToAlias c, Database.Esqueleto.Experimental.ToAlias.ToAlias d, Database.Esqueleto.Experimental.ToAlias.ToAlias e, Database.Esqueleto.Experimental.ToAlias.ToAlias f, Database.Esqueleto.Experimental.ToAlias.ToAlias g) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b, c, d, e, f, g)
+ Database.Esqueleto.Experimental.ToAlias: instance (Database.Esqueleto.Experimental.ToAlias.ToAlias a, Database.Esqueleto.Experimental.ToAlias.ToAlias b, Database.Esqueleto.Experimental.ToAlias.ToAlias c, Database.Esqueleto.Experimental.ToAlias.ToAlias d, Database.Esqueleto.Experimental.ToAlias.ToAlias e, Database.Esqueleto.Experimental.ToAlias.ToAlias f, Database.Esqueleto.Experimental.ToAlias.ToAlias g, Database.Esqueleto.Experimental.ToAlias.ToAlias h) => Database.Esqueleto.Experimental.ToAlias.ToAlias (a, b, c, d, e, f, g, h)
+ Database.Esqueleto.Experimental.ToAlias: instance Database.Esqueleto.Experimental.ToAlias.ToAlias (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value a))
+ Database.Esqueleto.Experimental.ToAlias: instance Database.Esqueleto.Experimental.ToAlias.ToAlias (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity a))
+ Database.Esqueleto.Experimental.ToAlias: instance Database.Esqueleto.Experimental.ToAlias.ToAlias (Database.Esqueleto.Internal.Internal.SqlExpr (GHC.Maybe.Maybe (Database.Persist.Class.PersistEntity.Entity a)))
+ Database.Esqueleto.Experimental.ToAlias: toAlias :: ToAlias a => a -> SqlQuery a
+ Database.Esqueleto.Experimental.ToAlias: type ToAliasT a = a
+ Database.Esqueleto.Experimental.ToAliasReference: class ToAliasReference a
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b)
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference c) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b, c)
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference d) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b, c, d)
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference e) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b, c, d, e)
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference e, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference f) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b, c, d, e, f)
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference e, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference f, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference g) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b, c, d, e, f, g)
+ Database.Esqueleto.Experimental.ToAliasReference: instance (Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference a, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference b, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference c, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference d, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference e, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference f, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference g, Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference h) => Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (a, b, c, d, e, f, g, h)
+ Database.Esqueleto.Experimental.ToAliasReference: instance Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value a))
+ Database.Esqueleto.Experimental.ToAliasReference: instance Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity a))
+ Database.Esqueleto.Experimental.ToAliasReference: instance Database.Esqueleto.Experimental.ToAliasReference.ToAliasReference (Database.Esqueleto.Internal.Internal.SqlExpr (GHC.Maybe.Maybe (Database.Persist.Class.PersistEntity.Entity a)))
+ Database.Esqueleto.Experimental.ToAliasReference: toAliasReference :: ToAliasReference a => Ident -> a -> SqlQuery a
+ Database.Esqueleto.Experimental.ToAliasReference: type ToAliasReferenceT a = a
+ Database.Esqueleto.Experimental.ToMaybe: class ToMaybe a where {
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b)
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe.ToMaybe c) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b, c)
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe.ToMaybe d) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b, c, d)
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe.ToMaybe e) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b, c, d, e)
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe.ToMaybe e, Database.Esqueleto.Experimental.ToMaybe.ToMaybe f) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b, c, d, e, f)
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe.ToMaybe e, Database.Esqueleto.Experimental.ToMaybe.ToMaybe f, Database.Esqueleto.Experimental.ToMaybe.ToMaybe g) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b, c, d, e, f, g)
+ Database.Esqueleto.Experimental.ToMaybe: instance (Database.Esqueleto.Experimental.ToMaybe.ToMaybe a, Database.Esqueleto.Experimental.ToMaybe.ToMaybe b, Database.Esqueleto.Experimental.ToMaybe.ToMaybe c, Database.Esqueleto.Experimental.ToMaybe.ToMaybe d, Database.Esqueleto.Experimental.ToMaybe.ToMaybe e, Database.Esqueleto.Experimental.ToMaybe.ToMaybe f, Database.Esqueleto.Experimental.ToMaybe.ToMaybe g, Database.Esqueleto.Experimental.ToMaybe.ToMaybe h) => Database.Esqueleto.Experimental.ToMaybe.ToMaybe (a, b, c, d, e, f, g, h)
+ Database.Esqueleto.Experimental.ToMaybe: instance Database.Esqueleto.Experimental.ToMaybe.ToMaybe (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Value a))
+ Database.Esqueleto.Experimental.ToMaybe: instance Database.Esqueleto.Experimental.ToMaybe.ToMaybe (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Persist.Class.PersistEntity.Entity a))
+ Database.Esqueleto.Experimental.ToMaybe: instance Database.Esqueleto.Experimental.ToMaybe.ToMaybe (Database.Esqueleto.Internal.Internal.SqlExpr (GHC.Maybe.Maybe a))
+ Database.Esqueleto.Experimental.ToMaybe: toMaybe :: ToMaybe a => a -> ToMaybeT a
+ Database.Esqueleto.Experimental.ToMaybe: type family ToMaybeT a;
+ Database.Esqueleto.Experimental.ToMaybe: }
+ Database.Esqueleto.Internal.Internal: ERaw :: SqlExprMeta -> (NeedParens -> IdentInfo -> (Builder, [PersistValue])) -> SqlExpr a
+ Database.Esqueleto.Internal.Internal: FromRaw :: (NeedParens -> IdentInfo -> (Builder, [PersistValue])) -> FromClause
+ Database.Esqueleto.Internal.Internal: PreprocessedFrom :: a -> FromClause -> PreprocessedFrom a
+ Database.Esqueleto.Internal.Internal: SqlExprMeta :: Maybe (IdentInfo -> [Builder]) -> Maybe Ident -> Bool -> SqlExprMeta
+ Database.Esqueleto.Internal.Internal: [sqlExprMetaAlias] :: SqlExprMeta -> Maybe Ident
+ Database.Esqueleto.Internal.Internal: [sqlExprMetaCompositeFields] :: SqlExprMeta -> Maybe (IdentInfo -> [Builder])
+ Database.Esqueleto.Internal.Internal: [sqlExprMetaIsReference] :: SqlExprMeta -> Bool
+ Database.Esqueleto.Internal.Internal: data SqlExprMeta
+ Database.Esqueleto.Internal.Internal: hasCompositeKeyMeta :: SqlExprMeta -> Bool
+ Database.Esqueleto.Internal.Internal: instance Database.Persist.Class.PersistEntity.PersistEntity e => Database.Esqueleto.Internal.Internal.SqlSelect (Database.Esqueleto.Internal.Internal.SqlExpr (Database.Esqueleto.Internal.Internal.Insertion e)) (Database.Esqueleto.Internal.Internal.Insertion e)
+ Database.Esqueleto.Internal.Internal: noMeta :: SqlExprMeta
+ Database.Esqueleto.Internal.Internal: orderByExpr :: Builder -> SqlExpr (Value a) -> SqlExpr OrderBy
+ Database.Esqueleto.Internal.Internal: unsafeSqlEntity :: PersistEntity ent => Ident -> SqlExpr (Entity ent)
+ Database.Esqueleto.Legacy: (!=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (%) :: SqlString s => SqlExpr (Value s)
+ Database.Esqueleto.Legacy: (&&.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (*.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
+ Database.Esqueleto.Legacy: (++.) :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: (+.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
+ Database.Esqueleto.Legacy: (-.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
+ Database.Esqueleto.Legacy: (/.) :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value a) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
+ Database.Esqueleto.Legacy: (<#) :: (a -> b) -> SqlExpr (Value a) -> SqlExpr (Insertion b)
+ Database.Esqueleto.Legacy: (<&>) :: SqlExpr (Insertion (a -> b)) -> SqlExpr (Value a) -> SqlExpr (Insertion b)
+ Database.Esqueleto.Legacy: (<.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (<=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Entity val) -> SqlExpr Update
+ Database.Esqueleto.Legacy: (==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (>.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (>=.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: (?.) :: (PersistEntity val, PersistField typ) => SqlExpr (Maybe (Entity val)) -> EntityField val typ -> SqlExpr (Value (Maybe typ))
+ Database.Esqueleto.Legacy: (^.) :: forall typ val. (PersistEntity val, PersistField typ) => SqlExpr (Entity val) -> EntityField val typ -> SqlExpr (Value typ)
+ Database.Esqueleto.Legacy: (||.) :: SqlExpr (Value Bool) -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: --
+ Database.Esqueleto.Legacy: -- <a>EntityField</a> values polymorphically. See the documentation on
+ Database.Esqueleto.Legacy: -- <a>SymbolToField</a> for more information.
+ Database.Esqueleto.Legacy: -- <tt>OverloadedLabels</tt> language extension to refer to
+ Database.Esqueleto.Legacy: -- As of <tt>persistent-2.11.0.0</tt>, it's possible to use the
+ Database.Esqueleto.Legacy: -- belongs to and the additional type of that field.
+ Database.Esqueleto.Legacy: -- can specify a Primary key made up of unique values.
+ Database.Esqueleto.Legacy: -- | Unique keys besides the <a>Key</a>.
+ Database.Esqueleto.Legacy: Active :: Checkmark
+ Database.Esqueleto.Legacy: Add :: PersistUpdate
+ Database.Esqueleto.Legacy: Assign :: PersistUpdate
+ Database.Esqueleto.Legacy: BackendSpecificUpdate :: Text -> PersistUpdate
+ Database.Esqueleto.Legacy: ByMaybeAttr :: WhyNullable
+ Database.Esqueleto.Legacy: ByNullableAttr :: WhyNullable
+ Database.Esqueleto.Legacy: Column :: !FieldNameDB -> !Bool -> !SqlType -> !Maybe Text -> !Maybe Text -> !Maybe ConstraintNameDB -> !Maybe Integer -> !Maybe ColumnReference -> Column
+ Database.Esqueleto.Legacy: CompositeDef :: !NonEmpty FieldDef -> ![Attr] -> CompositeDef
+ Database.Esqueleto.Legacy: CompositeRef :: CompositeDef -> ReferenceDef
+ Database.Esqueleto.Legacy: Couldn'tGetSQLConnection :: PersistentSqlException
+ Database.Esqueleto.Legacy: CrossJoin :: a -> b -> CrossJoin a b
+ Database.Esqueleto.Legacy: CrossJoinKind :: JoinKind
+ Database.Esqueleto.Legacy: Divide :: PersistUpdate
+ Database.Esqueleto.Legacy: EmbedEntityDef :: EntityNameHS -> [EmbedFieldDef] -> EmbedEntityDef
+ Database.Esqueleto.Legacy: EmbedFieldDef :: FieldNameDB -> Maybe (Either SelfEmbed EntityNameHS) -> EmbedFieldDef
+ Database.Esqueleto.Legacy: EmbedRef :: EntityNameHS -> ReferenceDef
+ Database.Esqueleto.Legacy: Entity :: Key record -> record -> Entity record
+ Database.Esqueleto.Legacy: EntityIdField :: !FieldDef -> EntityIdDef
+ Database.Esqueleto.Legacy: EntityIdNaturalKey :: !CompositeDef -> EntityIdDef
+ Database.Esqueleto.Legacy: Eq :: PersistFilter
+ Database.Esqueleto.Legacy: FTApp :: FieldType -> FieldType -> FieldType
+ Database.Esqueleto.Legacy: FTList :: FieldType -> FieldType
+ Database.Esqueleto.Legacy: FTTypeCon :: Maybe Text -> Text -> FieldType
+ Database.Esqueleto.Legacy: FTTypePromoted :: Text -> FieldType
+ Database.Esqueleto.Legacy: FieldDef :: !FieldNameHS -> !FieldNameDB -> !FieldType -> !SqlType -> ![FieldAttr] -> !Bool -> !ReferenceDef -> !FieldCascade -> !Maybe Text -> !Maybe Text -> !Bool -> FieldDef
+ Database.Esqueleto.Legacy: ForShare :: LockingKind
+ Database.Esqueleto.Legacy: ForUpdate :: LockingKind
+ Database.Esqueleto.Legacy: ForUpdateSkipLocked :: LockingKind
+ Database.Esqueleto.Legacy: ForeignDef :: !EntityNameHS -> !EntityNameDB -> !ConstraintNameHS -> !ConstraintNameDB -> !FieldCascade -> ![(ForeignFieldDef, ForeignFieldDef)] -> ![Attr] -> Bool -> Bool -> ForeignDef
+ Database.Esqueleto.Legacy: ForeignRef :: !EntityNameHS -> ReferenceDef
+ Database.Esqueleto.Legacy: FullOuterJoin :: a -> b -> FullOuterJoin a b
+ Database.Esqueleto.Legacy: FullOuterJoinKind :: JoinKind
+ Database.Esqueleto.Legacy: Ge :: PersistFilter
+ Database.Esqueleto.Legacy: Gt :: PersistFilter
+ Database.Esqueleto.Legacy: ISRInsertGet :: Text -> Text -> InsertSqlResult
+ Database.Esqueleto.Legacy: ISRManyKeys :: Text -> [PersistValue] -> InsertSqlResult
+ Database.Esqueleto.Legacy: ISRSingle :: Text -> InsertSqlResult
+ Database.Esqueleto.Legacy: In :: PersistFilter
+ Database.Esqueleto.Legacy: Inactive :: Checkmark
+ Database.Esqueleto.Legacy: InnerJoin :: a -> b -> InnerJoin a b
+ Database.Esqueleto.Legacy: InnerJoinKind :: JoinKind
+ Database.Esqueleto.Legacy: KeyNotFound :: String -> UpdateException
+ Database.Esqueleto.Legacy: Le :: PersistFilter
+ Database.Esqueleto.Legacy: LeftOuterJoin :: a -> b -> LeftOuterJoin a b
+ Database.Esqueleto.Legacy: LeftOuterJoinKind :: JoinKind
+ Database.Esqueleto.Legacy: LockInShareMode :: LockingKind
+ Database.Esqueleto.Legacy: Lt :: PersistFilter
+ Database.Esqueleto.Legacy: Multiply :: PersistUpdate
+ Database.Esqueleto.Legacy: Ne :: PersistFilter
+ Database.Esqueleto.Legacy: NoReference :: ReferenceDef
+ Database.Esqueleto.Legacy: NotIn :: PersistFilter
+ Database.Esqueleto.Legacy: NotNullable :: IsNullable
+ Database.Esqueleto.Legacy: Nullable :: !WhyNullable -> IsNullable
+ Database.Esqueleto.Legacy: OnClauseWithoutMatchingJoinException :: String -> OnClauseWithoutMatchingJoinException
+ Database.Esqueleto.Legacy: PersistArray :: [PersistValue] -> PersistValue
+ Database.Esqueleto.Legacy: PersistBool :: Bool -> PersistValue
+ Database.Esqueleto.Legacy: PersistByteString :: ByteString -> PersistValue
+ Database.Esqueleto.Legacy: PersistDay :: Day -> PersistValue
+ Database.Esqueleto.Legacy: PersistDouble :: Double -> PersistValue
+ Database.Esqueleto.Legacy: PersistError :: Text -> PersistException
+ Database.Esqueleto.Legacy: PersistForeignConstraintUnmet :: Text -> PersistException
+ Database.Esqueleto.Legacy: PersistInt64 :: Int64 -> PersistValue
+ Database.Esqueleto.Legacy: PersistInvalidField :: Text -> PersistException
+ Database.Esqueleto.Legacy: PersistList :: [PersistValue] -> PersistValue
+ Database.Esqueleto.Legacy: PersistLiteral_ :: LiteralType -> ByteString -> PersistValue
+ Database.Esqueleto.Legacy: PersistMap :: [(Text, PersistValue)] -> PersistValue
+ Database.Esqueleto.Legacy: PersistMarshalError :: Text -> PersistException
+ Database.Esqueleto.Legacy: PersistMongoDBError :: Text -> PersistException
+ Database.Esqueleto.Legacy: PersistMongoDBUnsupported :: Text -> PersistException
+ Database.Esqueleto.Legacy: PersistNull :: PersistValue
+ Database.Esqueleto.Legacy: PersistObjectId :: ByteString -> PersistValue
+ Database.Esqueleto.Legacy: PersistRational :: Rational -> PersistValue
+ Database.Esqueleto.Legacy: PersistText :: Text -> PersistValue
+ Database.Esqueleto.Legacy: PersistTimeOfDay :: TimeOfDay -> PersistValue
+ Database.Esqueleto.Legacy: PersistUTCTime :: UTCTime -> PersistValue
+ Database.Esqueleto.Legacy: RightOuterJoin :: a -> b -> RightOuterJoin a b
+ Database.Esqueleto.Legacy: RightOuterJoinKind :: JoinKind
+ Database.Esqueleto.Legacy: SelfReference :: ReferenceDef
+ Database.Esqueleto.Legacy: Single :: a -> Single a
+ Database.Esqueleto.Legacy: SomePersistField :: a -> SomePersistField
+ Database.Esqueleto.Legacy: SqlBlob :: SqlType
+ Database.Esqueleto.Legacy: SqlBool :: SqlType
+ Database.Esqueleto.Legacy: SqlDay :: SqlType
+ Database.Esqueleto.Legacy: SqlDayTime :: SqlType
+ Database.Esqueleto.Legacy: SqlInt32 :: SqlType
+ Database.Esqueleto.Legacy: SqlInt64 :: SqlType
+ Database.Esqueleto.Legacy: SqlNumeric :: Word32 -> Word32 -> SqlType
+ Database.Esqueleto.Legacy: SqlOther :: Text -> SqlType
+ Database.Esqueleto.Legacy: SqlReadBackend :: SqlBackend -> SqlReadBackend
+ Database.Esqueleto.Legacy: SqlReal :: SqlType
+ Database.Esqueleto.Legacy: SqlString :: SqlType
+ Database.Esqueleto.Legacy: SqlTime :: SqlType
+ Database.Esqueleto.Legacy: SqlWriteBackend :: SqlBackend -> SqlWriteBackend
+ Database.Esqueleto.Legacy: Statement :: IO () -> IO () -> ([PersistValue] -> IO Int64) -> (forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())) -> Statement
+ Database.Esqueleto.Legacy: StatementAlreadyFinalized :: Text -> PersistentSqlException
+ Database.Esqueleto.Legacy: Subtract :: PersistUpdate
+ Database.Esqueleto.Legacy: UniqueDef :: !ConstraintNameHS -> !ConstraintNameDB -> !NonEmpty (FieldNameHS, FieldNameDB) -> ![Attr] -> UniqueDef
+ Database.Esqueleto.Legacy: UpsertError :: String -> UpdateException
+ Database.Esqueleto.Legacy: Value :: a -> Value a
+ Database.Esqueleto.Legacy: ValueList :: a -> ValueList a
+ Database.Esqueleto.Legacy: [$sel:unSqlReadBackend:SqlReadBackend] :: SqlReadBackend -> SqlBackend
+ Database.Esqueleto.Legacy: [$sel:unSqlWriteBackend:SqlWriteBackend] :: SqlWriteBackend -> SqlBackend
+ Database.Esqueleto.Legacy: [cDefaultConstraintName] :: Column -> !Maybe ConstraintNameDB
+ Database.Esqueleto.Legacy: [cDefault] :: Column -> !Maybe Text
+ Database.Esqueleto.Legacy: [cGenerated] :: Column -> !Maybe Text
+ Database.Esqueleto.Legacy: [cMaxLen] :: Column -> !Maybe Integer
+ Database.Esqueleto.Legacy: [cName] :: Column -> !FieldNameDB
+ Database.Esqueleto.Legacy: [cNull] :: Column -> !Bool
+ Database.Esqueleto.Legacy: [cReference] :: Column -> !Maybe ColumnReference
+ Database.Esqueleto.Legacy: [cSqlType] :: Column -> !SqlType
+ Database.Esqueleto.Legacy: [compositeAttrs] :: CompositeDef -> ![Attr]
+ Database.Esqueleto.Legacy: [compositeFields] :: CompositeDef -> !NonEmpty FieldDef
+ Database.Esqueleto.Legacy: [emFieldDB] :: EmbedFieldDef -> FieldNameDB
+ Database.Esqueleto.Legacy: [emFieldEmbed] :: EmbedFieldDef -> Maybe (Either SelfEmbed EntityNameHS)
+ Database.Esqueleto.Legacy: [embeddedFields] :: EmbedEntityDef -> [EmbedFieldDef]
+ Database.Esqueleto.Legacy: [embeddedHaskell] :: EmbedEntityDef -> EntityNameHS
+ Database.Esqueleto.Legacy: [entityKey] :: Entity record -> Key record
+ Database.Esqueleto.Legacy: [entityVal] :: Entity record -> record
+ Database.Esqueleto.Legacy: [fieldAttrs] :: FieldDef -> ![FieldAttr]
+ Database.Esqueleto.Legacy: [fieldCascade] :: FieldDef -> !FieldCascade
+ Database.Esqueleto.Legacy: [fieldComments] :: FieldDef -> !Maybe Text
+ Database.Esqueleto.Legacy: [fieldDB] :: FieldDef -> !FieldNameDB
+ Database.Esqueleto.Legacy: [fieldGenerated] :: FieldDef -> !Maybe Text
+ Database.Esqueleto.Legacy: [fieldHaskell] :: FieldDef -> !FieldNameHS
+ Database.Esqueleto.Legacy: [fieldIsImplicitIdColumn] :: FieldDef -> !Bool
+ Database.Esqueleto.Legacy: [fieldReference] :: FieldDef -> !ReferenceDef
+ Database.Esqueleto.Legacy: [fieldSqlType] :: FieldDef -> !SqlType
+ Database.Esqueleto.Legacy: [fieldStrict] :: FieldDef -> !Bool
+ Database.Esqueleto.Legacy: [fieldType] :: FieldDef -> !FieldType
+ Database.Esqueleto.Legacy: [foreignAttrs] :: ForeignDef -> ![Attr]
+ Database.Esqueleto.Legacy: [foreignConstraintNameDBName] :: ForeignDef -> !ConstraintNameDB
+ Database.Esqueleto.Legacy: [foreignConstraintNameHaskell] :: ForeignDef -> !ConstraintNameHS
+ Database.Esqueleto.Legacy: [foreignFieldCascade] :: ForeignDef -> !FieldCascade
+ Database.Esqueleto.Legacy: [foreignFields] :: ForeignDef -> ![(ForeignFieldDef, ForeignFieldDef)]
+ Database.Esqueleto.Legacy: [foreignNullable] :: ForeignDef -> Bool
+ Database.Esqueleto.Legacy: [foreignRefTableDBName] :: ForeignDef -> !EntityNameDB
+ Database.Esqueleto.Legacy: [foreignRefTableHaskell] :: ForeignDef -> !EntityNameHS
+ Database.Esqueleto.Legacy: [foreignToPrimary] :: ForeignDef -> Bool
+ Database.Esqueleto.Legacy: [stmtExecute] :: Statement -> [PersistValue] -> IO Int64
+ Database.Esqueleto.Legacy: [stmtFinalize] :: Statement -> IO ()
+ Database.Esqueleto.Legacy: [stmtQuery] :: Statement -> forall (m :: Type -> Type). MonadIO m => [PersistValue] -> Acquire (ConduitM () [PersistValue] m ())
+ Database.Esqueleto.Legacy: [stmtReset] :: Statement -> IO ()
+ Database.Esqueleto.Legacy: [unSingle] :: Single a -> a
+ Database.Esqueleto.Legacy: [unValue] :: Value a -> a
+ Database.Esqueleto.Legacy: [uniqueAttrs] :: UniqueDef -> ![Attr]
+ Database.Esqueleto.Legacy: [uniqueDBName] :: UniqueDef -> !ConstraintNameDB
+ Database.Esqueleto.Legacy: [uniqueFields] :: UniqueDef -> !NonEmpty (FieldNameHS, FieldNameDB)
+ Database.Esqueleto.Legacy: [uniqueHaskell] :: UniqueDef -> !ConstraintNameHS
+ Database.Esqueleto.Legacy: applyEnv :: PersistConfig c => c -> IO c
+ Database.Esqueleto.Legacy: asc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy
+ Database.Esqueleto.Legacy: associateJoin :: forall e1 e0. Ord (Key e0) => [(Entity e0, e1)] -> Map (Key e0) (e0, [e1])
+ Database.Esqueleto.Legacy: avg_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b))
+ Database.Esqueleto.Legacy: belongsTo :: forall ent1 ent2 backend (m :: Type -> Type). (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Maybe (Key ent2)) -> ent1 -> ReaderT backend m (Maybe ent2)
+ Database.Esqueleto.Legacy: belongsToJust :: forall ent1 ent2 backend (m :: Type -> Type). (PersistStoreRead backend, PersistEntity ent1, PersistRecordBackend ent2 backend, MonadIO m) => (ent1 -> Key ent2) -> ent1 -> ReaderT backend m ent2
+ Database.Esqueleto.Legacy: between :: PersistField a => SqlExpr (Value a) -> (SqlExpr (Value a), SqlExpr (Value a)) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: case_ :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: castNum :: (Num a, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
+ Database.Esqueleto.Legacy: castNumM :: (Num a, Num b) => SqlExpr (Value (Maybe a)) -> SqlExpr (Value (Maybe b))
+ Database.Esqueleto.Legacy: castString :: (SqlString s, SqlString r) => SqlExpr (Value s) -> SqlExpr (Value r)
+ Database.Esqueleto.Legacy: ceiling_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
+ Database.Esqueleto.Legacy: checkUnique :: forall record backend (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, PersistUniqueRead backend) => record -> ReaderT backend m (Maybe (Unique record))
+ Database.Esqueleto.Legacy: class BackendCompatible sup sub
+ Database.Esqueleto.Legacy: class (PersistStoreWrite backend, PersistEntity record, BaseBackend backend ~ PersistEntityBackend record) => DeleteCascade record backend
+ Database.Esqueleto.Legacy: class From a
+ Database.Esqueleto.Legacy: class HasPersistBackend backend where {
+ Database.Esqueleto.Legacy: class HasPersistBackend backend => IsPersistBackend backend
+ Database.Esqueleto.Legacy: class PersistConfig c where {
+ Database.Esqueleto.Legacy: class PersistCore backend where {
+ Database.Esqueleto.Legacy: class (PersistField Key record, ToJSON Key record, FromJSON Key record, Show Key record, Read Key record, Eq Key record, Ord Key record) => PersistEntity record where {
+ Database.Esqueleto.Legacy: class PersistField a
+ Database.Esqueleto.Legacy: class PersistField a => PersistFieldSql a
+ Database.Esqueleto.Legacy: class (PersistCore backend, PersistStoreRead backend) => PersistQueryRead backend
+ Database.Esqueleto.Legacy: class (PersistQueryRead backend, PersistStoreWrite backend) => PersistQueryWrite backend
+ Database.Esqueleto.Legacy: class (Show BackendKey backend, Read BackendKey backend, Eq BackendKey backend, Ord BackendKey backend, PersistCore backend, PersistField BackendKey backend, ToJSON BackendKey backend, FromJSON BackendKey backend) => PersistStoreRead backend
+ Database.Esqueleto.Legacy: class (Show BackendKey backend, Read BackendKey backend, Eq BackendKey backend, Ord BackendKey backend, PersistStoreRead backend, PersistField BackendKey backend, ToJSON BackendKey backend, FromJSON BackendKey backend) => PersistStoreWrite backend
+ Database.Esqueleto.Legacy: class PersistStoreRead backend => PersistUniqueRead backend
+ Database.Esqueleto.Legacy: class (PersistUniqueRead backend, PersistStoreWrite backend) => PersistUniqueWrite backend
+ Database.Esqueleto.Legacy: class RawSql a
+ Database.Esqueleto.Legacy: class PersistField a => SqlString a
+ Database.Esqueleto.Legacy: class (PersistEntity record, PersistEntityBackend record ~ backend, PersistCore backend) => ToBackendKey backend record
+ Database.Esqueleto.Legacy: class ToBaseId ent where {
+ Database.Esqueleto.Legacy: close' :: BackendCompatible SqlBackend backend => backend -> IO ()
+ Database.Esqueleto.Legacy: coalesce :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value (Maybe a))
+ Database.Esqueleto.Legacy: coalesceDefault :: PersistField a => [SqlExpr (Value (Maybe a))] -> SqlExpr (Value a) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: concat_ :: SqlString s => [SqlExpr (Value s)] -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: count :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: countDistinct :: Num a => SqlExpr (Value typ) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: countRows :: Num a => SqlExpr (Value a)
+ Database.Esqueleto.Legacy: createPoolConfig :: PersistConfig c => c -> IO (PersistConfigPool c)
+ Database.Esqueleto.Legacy: createSqlPool :: forall backend m. (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> Int -> m (Pool backend)
+ Database.Esqueleto.Legacy: data Checkmark
+ Database.Esqueleto.Legacy: data Column
+ Database.Esqueleto.Legacy: data CompositeDef
+ Database.Esqueleto.Legacy: data CrossJoin a b
+ Database.Esqueleto.Legacy: data DistinctOn
+ Database.Esqueleto.Legacy: data EmbedEntityDef
+ Database.Esqueleto.Legacy: data EmbedFieldDef
+ Database.Esqueleto.Legacy: data Entity record
+ Database.Esqueleto.Legacy: data EntityDef
+ Database.Esqueleto.Legacy: data EntityIdDef
+ Database.Esqueleto.Legacy: data FieldDef
+ Database.Esqueleto.Legacy: data FieldType
+ Database.Esqueleto.Legacy: data ForeignDef
+ Database.Esqueleto.Legacy: data FullOuterJoin a b
+ Database.Esqueleto.Legacy: data InnerJoin a b
+ Database.Esqueleto.Legacy: data InsertSqlResult
+ Database.Esqueleto.Legacy: data IsNullable
+ Database.Esqueleto.Legacy: data JoinKind
+ Database.Esqueleto.Legacy: data LeftOuterJoin a b
+ Database.Esqueleto.Legacy: data LockingKind
+ Database.Esqueleto.Legacy: data OnClauseWithoutMatchingJoinException
+ Database.Esqueleto.Legacy: data OrderBy
+ Database.Esqueleto.Legacy: data PersistException
+ Database.Esqueleto.Legacy: data PersistFilter
+ Database.Esqueleto.Legacy: data PersistUpdate
+ Database.Esqueleto.Legacy: data PersistValue
+ Database.Esqueleto.Legacy: data PersistentSqlException
+ Database.Esqueleto.Legacy: data ReferenceDef
+ Database.Esqueleto.Legacy: data RightOuterJoin a b
+ Database.Esqueleto.Legacy: data SomePersistField
+ Database.Esqueleto.Legacy: data SqlBackend
+ Database.Esqueleto.Legacy: data SqlExpr a
+ Database.Esqueleto.Legacy: data SqlQuery a
+ Database.Esqueleto.Legacy: data SqlType
+ Database.Esqueleto.Legacy: data Statement
+ Database.Esqueleto.Legacy: data UniqueDef
+ Database.Esqueleto.Legacy: data UpdateException
+ Database.Esqueleto.Legacy: data WhyNullable
+ Database.Esqueleto.Legacy: data family BackendKey backend;
+ Database.Esqueleto.Legacy: decorateSQLWithLimitOffset :: Text -> (Int, Int) -> Text -> Text
+ Database.Esqueleto.Legacy: defaultAttribute :: [FieldAttr] -> Maybe Text
+ Database.Esqueleto.Legacy: delete :: MonadIO m => SqlQuery () -> SqlWriteT m ()
+ Database.Esqueleto.Legacy: deleteBy :: forall record (m :: Type -> Type). (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: deleteCascade :: forall (m :: Type -> Type). (DeleteCascade record backend, MonadIO m) => Key record -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: deleteCount :: MonadIO m => SqlQuery () -> SqlWriteT m Int64
+ Database.Esqueleto.Legacy: deleteKey :: (PersistStore backend, BaseBackend backend ~ PersistEntityBackend val, MonadIO m, PersistEntity val) => Key val -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: deleteWhere :: forall (m :: Type -> Type) record. (PersistQueryWrite backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: desc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy
+ Database.Esqueleto.Legacy: distinct :: SqlQuery a -> SqlQuery a
+ Database.Esqueleto.Legacy: distinctOn :: [SqlExpr DistinctOn] -> SqlQuery a -> SqlQuery a
+ Database.Esqueleto.Legacy: distinctOnOrderBy :: [SqlExpr OrderBy] -> SqlQuery a -> SqlQuery a
+ Database.Esqueleto.Legacy: don :: SqlExpr (Value a) -> SqlExpr DistinctOn
+ Database.Esqueleto.Legacy: else_ :: expr a -> expr a
+ Database.Esqueleto.Legacy: entityDef :: PersistEntity record => proxy record -> EntityDef
+ Database.Esqueleto.Legacy: entityIdFromJSON :: (PersistEntity record, FromJSON record) => Value -> Parser (Entity record)
+ Database.Esqueleto.Legacy: entityIdToJSON :: (PersistEntity record, ToJSON record) => Entity record -> Value
+ Database.Esqueleto.Legacy: entityPrimary :: EntityDef -> Maybe CompositeDef
+ Database.Esqueleto.Legacy: entityValues :: PersistEntity record => Entity record -> [PersistValue]
+ Database.Esqueleto.Legacy: exists :: SqlQuery () -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: fieldDBName :: PersistEntity record => EntityField record typ -> FieldNameDB
+ Database.Esqueleto.Legacy: fieldLens :: PersistEntity record => EntityField record field -> forall (f :: Type -> Type). Functor f => (field -> f field) -> Entity record -> f (Entity record)
+ Database.Esqueleto.Legacy: floor_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
+ Database.Esqueleto.Legacy: from :: From a => (a -> SqlQuery b) -> SqlQuery b
+ Database.Esqueleto.Legacy: fromBackendKey :: ToBackendKey backend record => BackendKey backend -> Key record
+ Database.Esqueleto.Legacy: fromPersistValue :: PersistField a => PersistValue -> Either Text a
+ Database.Esqueleto.Legacy: fromPersistValueJSON :: FromJSON a => PersistValue -> Either Text a
+ Database.Esqueleto.Legacy: fromPersistValues :: PersistEntity record => [PersistValue] -> Either Text record
+ Database.Esqueleto.Legacy: fromSqlKey :: ToBackendKey SqlBackend record => Key record -> Int64
+ Database.Esqueleto.Legacy: get :: forall record (m :: Type -> Type). (PersistStoreRead backend, MonadIO m, PersistRecordBackend record backend) => Key record -> ReaderT backend m (Maybe record)
+ Database.Esqueleto.Legacy: getBy :: forall record (m :: Type -> Type). (PersistUniqueRead backend, MonadIO m, PersistRecordBackend record backend) => Unique record -> ReaderT backend m (Maybe (Entity record))
+ Database.Esqueleto.Legacy: getByValue :: forall record (m :: Type -> Type) backend. (MonadIO m, PersistUniqueRead backend, PersistRecordBackend record backend, AtLeastOneUniqueKey record) => record -> ReaderT backend m (Maybe (Entity record))
+ Database.Esqueleto.Legacy: getEntity :: forall e backend (m :: Type -> Type). (PersistStoreRead backend, PersistRecordBackend e backend, MonadIO m) => Key e -> ReaderT backend m (Maybe (Entity e))
+ Database.Esqueleto.Legacy: getEntityDBName :: EntityDef -> EntityNameDB
+ Database.Esqueleto.Legacy: getEntityFields :: EntityDef -> [FieldDef]
+ Database.Esqueleto.Legacy: getEntityId :: EntityDef -> EntityIdDef
+ Database.Esqueleto.Legacy: getEntityKeyFields :: EntityDef -> NonEmpty FieldDef
+ Database.Esqueleto.Legacy: getEntityUniques :: EntityDef -> [UniqueDef]
+ Database.Esqueleto.Legacy: getFieldName :: forall record typ (m :: Type -> Type) backend. (PersistEntity record, PersistEntityBackend record ~ SqlBackend, BackendCompatible SqlBackend backend, Monad m) => EntityField record typ -> ReaderT backend m Text
+ Database.Esqueleto.Legacy: getJust :: forall record backend (m :: Type -> Type). (PersistStoreRead backend, PersistRecordBackend record backend, MonadIO m) => Key record -> ReaderT backend m record
+ Database.Esqueleto.Legacy: getJustEntity :: forall record backend (m :: Type -> Type). (PersistEntityBackend record ~ BaseBackend backend, MonadIO m, PersistEntity record, PersistStoreRead backend) => Key record -> ReaderT backend m (Entity record)
+ Database.Esqueleto.Legacy: getMany :: forall record (m :: Type -> Type). (PersistStoreRead backend, MonadIO m, PersistRecordBackend record backend) => [Key record] -> ReaderT backend m (Map (Key record) record)
+ Database.Esqueleto.Legacy: getMigration :: forall (m :: Type -> Type). (MonadIO m, HasCallStack) => Migration -> ReaderT SqlBackend m [Sql]
+ Database.Esqueleto.Legacy: getStmtConn :: SqlBackend -> Text -> IO Statement
+ Database.Esqueleto.Legacy: getTableName :: forall record (m :: Type -> Type) backend. (PersistEntity record, BackendCompatible SqlBackend backend, Monad m) => record -> ReaderT backend m Text
+ Database.Esqueleto.Legacy: groupBy :: ToSomeValues a => a -> SqlQuery ()
+ Database.Esqueleto.Legacy: having :: SqlExpr (Value Bool) -> SqlQuery ()
+ Database.Esqueleto.Legacy: ilike :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: in_ :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: infix 4 !=.
+ Database.Esqueleto.Legacy: infixl 2 `FullOuterJoin`
+ Database.Esqueleto.Legacy: infixl 6 -.
+ Database.Esqueleto.Legacy: infixl 7 *.
+ Database.Esqueleto.Legacy: infixl 9 ^.
+ Database.Esqueleto.Legacy: infixr 2 `ilike`
+ Database.Esqueleto.Legacy: infixr 3 /=.
+ Database.Esqueleto.Legacy: infixr 5 ++.
+ Database.Esqueleto.Legacy: insert :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Key record)
+ Database.Esqueleto.Legacy: insertBy :: forall record backend (m :: Type -> Type). (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend, AtLeastOneUniqueKey record) => record -> ReaderT backend m (Either (Entity record) (Key record))
+ Database.Esqueleto.Legacy: insertEntity :: forall e backend (m :: Type -> Type). (PersistStoreWrite backend, PersistRecordBackend e backend, MonadIO m) => e -> ReaderT backend m (Entity e)
+ Database.Esqueleto.Legacy: insertEntityMany :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [Entity record] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: insertKey :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: insertMany :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m [Key record]
+ Database.Esqueleto.Legacy: insertMany_ :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: insertRecord :: forall record backend (m :: Type -> Type). (PersistEntityBackend record ~ BaseBackend backend, PersistEntity record, MonadIO m, PersistStoreWrite backend) => record -> ReaderT backend m record
+ Database.Esqueleto.Legacy: insertSelect :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m ()
+ Database.Esqueleto.Legacy: insertSelectCount :: (MonadIO m, PersistEntity a) => SqlQuery (SqlExpr (Insertion a)) -> SqlWriteT m Int64
+ Database.Esqueleto.Legacy: insertUnique :: forall record (m :: Type -> Type). (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m (Maybe (Key record))
+ Database.Esqueleto.Legacy: insertUniqueEntity :: forall record backend (m :: Type -> Type). (MonadIO m, PersistRecordBackend record backend, PersistUniqueWrite backend) => record -> ReaderT backend m (Maybe (Entity record))
+ Database.Esqueleto.Legacy: insert_ :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => record -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: isNothing :: PersistField typ => SqlExpr (Value (Maybe typ)) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: joinV :: SqlExpr (Value (Maybe (Maybe typ))) -> SqlExpr (Value (Maybe typ))
+ Database.Esqueleto.Legacy: just :: SqlExpr (Value typ) -> SqlExpr (Value (Maybe typ))
+ Database.Esqueleto.Legacy: justList :: SqlExpr (ValueList typ) -> SqlExpr (ValueList (Maybe typ))
+ Database.Esqueleto.Legacy: keyAndEntityFields :: EntityDef -> NonEmpty FieldDef
+ Database.Esqueleto.Legacy: keyFromRecordM :: PersistEntity record => Maybe (record -> Key record)
+ Database.Esqueleto.Legacy: keyFromValues :: PersistEntity record => [PersistValue] -> Either Text (Key record)
+ Database.Esqueleto.Legacy: keyToValues :: PersistEntity record => Key record -> [PersistValue]
+ Database.Esqueleto.Legacy: keyValueEntityFromJSON :: (PersistEntity record, FromJSON record) => Value -> Parser (Entity record)
+ Database.Esqueleto.Legacy: keyValueEntityToJSON :: (PersistEntity record, ToJSON record) => Entity record -> Value
+ Database.Esqueleto.Legacy: left_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: length_ :: (SqlString s, Num a) => SqlExpr (Value s) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: liftPersist :: (MonadIO m, MonadReader backend m) => ReaderT backend IO b -> m b
+ Database.Esqueleto.Legacy: liftSqlPersistMPool :: forall backend m a. (MonadIO m, BackendCompatible SqlBackend backend) => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> m a
+ Database.Esqueleto.Legacy: like :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: limit :: Int64 -> SqlQuery ()
+ Database.Esqueleto.Legacy: loadConfig :: PersistConfig c => Value -> Parser c
+ Database.Esqueleto.Legacy: locking :: LockingKind -> SqlQuery ()
+ Database.Esqueleto.Legacy: lower_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: ltrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: max_ :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe a))
+ Database.Esqueleto.Legacy: migrate :: [EntityDef] -> EntityDef -> Migration
+ Database.Esqueleto.Legacy: min_ :: PersistField a => SqlExpr (Value a) -> SqlExpr (Value (Maybe a))
+ Database.Esqueleto.Legacy: mkColumns :: [EntityDef] -> EntityDef -> BackendSpecificOverrides -> ([Column], [UniqueDef], [ForeignDef])
+ Database.Esqueleto.Legacy: newtype Single a
+ Database.Esqueleto.Legacy: newtype SqlReadBackend
+ Database.Esqueleto.Legacy: newtype SqlWriteBackend
+ Database.Esqueleto.Legacy: newtype Value a
+ Database.Esqueleto.Legacy: newtype ValueList a
+ Database.Esqueleto.Legacy: notExists :: SqlQuery () -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: notIn :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: not_ :: SqlExpr (Value Bool) -> SqlExpr (Value Bool)
+ Database.Esqueleto.Legacy: nothing :: SqlExpr (Value (Maybe typ))
+ Database.Esqueleto.Legacy: offset :: Int64 -> SqlQuery ()
+ Database.Esqueleto.Legacy: on :: SqlExpr (Value Bool) -> SqlQuery ()
+ Database.Esqueleto.Legacy: onlyUnique :: forall record backend (m :: Type -> Type). (MonadIO m, PersistUniqueWrite backend, PersistRecordBackend record backend, OnlyOneUniqueKey record) => record -> ReaderT backend m (Unique record)
+ Database.Esqueleto.Legacy: orderBy :: [SqlExpr OrderBy] -> SqlQuery ()
+ Database.Esqueleto.Legacy: parseMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m (Either [Text] CautiousMigration)
+ Database.Esqueleto.Legacy: parseMigration' :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m CautiousMigration
+ Database.Esqueleto.Legacy: pattern PersistDbSpecific :: ByteString -> PersistValue
+ Database.Esqueleto.Legacy: pattern PersistLiteral :: ByteString -> PersistValue
+ Database.Esqueleto.Legacy: pattern PersistLiteralEscaped :: ByteString -> PersistValue
+ Database.Esqueleto.Legacy: persistBackend :: HasPersistBackend backend => backend -> BaseBackend backend
+ Database.Esqueleto.Legacy: persistFieldDef :: PersistEntity record => EntityField record typ -> FieldDef
+ Database.Esqueleto.Legacy: persistIdField :: PersistEntity record => EntityField record (Key record)
+ Database.Esqueleto.Legacy: persistUniqueKeys :: PersistEntity record => record -> [Unique record]
+ Database.Esqueleto.Legacy: persistUniqueToFieldNames :: PersistEntity record => Unique record -> NonEmpty (FieldNameHS, FieldNameDB)
+ Database.Esqueleto.Legacy: persistUniqueToValues :: PersistEntity record => Unique record -> [PersistValue]
+ Database.Esqueleto.Legacy: printMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m ()
+ Database.Esqueleto.Legacy: projectBackend :: BackendCompatible sup sub => sub -> sup
+ Database.Esqueleto.Legacy: putMany :: forall record (m :: Type -> Type). (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => [record] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: rand :: SqlExpr OrderBy
+ Database.Esqueleto.Legacy: random_ :: (PersistField a, Num a) => SqlExpr (Value a)
+ Database.Esqueleto.Legacy: rawExecute :: forall (m :: Type -> Type) backend. (MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: rawExecuteCount :: forall (m :: Type -> Type) backend. (MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m Int64
+ Database.Esqueleto.Legacy: rawQuery :: forall (m :: Type -> Type) env. (MonadResource m, MonadReader env m, BackendCompatible SqlBackend env) => Text -> [PersistValue] -> ConduitM () [PersistValue] m ()
+ Database.Esqueleto.Legacy: rawQueryRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) env. (MonadIO m1, MonadIO m2, BackendCompatible SqlBackend env) => Text -> [PersistValue] -> ReaderT env m1 (Acquire (ConduitM () [PersistValue] m2 ()))
+ Database.Esqueleto.Legacy: rawSql :: forall a (m :: Type -> Type) backend. (RawSql a, MonadIO m, BackendCompatible SqlBackend backend) => Text -> [PersistValue] -> ReaderT backend m [a]
+ Database.Esqueleto.Legacy: rawSqlColCountReason :: RawSql a => a -> String
+ Database.Esqueleto.Legacy: rawSqlCols :: RawSql a => (Text -> Text) -> a -> (Int, [Text])
+ Database.Esqueleto.Legacy: rawSqlProcessRow :: RawSql a => [PersistValue] -> Either Text a
+ Database.Esqueleto.Legacy: readToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlBackend m a
+ Database.Esqueleto.Legacy: readToWrite :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlReadBackend m a -> ReaderT SqlWriteBackend m a
+ Database.Esqueleto.Legacy: renderQueryDelete :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
+ Database.Esqueleto.Legacy: renderQueryInsertInto :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
+ Database.Esqueleto.Legacy: renderQuerySelect :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
+ Database.Esqueleto.Legacy: renderQueryToText :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => Mode -> SqlQuery a -> ReaderT backend m (Text, [PersistValue])
+ Database.Esqueleto.Legacy: renderQueryUpdate :: (SqlSelect a r, BackendCompatible SqlBackend backend, Monad m) => SqlQuery a -> ReaderT backend m (Text, [PersistValue])
+ Database.Esqueleto.Legacy: replace :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: replaceUnique :: forall record backend (m :: Type -> Type). (MonadIO m, Eq (Unique record), PersistRecordBackend record backend, PersistUniqueWrite backend) => Key record -> record -> ReaderT backend m (Maybe (Unique record))
+ Database.Esqueleto.Legacy: repsert :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> record -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: repsertMany :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => [(Key record, record)] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: right_ :: (SqlString s, Num a) => (SqlExpr (Value s), SqlExpr (Value a)) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: round_ :: (PersistField a, Num a, PersistField b, Num b) => SqlExpr (Value a) -> SqlExpr (Value b)
+ Database.Esqueleto.Legacy: rtrim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: runMigration :: forall (m :: Type -> Type). MonadIO m => Migration -> ReaderT SqlBackend m ()
+ Database.Esqueleto.Legacy: runMigrationSilent :: forall (m :: Type -> Type). MonadUnliftIO m => Migration -> ReaderT SqlBackend m [Text]
+ Database.Esqueleto.Legacy: runMigrationUnsafe :: forall (m :: Type -> Type). MonadIO m => Migration -> ReaderT SqlBackend m ()
+ Database.Esqueleto.Legacy: runPool :: (PersistConfig c, MonadUnliftIO m) => c -> PersistConfigBackend c m a -> PersistConfigPool c -> m a
+ Database.Esqueleto.Legacy: runSqlConn :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> backend -> m a
+ Database.Esqueleto.Legacy: runSqlPersistM :: BackendCompatible SqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> backend -> IO a
+ Database.Esqueleto.Legacy: runSqlPersistMPool :: BackendCompatible SqlBackend backend => ReaderT backend (NoLoggingT (ResourceT IO)) a -> Pool backend -> IO a
+ Database.Esqueleto.Legacy: runSqlPool :: forall backend m a. (MonadUnliftIO m, BackendCompatible SqlBackend backend) => ReaderT backend m a -> Pool backend -> m a
+ Database.Esqueleto.Legacy: select :: (SqlSelect a r, MonadIO m) => SqlQuery a -> SqlReadT m [r]
+ Database.Esqueleto.Legacy: selectFirst :: forall (m :: Type -> Type) record. (PersistQueryRead backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m (Maybe (Entity record))
+ Database.Esqueleto.Legacy: selectKeys :: forall record backend (m :: Type -> Type). (PersistQueryRead backend, MonadResource m, PersistRecordBackend record backend, MonadReader backend m) => [Filter record] -> [SelectOpt record] -> ConduitM () (Key record) m ()
+ Database.Esqueleto.Legacy: selectKeysRes :: forall (m1 :: Type -> Type) (m2 :: Type -> Type) record. (PersistQueryRead backend, MonadIO m1, MonadIO m2, PersistRecordBackend record backend) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 (Acquire (ConduitM () (Key record) m2 ()))
+ Database.Esqueleto.Legacy: selectSource :: (SqlSelect a r, BackendCompatible SqlBackend backend, IsPersistBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend, MonadResource m) => SqlQuery a -> ConduitT () r (ReaderT backend m) ()
+ Database.Esqueleto.Legacy: selectSourceRes :: forall record (m1 :: Type -> Type) (m2 :: Type -> Type). (PersistQueryRead backend, PersistRecordBackend record backend, MonadIO m1, MonadIO m2) => [Filter record] -> [SelectOpt record] -> ReaderT backend m1 (Acquire (ConduitM () (Entity record) m2 ()))
+ Database.Esqueleto.Legacy: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update] -> SqlQuery ()
+ Database.Esqueleto.Legacy: showMigration :: forall (m :: Type -> Type). (HasCallStack, MonadIO m) => Migration -> ReaderT SqlBackend m [Text]
+ Database.Esqueleto.Legacy: sqlType :: PersistFieldSql a => Proxy a -> SqlType
+ Database.Esqueleto.Legacy: subList_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)
+ Database.Esqueleto.Legacy: subSelect :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value (Maybe a))
+ Database.Esqueleto.Legacy: subSelectCount :: (Num a, PersistField a) => SqlQuery ignored -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: subSelectForeign :: (BackendCompatible SqlBackend (PersistEntityBackend val1), PersistEntity val1, PersistEntity val2, PersistField a) => SqlExpr (Entity val2) -> EntityField val2 (Key val1) -> (SqlExpr (Entity val1) -> SqlExpr (Value a)) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: subSelectList :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)
+ Database.Esqueleto.Legacy: subSelectMaybe :: PersistField a => SqlQuery (SqlExpr (Value (Maybe a))) -> SqlExpr (Value (Maybe a))
+ Database.Esqueleto.Legacy: subSelectUnsafe :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: sub_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)
+ Database.Esqueleto.Legacy: sum_ :: (PersistField a, PersistField b) => SqlExpr (Value a) -> SqlExpr (Value (Maybe b))
+ Database.Esqueleto.Legacy: tableDBName :: PersistEntity record => record -> EntityNameDB
+ Database.Esqueleto.Legacy: then_ :: ()
+ Database.Esqueleto.Legacy: toBackendKey :: ToBackendKey backend record => Key record -> BackendKey backend
+ Database.Esqueleto.Legacy: toBaseId :: ToBaseId ent => SqlExpr (Value (Key ent)) -> SqlExpr (Value (Key (BaseEnt ent)))
+ Database.Esqueleto.Legacy: toBaseIdWitness :: ToBaseId ent => Key (BaseEnt ent) -> Key ent
+ Database.Esqueleto.Legacy: toJsonText :: ToJSON j => j -> Text
+ Database.Esqueleto.Legacy: toPersistFields :: PersistEntity record => record -> [SomePersistField]
+ Database.Esqueleto.Legacy: toPersistValue :: PersistField a => a -> PersistValue
+ Database.Esqueleto.Legacy: toPersistValueJSON :: ToJSON a => a -> PersistValue
+ Database.Esqueleto.Legacy: toSqlKey :: ToBackendKey SqlBackend record => Int64 -> Key record
+ Database.Esqueleto.Legacy: transactionSave :: forall (m :: Type -> Type). MonadIO m => ReaderT SqlBackend m ()
+ Database.Esqueleto.Legacy: transactionUndo :: forall (m :: Type -> Type). MonadIO m => ReaderT SqlBackend m ()
+ Database.Esqueleto.Legacy: trim_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: type Attr = Text
+ Database.Esqueleto.Legacy: type CautiousMigration = [(Bool, Sql)]
+ Database.Esqueleto.Legacy: type ConnectionPool = Pool SqlBackend
+ Database.Esqueleto.Legacy: type ExtraLine = [Text]
+ Database.Esqueleto.Legacy: type ForeignFieldDef = (FieldNameHS, FieldNameDB)
+ Database.Esqueleto.Legacy: type IsSqlBackend backend = (IsPersistBackend backend, BaseBackend backend ~ SqlBackend)
+ Database.Esqueleto.Legacy: type LogFunc = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
+ Database.Esqueleto.Legacy: type Migration = WriterT [Text] WriterT CautiousMigration ReaderT SqlBackend IO ()
+ Database.Esqueleto.Legacy: type PersistRecordBackend record backend = (PersistEntity record, PersistEntityBackend record ~ BaseBackend backend)
+ Database.Esqueleto.Legacy: type PersistStore a = PersistStoreWrite a
+ Database.Esqueleto.Legacy: type PersistUnique a = PersistUniqueWrite a
+ Database.Esqueleto.Legacy: type SqlWriteT (m :: Type -> Type) a = forall backend. SqlBackendCanWrite backend => ReaderT backend m a
+ Database.Esqueleto.Legacy: type Sql = Text
+ Database.Esqueleto.Legacy: type SqlBackendCanRead backend = (BackendCompatible SqlBackend backend, PersistQueryRead backend, PersistStoreRead backend, PersistUniqueRead backend)
+ Database.Esqueleto.Legacy: type SqlBackendCanWrite backend = (SqlBackendCanRead backend, PersistQueryWrite backend, PersistStoreWrite backend, PersistUniqueWrite backend)
+ Database.Esqueleto.Legacy: type SqlEntity ent = (PersistEntity ent, PersistEntityBackend ent ~ SqlBackend)
+ Database.Esqueleto.Legacy: type SqlPersistM = SqlPersistT NoLoggingT ResourceT IO
+ Database.Esqueleto.Legacy: type SqlPersistT = ReaderT SqlBackend
+ Database.Esqueleto.Legacy: type family BaseBackend backend;
+ Database.Esqueleto.Legacy: update :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m ()
+ Database.Esqueleto.Legacy: updateCount :: (MonadIO m, PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val)) => (SqlExpr (Entity val) -> SqlQuery ()) -> SqlWriteT m Int64
+ Database.Esqueleto.Legacy: updateGet :: forall record (m :: Type -> Type). (PersistStoreWrite backend, MonadIO m, PersistRecordBackend record backend) => Key record -> [Update record] -> ReaderT backend m record
+ Database.Esqueleto.Legacy: updateWhere :: forall (m :: Type -> Type) record. (PersistQueryWrite backend, MonadIO m, PersistRecordBackend record backend) => [Filter record] -> [Update record] -> ReaderT backend m ()
+ Database.Esqueleto.Legacy: upper_ :: SqlString s => SqlExpr (Value s) -> SqlExpr (Value s)
+ Database.Esqueleto.Legacy: upsert :: forall record (m :: Type -> Type). (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend, OnlyOneUniqueKey record) => record -> [Update record] -> ReaderT backend m (Entity record)
+ Database.Esqueleto.Legacy: upsertBy :: forall record (m :: Type -> Type). (PersistUniqueWrite backend, MonadIO m, PersistRecordBackend record backend) => Unique record -> record -> [Update record] -> ReaderT backend m (Entity record)
+ Database.Esqueleto.Legacy: val :: PersistField typ => typ -> SqlExpr (Value typ)
+ Database.Esqueleto.Legacy: valJ :: PersistField (Key entity) => Value (Key entity) -> SqlExpr (Value (Key entity))
+ Database.Esqueleto.Legacy: valList :: PersistField typ => [typ] -> SqlExpr (ValueList typ)
+ Database.Esqueleto.Legacy: valkey :: (ToBackendKey SqlBackend entity, PersistField (Key entity)) => Int64 -> SqlExpr (Value (Key entity))
+ Database.Esqueleto.Legacy: when_ :: expr (Value Bool) -> () -> expr a -> (expr (Value Bool), expr a)
+ Database.Esqueleto.Legacy: where_ :: SqlExpr (Value Bool) -> SqlQuery ()
+ Database.Esqueleto.Legacy: withNonNull :: PersistField typ => SqlExpr (Value (Maybe typ)) -> (SqlExpr (Value typ) -> SqlQuery a) -> SqlQuery a
+ Database.Esqueleto.Legacy: withRawQuery :: forall (m :: Type -> Type) a. MonadIO m => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> ReaderT SqlBackend m a
+ Database.Esqueleto.Legacy: withSqlConn :: forall backend m a. (MonadUnliftIO m, MonadLoggerIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> (backend -> m a) -> m a
+ Database.Esqueleto.Legacy: withSqlPool :: forall backend m a. (MonadLoggerIO m, MonadUnliftIO m, BackendCompatible SqlBackend backend) => (LogFunc -> IO backend) -> Int -> (Pool backend -> m a) -> m a
+ Database.Esqueleto.Legacy: writeToUnknown :: forall (m :: Type -> Type) a. Monad m => ReaderT SqlWriteBackend m a -> ReaderT SqlBackend m a
+ Database.Esqueleto.Legacy: }
- Database.Esqueleto: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val)
+ Database.Esqueleto: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery ()
+ Database.Esqueleto: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update] -> SqlQuery ()
- Database.Esqueleto.Experimental: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Experimental: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Experimental: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Experimental: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Experimental: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Experimental: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Experimental: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Experimental: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Experimental: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val)
+ Database.Esqueleto.Experimental: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Experimental: except_ :: a -> b -> Except a b
+ Database.Esqueleto.Experimental: except_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'
- Database.Esqueleto.Experimental: from :: ToFrom a => a -> SqlQuery (ToFromT a)
+ Database.Esqueleto.Experimental: from :: ToFrom a a' => a -> SqlQuery a'
- Database.Esqueleto.Experimental: intersect_ :: a -> b -> Intersect a b
+ Database.Esqueleto.Experimental: intersect_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'
- Database.Esqueleto.Experimental: on :: ValidOnClauseValue a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool))
+ Database.Esqueleto.Experimental: on :: ValidOnClause a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool))
- Database.Esqueleto.Experimental: pattern SelectQuery :: SqlQuery a -> SqlSetOperation a
+ Database.Esqueleto.Experimental: pattern SelectQuery :: p -> p
- Database.Esqueleto.Experimental: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery ()
+ Database.Esqueleto.Experimental: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update] -> SqlQuery ()
- Database.Esqueleto.Experimental: unionAll_ :: a -> b -> UnionAll a b
+ Database.Esqueleto.Experimental: unionAll_ :: UnionAll_ a => a
- Database.Esqueleto.Experimental: union_ :: a -> b -> Union a b
+ Database.Esqueleto.Experimental: union_ :: Union_ a => a
- Database.Esqueleto.Experimental: withRecursive :: (ToAlias a, ToAliasReference a, SqlSelect a r, RecursiveCteUnion unionKind) => SqlQuery a -> unionKind -> (From a -> SqlQuery a) -> SqlQuery (From a)
+ Database.Esqueleto.Experimental: withRecursive :: (ToAlias a, ToAliasReference a, SqlSelect a r) => SqlQuery a -> UnionKind -> (From a -> SqlQuery a) -> SqlQuery (From a)
- Database.Esqueleto.Internal.Internal: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Internal.Internal: (*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Internal.Internal: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Internal.Internal: (+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Internal.Internal: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Internal.Internal: (-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Internal.Internal: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)
+ Database.Esqueleto.Internal.Internal: (/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Internal.Internal: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val)
+ Database.Esqueleto.Internal.Internal: (=.) :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Internal.Internal: SetClause :: SqlExpr (Value ()) -> SetClause
+ Database.Esqueleto.Internal.Internal: SetClause :: SqlExpr Update -> SetClause
- Database.Esqueleto.Internal.Internal: data Update typ
+ Database.Esqueleto.Internal.Internal: data Update
- Database.Esqueleto.Internal.Internal: fromFinish :: SqlExpr (PreprocessedFrom a) -> SqlQuery a
+ Database.Esqueleto.Internal.Internal: fromFinish :: PreprocessedFrom a -> SqlQuery a
- Database.Esqueleto.Internal.Internal: fromJoin :: IsJoinKind join => SqlExpr (PreprocessedFrom a) -> SqlExpr (PreprocessedFrom b) -> SqlQuery (SqlExpr (PreprocessedFrom (join a b)))
+ Database.Esqueleto.Internal.Internal: fromJoin :: IsJoinKind join => PreprocessedFrom a -> PreprocessedFrom b -> SqlQuery (PreprocessedFrom (join a b))
- Database.Esqueleto.Internal.Internal: fromPreprocess :: FromPreprocess a => SqlQuery (SqlExpr (PreprocessedFrom a))
+ Database.Esqueleto.Internal.Internal: fromPreprocess :: FromPreprocess a => SqlQuery (PreprocessedFrom a)
- Database.Esqueleto.Internal.Internal: fromStart :: forall a. (PersistEntity a, BackendCompatible SqlBackend (PersistEntityBackend a)) => SqlQuery (SqlExpr (PreprocessedFrom (SqlExpr (Entity a))))
+ Database.Esqueleto.Internal.Internal: fromStart :: forall a. (PersistEntity a, BackendCompatible SqlBackend (PersistEntityBackend a)) => SqlQuery (PreprocessedFrom (SqlExpr (Entity a)))
- Database.Esqueleto.Internal.Internal: fromStartMaybe :: (PersistEntity a, BackendCompatible SqlBackend (PersistEntityBackend a)) => SqlQuery (SqlExpr (PreprocessedFrom (SqlExpr (Maybe (Entity a)))))
+ Database.Esqueleto.Internal.Internal: fromStartMaybe :: (PersistEntity a, BackendCompatible SqlBackend (PersistEntityBackend a)) => SqlQuery (PreprocessedFrom (SqlExpr (Maybe (Entity a))))
- Database.Esqueleto.Internal.Internal: makeLimit :: IdentInfo -> LimitClause -> [OrderByClause] -> (Builder, [PersistValue])
+ Database.Esqueleto.Internal.Internal: makeLimit :: IdentInfo -> LimitClause -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Internal: renderUpdates :: BackendCompatible SqlBackend backend => backend -> [SqlExpr (Update val)] -> (Builder, [PersistValue])
+ Database.Esqueleto.Internal.Internal: renderUpdates :: BackendCompatible SqlBackend backend => backend -> [SqlExpr (Entity val) -> SqlExpr Update] -> (Builder, [PersistValue])
- Database.Esqueleto.Internal.Internal: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery ()
+ Database.Esqueleto.Internal.Internal: set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update] -> SqlQuery ()
- Database.Esqueleto.Internal.Internal: setAux :: (PersistEntity val, PersistField typ) => EntityField val typ -> (SqlExpr (Entity val) -> SqlExpr (Value typ)) -> SqlExpr (Update val)
+ Database.Esqueleto.Internal.Internal: setAux :: (PersistEntity val, PersistField typ) => EntityField val typ -> (SqlExpr (Entity val) -> SqlExpr (Value typ)) -> SqlExpr (Entity val) -> SqlExpr Update
- Database.Esqueleto.Internal.Internal: type family BaseEnt ent :: *;
+ Database.Esqueleto.Internal.Internal: type family BaseEnt ent :: Type;
- Database.Esqueleto.PostgreSQL: insertSelectWithConflict :: forall a m val. (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val) => a -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Update val)]) -> SqlWriteT m ()
+ Database.Esqueleto.PostgreSQL: insertSelectWithConflict :: forall a m val. (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val) => a -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update]) -> SqlWriteT m ()
- Database.Esqueleto.PostgreSQL: insertSelectWithConflictCount :: forall a val m. (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val) => a -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Update val)]) -> SqlWriteT m Int64
+ Database.Esqueleto.PostgreSQL: insertSelectWithConflictCount :: forall a val m. (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val) => a -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update]) -> SqlWriteT m Int64
- Database.Esqueleto.PostgreSQL: upsert :: (MonadIO m, PersistEntity record, OnlyOneUniqueKey record, PersistRecordBackend record SqlBackend, IsPersistBackend (PersistEntityBackend record)) => record -> [SqlExpr (Update record)] -> ReaderT SqlBackend m (Entity record)
+ Database.Esqueleto.PostgreSQL: upsert :: (MonadIO m, PersistEntity record, OnlyOneUniqueKey record, PersistRecordBackend record SqlBackend, IsPersistBackend (PersistEntityBackend record)) => record -> [SqlExpr (Entity record) -> SqlExpr Update] -> ReaderT SqlBackend m (Entity record)
- Database.Esqueleto.PostgreSQL: upsertBy :: (MonadIO m, PersistEntity record, IsPersistBackend (PersistEntityBackend record)) => Unique record -> record -> [SqlExpr (Update record)] -> ReaderT SqlBackend m (Entity record)
+ Database.Esqueleto.PostgreSQL: upsertBy :: (MonadIO m, PersistEntity record, IsPersistBackend (PersistEntityBackend record)) => Unique record -> record -> [SqlExpr (Entity record) -> SqlExpr Update] -> ReaderT SqlBackend m (Entity record)

Files

changelog.md view
@@ -1,9 +1,27 @@-3.4.3.0+3.5.0.0 =======+- @belevy+  - [#228](https://github.com/bitemyapp/esqueleto/pull/228)+        - Destroy all GADTs; Removes the From GADT and SqlExpr GADT+        - From GADT is replaced with a From data type and FromRaw+        - SqlExpr is now all defined in terms of ERaw+        - Modified ERaw to contain a SqlExprMeta with any extra information+          that may be needed+        - Experimental top level is now strictly for documentation and all the+          implementation details are in Experimental.* modules - @parsonsmatt-    - [#]()-        - Backport the `SqlSelect` instance for `:&`, initially implemented by-          @ivanbakel in [#268](https://github.com/bitemyapp/esqueleto/pull/268)+    - [#259](https://github.com/bitemyapp/esqueleto/pull/259)+        - Create the `Database.Esqueleto.Legacy` module. The+          `Database.Esqueleto` module now emits a warning, directing users to+          either import `Database.Esqueleto.Legacy` to keep the old behavior or+          to import `Database.Esqueleto.Experimental` to opt in to the new+          behavior.+        - Deleted the deprecated modules+          `Database.Esqueleto.Internal.{Language,Sql}`. Please use+          `Database.Esqueleto.Internal.Internal` instead, or ideally post what+          you need from the library so we can support you safely.+        - Support GHC 9+ 3.4.2.2 ======= - @parsonsmatt@@ -36,6 +54,7 @@ - @Vlix   - [#232](https://github.com/bitemyapp/esqueleto/pull/232)     - Export the `ValidOnClauseValue` type family+  3.4.0.1 =======
esqueleto.cabal view
@@ -1,7 +1,7 @@ cabal-version: 1.12  name:           esqueleto-version:        3.4.3.0+version:        3.5.0.0 synopsis:       Type-safe EDSL for SQL queries on persistent backends. description:    @esqueleto@ is a bare bones, type-safe EDSL for SQL queries that works with unmodified @persistent@ SQL backends.  Its language closely resembles SQL, so you don't have to learn new concepts, just new syntax, and it's fairly easy to predict the generated SQL and optimize it for your backend. Most kinds of errors committed when writing SQL are caught as compile-time errors---although it is possible to write type-checked @esqueleto@ queries that fail at runtime.                 .@@ -29,18 +29,24 @@ library     exposed-modules:         Database.Esqueleto+        Database.Esqueleto.Legacy         Database.Esqueleto.Experimental-        Database.Esqueleto.Internal.Language-        Database.Esqueleto.Internal.Sql         Database.Esqueleto.Internal.Internal         Database.Esqueleto.Internal.ExprParser         Database.Esqueleto.MySQL         Database.Esqueleto.PostgreSQL         Database.Esqueleto.PostgreSQL.JSON         Database.Esqueleto.SQLite+        Database.Esqueleto.Experimental.From+        Database.Esqueleto.Experimental.From.CommonTableExpression+        Database.Esqueleto.Experimental.From.Join+        Database.Esqueleto.Experimental.From.SqlSetOperation+        Database.Esqueleto.Experimental.ToAlias+        Database.Esqueleto.Experimental.ToAliasReference+        Database.Esqueleto.Experimental.ToMaybe     other-modules:-        Database.Esqueleto.Internal.PersistentImport         Database.Esqueleto.PostgreSQL.JSON.Instances+        Database.Esqueleto.Internal.PersistentImport         Paths_esqueleto     hs-source-dirs:         src/@@ -69,7 +75,6 @@         -Wpartial-fields         -Wmissing-home-modules         -Widentities-        -Wredundant-constraints         -Wcpp-undef         -Wcpp-undef         -Wmonomorphism-restriction
src/Database/Esqueleto.hs view
@@ -1,4 +1,8 @@-{-# LANGUAGE FlexibleContexts, FlexibleInstances, GADTs, RankNTypes #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE RankNTypes #-}+ -- | The @esqueleto@ EDSL (embedded domain specific language). -- This module replaces @Database.Persist@, so instead of -- importing that module you should just import this one:@@ -28,11 +32,15 @@ -- Other than identifier name clashes, @esqueleto@ does not -- conflict with @persistent@ in any way. ----- Note that the faciliites for @JOIN@ have been significantly improved in the+-- Note that the facilities for @JOIN@ have been significantly improved in the -- "Database.Esqueleto.Experimental" module. The definition of 'from' and 'on' -- in this module will be replaced with those at the 4.0.0.0 version, so you are -- encouraged to migrate to the new method.-module Database.Esqueleto+--+-- This module has an attached WARNING message indicating that the Experimental+-- syntax will become the default. If you want to continue using the old syntax,+-- please refer to "Database.Esqueleto.Legacy" as a drop-in replacement.+module Database.Esqueleto {-# WARNING "This module will switch over to the Experimental syntax in an upcoming major version release. Please migrate to the Database.Esqueleto.Legacy module to continue using the old syntax, or translate to the new and improved syntax in Database.Esqueleto.Experimental." #-}   ( -- * Setup     -- $setup @@ -120,14 +128,8 @@   , module Database.Esqueleto.Internal.PersistentImport   ) where -import Control.Monad.IO.Class (MonadIO)-import Control.Monad.Trans.Reader (ReaderT)-import Data.Int (Int64)-import qualified Data.Map.Strict as Map-import Database.Esqueleto.Internal.Language-import Database.Esqueleto.Internal.Sql+import Database.Esqueleto.Legacy import Database.Esqueleto.Internal.PersistentImport-import qualified Database.Persist   -- $setup
src/Database/Esqueleto/Experimental.hs view
@@ -1,22 +1,11 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE PatternSynonyms #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE UndecidableInstances #-}  -- | This module contains a new way (introduced in 3.3.3.0) of using @FROM@ in -- Haskell. The old method was a bit finicky and could permit runtime errors, -- and this new way is both significantly safer and much more powerful. ----- Esqueleto users are encouraged to migrate to this module, as it will become--- the default in a new major version @4.0.0.0@.+-- This syntax will become the default syntax exported from the library in+-- version @3.6.0.0@. To use the old syntax, see "Database.Esqueleto.Legacy". module Database.Esqueleto.Experimental     ( -- * Setup       -- $setup@@ -29,10 +18,24 @@        -- * Documentation -      From(..)-    , on-    , from+    -- ** Basic Queries+      from+    , table+    , Table(..)+    , SubQuery(..)+    , selectQuery++    -- ** Joins     , (:&)(..)+    , on+    , innerJoin+    , innerJoinLateral+    , leftJoin+    , leftJoinLateral+    , rightJoin+    , fullOuterJoin+    , crossJoin+    , crossJoinLateral        -- ** Set Operations       -- $sql-set-operations@@ -50,16 +53,16 @@     , with     , withRecursive -      -- * Internals-    , ToFrom(..)+      -- ** Internals+    , From(..)     , ToMaybe(..)     , ToAlias(..)     , ToAliasT     , ToAliasReference(..)     , ToAliasReferenceT-    , ValidOnClauseValue-    -- * The Normal Stuff+    , ToSqlSetOperation(..) +    -- * The Normal Stuff     , where_     , groupBy     , orderBy@@ -172,6 +175,7 @@     , DistinctOn     , LockingKind(..)     , SqlString+       -- ** Joins     , InnerJoin(..)     , CrossJoin(..)@@ -180,7 +184,8 @@     , FullOuterJoin(..)     , JoinKind(..)     , OnClauseWithoutMatchingJoinException(..)-      -- * SQL backend++      -- ** SQL backend     , SqlQuery     , SqlExpr     , SqlEntity@@ -194,41 +199,36 @@     , insertSelectCount     , (<#)     , (<&>)+     -- ** Rendering Queries     , renderQueryToText     , renderQuerySelect     , renderQueryUpdate     , renderQueryDelete     , renderQueryInsertInto-    -- * Internal.Language-    -- * RDBMS-specific modules-    -- $rdbmsSpecificModules -    -- * Helpers+    -- ** Helpers     , valkey     , valJ     , associateJoin -      -- * Re-exports+      -- ** Re-exports       -- $reexports     , deleteKey     , module Database.Esqueleto.Internal.PersistentImport     ) where -import Control.Monad.Trans.Class (lift)-import qualified Control.Monad.Trans.State as S-import qualified Control.Monad.Trans.Writer as W-#if __GLASGOW_HASKELL__ < 804-import Data.Semigroup-#endif-import Data.Kind (Constraint)-import Data.Proxy (Proxy(..))-import qualified Data.Text.Lazy.Builder as TLB import Database.Esqueleto.Internal.Internal hiding (From, from, on) import Database.Esqueleto.Internal.PersistentImport-import GHC.TypeLits-import Database.Persist (EntityNameDB(..)) +import Database.Esqueleto.Experimental.From+import Database.Esqueleto.Experimental.From.CommonTableExpression+import Database.Esqueleto.Experimental.From.Join+import Database.Esqueleto.Experimental.From.SqlSetOperation+import Database.Esqueleto.Experimental.ToAlias+import Database.Esqueleto.Experimental.ToAliasReference+import Database.Esqueleto.Experimental.ToMaybe+ -- $setup -- -- If you're already using "Database.Esqueleto", then you can get@@ -317,7 +317,7 @@ -- -- @ -- select $ do--- people <- from $ Table \@Person+-- people <- from $ table \@Person -- where_ (people ^. PersonName ==. val \"John\") -- pure people -- @@@ -345,8 +345,8 @@ -- @ -- select $ do -- (people :& blogPosts) <----     from $ Table \@Person---     \`LeftOuterJoin\` Table \@BlogPost+--     from $ table \@Person+--     \`leftJoin\` table \@BlogPost --     \`on\` (\\(people :& blogPosts) -> --             people ^. PersonId ==. blogPosts ?. BlogPostAuthorId) -- where_ (people ^. PersonAge >. val 18)@@ -377,7 +377,7 @@ -- -- In this version, with each successive 'on' clause, only the tables -- we have already joined into are in scope, so we must pattern match--- accordingly. In this case, in the second 'InnerJoin', we do not use+-- accordingly. In this case, in the second 'innerJoin', we do not use -- the first `Person` reference, so we use @_@ as a placeholder to -- ignore it. This prevents a possible runtime error where a table -- is referenced before it appears in the sequence of 'JOIN's.@@ -385,11 +385,11 @@ -- @ -- select $ do -- (people1 :& followers :& people2) <----     from $ Table \@Person---     \`InnerJoin` Table \@Follow+--     from $ table \@Person+--     \`innerJoin` table \@Follow --     \`on\` (\\(people1 :& followers) -> --             people1 ^. PersonId ==. followers ^. FollowFollowed)---     \`InnerJoin` Table \@Person+--     \`innerJoin` table \@Person --     \`on\` (\\(_ :& followers :& people2) -> --             followers ^. FollowFollower ==. people2 ^. PersonId) -- where_ (people1 ^. PersonName ==. val \"John\")@@ -421,8 +421,8 @@ -- peopleWithPosts <- --   from $ do --     (people :& blogPosts) <----       from $ Table \@Person---       \`InnerJoin\` Table \@BlogPost+--       from $ table \@Person+--       \`innerJoin\` table \@BlogPost --       \`on\` (\\(p :& bP) -> --               p ^. PersonId ==. bP ^. BlogPostAuthorId) --     groupBy (people ^. PersonId)@@ -452,8 +452,8 @@ -- (authors, blogPosts) <- from $ --   (do --     (author :& blogPost) <----       from $ Table \@Person---       \`InnerJoin\` Table \@BlogPost+--       from $ table \@Person+--       \`innerJoin\` table \@BlogPost --       \`on\` (\\(a :& bP) -> --               a ^. PersonId ==. bP ^. BlogPostAuthorId) --     where_ (author ^. PersonId ==. val currentPersonId)@@ -462,11 +462,11 @@ --   \`union_\` --   (do --     (follow :& blogPost :& author) <----       from $ Table \@Follow---       \`InnerJoin\` Table \@BlogPost+--       from $ table \@Follow+--       \`innerJoin\` table \@BlogPost --       \`on\` (\\(f :& bP) -> --               f ^. FollowFollowed ==. bP ^. BlogPostAuthorId)---       \`InnerJoin\` Table \@Person+--       \`innerJoin\` table \@Person --       \`on\` (\\(_ :& bP :& a) -> --               bP ^. BlogPostAuthorId ==. a ^. PersonId) --     where_ (follow ^. FollowFollower ==. val currentPersonId)@@ -485,14 +485,14 @@ -- @ -- select $ do -- (salesPerson :& maxSaleAmount :& maxSaleCustomerName) <----   from $ Table \@SalesPerson---   \`CrossJoin\` (\\salesPerson -> do---         sales <- from $ Table \@Sale+--   from $ table \@SalesPerson+--   \`crossJoinLateral\` (\\salesPerson -> do+--         sales <- from $ table \@Sale --         where_ $ sales ^. SaleSalesPersonId ==. salesPerson ^. SalesPersonId --         pure $ max_ (sales ^. SaleAmount) --         )---   \`CrossJoin\` (\\(salesPerson :& maxSaleAmount) -> do---         sales <- from $ Table \@Sale+--   \`crossJoinLateral\` (\\(salesPerson :& maxSaleAmount) -> do+--         sales <- from $ table \@Sale --         where_ $ sales ^. SaleSalesPersonId ==. salesPerson ^. SalesPersonId --              &&. sales ^. SaleAmount ==. maxSaleAmount --         pure $ sales ^. SaleCustomerName)@@ -527,39 +527,6 @@ --   AS max_sale_customer; -- @ --- | A left-precedence pair. Pronounced \"and\". Used to represent expressions--- that have been joined together.------ The precedence behavior can be demonstrated by:------ @--- a :& b :& c == ((a :& b) :& c)--- @------ See the examples at the beginning of this module to see how this--- operator is used in 'JOIN' operations.-data (:&) a b = a :& b-infixl 2 :&---- | You may return joined values from a 'select' query - this is--- identical to the tuple instance, but is provided for convenience.------ @since 3.4.3.0-instance (SqlSelect a ra, SqlSelect b rb) => SqlSelect (a :& b) (ra :& rb) where-    sqlSelectCols esc (a :& b) = sqlSelectCols esc (a, b)-    sqlSelectColCount = sqlSelectColCount . toTuple-      where-        toTuple :: Proxy (a :& b) -> Proxy (a, b)-        toTuple = const Proxy-    sqlSelectProcessRow = fmap (uncurry (:&)) . sqlSelectProcessRow--data SqlSetOperation a-    = SqlSetUnion (SqlSetOperation a) (SqlSetOperation a)-    | SqlSetUnionAll (SqlSetOperation a) (SqlSetOperation a)-    | SqlSetExcept (SqlSetOperation a) (SqlSetOperation a)-    | SqlSetIntersect (SqlSetOperation a) (SqlSetOperation a)-    | SelectQueryP NeedParens (SqlQuery a)- -- $sql-set-operations -- -- Data type that represents SQL set operations. This includes@@ -573,12 +540,12 @@ -- @ -- select $ from $ --   (do---      a <- from Table @A+--      a <- from $ table @A --      pure $ a ^. ASomeCol --   ) --   \`union_\` --   (do---      b <- from Table @B+--      b <- from $ table @B --      pure $ b ^. BSomeCol --   ) -- @@@ -593,846 +560,3 @@ -- ) -- @ ----{-# DEPRECATED Union "/Since: 3.4.0.0/ - Use the 'union_' function instead of the 'Union' data constructor" #-}-data Union a b = a `Union` b---- | @UNION@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.-union_ :: a -> b -> Union a b-union_ = Union--{-# DEPRECATED UnionAll "/Since: 3.4.0.0/ - Use the 'unionAll_' function instead of the 'UnionAll' data constructor" #-}-data UnionAll a b = a `UnionAll` b---- | @UNION@ @ALL@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.-unionAll_ :: a -> b -> UnionAll a b-unionAll_ = UnionAll--{-# DEPRECATED Except "/Since: 3.4.0.0/ - Use the 'except_' function instead of the 'Except' data constructor" #-}-data Except a b = a `Except` b---- | @EXCEPT@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.-except_ :: a -> b -> Except a b-except_ = Except--{-# DEPRECATED Intersect "/Since: 3.4.0.0/ - Use the 'intersect_' function instead of the 'Intersect' data constructor" #-}-data Intersect a b = a `Intersect` b---- | @INTERSECT@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.-intersect_ :: a -> b -> Intersect a b-intersect_ = Intersect--class SetOperationT a ~ b => ToSetOperation a b | a -> b where-    type SetOperationT a-    toSetOperation :: a -> SqlSetOperation b-instance ToSetOperation (SqlSetOperation a) a where-    type SetOperationT (SqlSetOperation a) = a-    toSetOperation = id-instance ToSetOperation (SqlQuery a) a where-    type SetOperationT (SqlQuery a) = a-    toSetOperation = SelectQueryP Never-instance (ToSetOperation a c, ToSetOperation b c) => ToSetOperation (Union a b) c where-    type SetOperationT (Union a b) = SetOperationT a-    toSetOperation (Union a b) = SqlSetUnion (toSetOperation a) (toSetOperation b)-instance (ToSetOperation a c, ToSetOperation b c) => ToSetOperation (UnionAll a b) c where-    type SetOperationT (UnionAll a b) = SetOperationT a-    toSetOperation (UnionAll a b) = SqlSetUnionAll (toSetOperation a) (toSetOperation b)-instance (ToSetOperation a c, ToSetOperation b c) => ToSetOperation (Except a b) c where-    type SetOperationT (Except a b) = SetOperationT a-    toSetOperation (Except a b) = SqlSetExcept (toSetOperation a) (toSetOperation b)-instance (ToSetOperation a c, ToSetOperation b c) => ToSetOperation (Intersect a b) c where-    type SetOperationT (Intersect a b) = SetOperationT a-    toSetOperation (Intersect a b) = SqlSetIntersect (toSetOperation a) (toSetOperation b)--{-# DEPRECATED SelectQuery "/Since: 3.4.0.0/ - It is no longer necessary to tag 'SqlQuery' values with @SelectQuery@" #-}-pattern SelectQuery :: SqlQuery a -> SqlSetOperation a-pattern SelectQuery q = SelectQueryP Never q---- | Data type that represents the syntax of a 'JOIN' tree. In practice,--- only the @Table@ constructor is used directly when writing queries. For example,------ @--- select $ from $ Table \@People--- @-data From a where-    Table-        :: PersistEntity ent-        => From (SqlExpr (Entity ent))-    SubQuery-        :: ( SqlSelect a r-           , ToAlias a-           , ToAliasReference a-           )-        => SqlQuery a-        -> From a-    FromCte-        :: Ident-        -> a-        -> From a-    SqlSetOperation-        :: ( SqlSelect a r-           , ToAlias a-           , ToAliasReference a-           )-        => SqlSetOperation a-        -> From a-    InnerJoinFrom-        :: From a-        -> (From b, (a :& b) -> SqlExpr (Value Bool))-        -> From (a :& b)-    InnerJoinFromLateral-        :: ( SqlSelect b r-           , ToAlias b-           , ToAliasReference b-           )-        => From a-        -> ((a -> SqlQuery b), (a :& b) -> SqlExpr (Value Bool))-        -> From (a :& b)-    CrossJoinFrom-        :: From a-        -> From b-        -> From (a :& b)-    CrossJoinFromLateral-        :: ( SqlSelect b r-           , ToAlias b-           , ToAliasReference b-           )-        => From a-        -> (a -> SqlQuery b)-        -> From (a :& b)-    LeftJoinFrom-        :: ToMaybe b-        => From a-        -> (From b, (a :& ToMaybeT b) -> SqlExpr (Value Bool))-        -> From (a :& ToMaybeT b)-    LeftJoinFromLateral-        :: ( SqlSelect b r-           , ToAlias b-           , ToAliasReference b-           , ToMaybe b-           )-        => From a-        -> ((a -> SqlQuery b), (a :& ToMaybeT b) -> SqlExpr (Value Bool))-        -> From (a :& ToMaybeT b)-    RightJoinFrom-        :: ToMaybe a-        => From a-        -> (From b, (ToMaybeT a :& b) -> SqlExpr (Value Bool))-        -> From (ToMaybeT a :& b)-    FullJoinFrom-        :: (ToMaybe a, ToMaybe b )-        => From a-        -> (From b, (ToMaybeT a :& ToMaybeT b) -> SqlExpr (Value Bool))-        -> From (ToMaybeT a :& ToMaybeT b)---- | Constraint for `on`. Ensures that only types that require an `on` can be used on--- the left hand side. This was previously reusing the ToFrom class which was actually--- a bit too lenient as it allowed to much.------ @since 3.4.0.0-type family ValidOnClauseValue a :: Constraint where-  ValidOnClauseValue (From a) = ()-  ValidOnClauseValue (SqlQuery a) = ()-  ValidOnClauseValue (SqlSetOperation a) = ()-  ValidOnClauseValue (a -> SqlQuery b) = ()-  ValidOnClauseValue _ = TypeError ('Text "Illegal use of ON")---- | An @ON@ clause that describes how two tables are related. This should be--- used as an infix operator after a 'JOIN'. For example,------ @--- select $--- from $ Table \@Person--- \`InnerJoin\` Table \@BlogPost--- \`on\` (\\(p :& bP) ->---         p ^. PersonId ==. bP ^. BlogPostAuthorId)--- @-on :: ValidOnClauseValue a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool))-on = (,)-infix 9 `on`--data Lateral-data NotLateral--type family IsLateral a where-    IsLateral (a -> SqlQuery b) = Lateral-    IsLateral a = NotLateral--type family ErrorOnLateral a :: Constraint where-  ErrorOnLateral (a -> SqlQuery b) = TypeError ('Text "LATERAL can only be used for INNER, LEFT, and CROSS join kinds.")-  ErrorOnLateral _ = ()--{-- Type class magic to allow the use of the `InnerJoin` family of data constructors in from --}-class ToFrom a where-    type ToFromT a-    toFrom :: a -> From (ToFromT a)---- @since 3.4.0.1-type family FromOnClause a where-    FromOnClause (a, b -> SqlExpr (Value Bool)) = b-    FromOnClause a = TypeError ('Text "Missing ON clause")--instance {-# OVERLAPPABLE #-} ToFrom (InnerJoin a b) where-    type ToFromT (InnerJoin a b) = FromOnClause b-    toFrom = undefined-instance {-# OVERLAPPABLE #-} ToFrom (LeftOuterJoin a b) where-    type ToFromT (LeftOuterJoin a b) = FromOnClause b-    toFrom = undefined-instance {-# OVERLAPPABLE #-} ToFrom (FullOuterJoin a b) where-    type ToFromT (FullOuterJoin a b) = FromOnClause b-    toFrom = undefined-instance {-# OVERLAPPABLE #-} ToFrom (RightOuterJoin a b) where-    type ToFromT (RightOuterJoin a b) = FromOnClause b-    toFrom = undefined--instance ToFrom (From a) where-    type ToFromT (From a) = a-    toFrom = id--instance-    ( ToAlias a-    , ToAliasReference a-    , SqlSelect a r-    )-  =>-    ToFrom (SqlQuery a)-  where-    type ToFromT (SqlQuery a) = a-    toFrom = SubQuery--instance-    ( SqlSelect c r-    , ToAlias c-    , ToAliasReference c-    , ToSetOperation a c-    , ToSetOperation b c-    , c ~ SetOperationT a-    )-  =>-    ToFrom (Union a b)-  where-    type ToFromT (Union a b) = SetOperationT a-    toFrom u = SqlSetOperation $ toSetOperation u--instance-    ( SqlSelect c r-    , ToAlias c-    , ToAliasReference c-    , ToSetOperation a c-    , ToSetOperation b c-    , c ~ SetOperationT a-    )-  =>-    ToFrom (UnionAll a b)-  where-    type ToFromT (UnionAll a b) = SetOperationT a-    toFrom u = SqlSetOperation $ toSetOperation u--instance-    ( SqlSelect c r-    , ToAlias c-    , ToAliasReference c-    , ToSetOperation a c-    , ToSetOperation b c-    , c ~ SetOperationT a-    )-  =>-    ToFrom (Intersect a b)-  where-    type ToFromT (Intersect a b) = SetOperationT a-    toFrom u = SqlSetOperation $ toSetOperation u--instance-    ( SqlSelect c r-    , ToAlias c-    , ToAliasReference c-    , ToSetOperation a c-    , ToSetOperation b c-    , c ~ SetOperationT a-    )-  =>-    ToFrom (Except a b)-  where-    type ToFromT (Except a b) = SetOperationT a-    toFrom u = SqlSetOperation $ toSetOperation u--instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToFrom (SqlSetOperation a) where-    type ToFromT (SqlSetOperation a) = a-    -- If someone uses just a plain SelectQuery it should behave like a normal subquery-    toFrom (SelectQueryP _ q) = SubQuery q-    -- Otherwise use the SqlSetOperation-    toFrom q = SqlSetOperation q--class ToInnerJoin lateral lhs rhs res where-    toInnerJoin :: Proxy lateral -> lhs -> rhs -> (res -> SqlExpr (Value Bool)) -> From res--instance ( SqlSelect b r-         , ToAlias b-         , ToAliasReference b-         , ToFrom a-         , ToFromT a ~ a'-         ) => ToInnerJoin Lateral a (a' -> SqlQuery b) (a' :& b) where-             toInnerJoin _ lhs q on' = InnerJoinFromLateral (toFrom lhs) (q, on')--instance (ToFrom a, ToFromT a ~ a', ToFrom b, ToFromT b ~ b')-  => ToInnerJoin NotLateral a b (a' :& b') where-      toInnerJoin _ lhs rhs on' = InnerJoinFrom (toFrom lhs) (toFrom rhs, on')--instance (ToInnerJoin (IsLateral b) a b b') => ToFrom (InnerJoin a (b, b' -> SqlExpr (Value Bool))) where-    type ToFromT (InnerJoin a (b, b' -> SqlExpr (Value Bool))) = FromOnClause (b, b' -> SqlExpr(Value Bool))-    toFrom (InnerJoin lhs (rhs, on')) = toInnerJoin (toProxy rhs) lhs rhs on'-        where-            toProxy :: b -> Proxy (IsLateral b)-            toProxy _ = Proxy---- @since 3.4.0.1-type family FromCrossJoin a b where-    FromCrossJoin a (b -> SqlQuery c) = ToFromT a :& c-    FromCrossJoin a b = ToFromT a :& ToFromT b--instance ( ToFrom a-         , ToFrom b-         , ToFromT (CrossJoin a b) ~ (ToFromT a :& ToFromT b)-         ) => ToFrom (CrossJoin a b) where-    type ToFromT (CrossJoin a b) = FromCrossJoin a b-    toFrom (CrossJoin lhs rhs) = CrossJoinFrom (toFrom lhs) (toFrom rhs)--instance {-# OVERLAPPING #-}-         ( ToFrom a-         , ToFromT a ~ a'-         , SqlSelect b r-         , ToAlias b-         , ToAliasReference b-         ) => ToFrom (CrossJoin a (a' -> SqlQuery b)) where-    type ToFromT (CrossJoin a (a' -> SqlQuery b)) = FromCrossJoin a (a' -> SqlQuery b)-    toFrom (CrossJoin lhs q) = CrossJoinFromLateral (toFrom lhs) q--class ToLeftJoin lateral lhs rhs res where-    toLeftJoin :: Proxy lateral -> lhs -> rhs -> (res -> SqlExpr (Value Bool)) -> From res--instance ( ToFrom a-         , ToFromT a ~ a'-         , SqlSelect b r-         , ToAlias b-         , ToAliasReference b-         , ToMaybe b-         , mb ~ ToMaybeT b-         ) => ToLeftJoin Lateral a (a' -> SqlQuery b) (a' :& mb) where-            toLeftJoin _ lhs q on' = LeftJoinFromLateral (toFrom lhs) (q, on')--instance ( ToFrom a-         , ToFromT a ~ a'-         , ToFrom b-         , ToFromT b ~ b'-         , ToMaybe b'-         , mb ~ ToMaybeT b'-         ) => ToLeftJoin NotLateral a b (a' :& mb) where-            toLeftJoin _ lhs rhs on' = LeftJoinFrom (toFrom lhs) (toFrom rhs, on')--instance ( ToLeftJoin (IsLateral b) a b b'-         ) => ToFrom (LeftOuterJoin a (b, b' -> SqlExpr (Value Bool))) where-            type ToFromT (LeftOuterJoin a (b, b' -> SqlExpr (Value Bool))) = FromOnClause (b, b' -> SqlExpr(Value Bool))-            toFrom (LeftOuterJoin lhs (rhs, on')) =-                toLeftJoin (toProxy rhs) lhs rhs on'-              where-                toProxy :: b -> Proxy (IsLateral b)-                toProxy _ = Proxy--instance ( ToFrom a-         , ToFromT a ~ a'-         , ToFrom b-         , ToFromT b ~ b'-         , ToMaybe a'-         , ma ~ ToMaybeT a'-         , ToMaybe b'-         , mb ~ ToMaybeT b'-         , ErrorOnLateral b-         ) => ToFrom (FullOuterJoin a (b, (ma :& mb) -> SqlExpr (Value Bool))) where-            type ToFromT (FullOuterJoin a (b, (ma :& mb) -> SqlExpr (Value Bool))) = FromOnClause (b, (ma :& mb) -> SqlExpr(Value Bool))-            toFrom (FullOuterJoin lhs (rhs, on')) = FullJoinFrom (toFrom lhs) (toFrom rhs, on')--instance ( ToFrom a-         , ToFromT a ~ a'-         , ToMaybe a'-         , ma ~ ToMaybeT a'-         , ToFrom b-         , ToFromT b ~ b'-         , ErrorOnLateral b-         ) => ToFrom (RightOuterJoin a (b, (ma :& b') -> SqlExpr (Value Bool))) where-            type ToFromT (RightOuterJoin a (b, (ma :& b') -> SqlExpr (Value Bool))) = FromOnClause (b, (ma :& b') -> SqlExpr(Value Bool))-            toFrom (RightOuterJoin lhs (rhs, on')) = RightJoinFrom (toFrom lhs) (toFrom rhs,  on')--type family Nullable a where-    Nullable (Maybe a) = a-    Nullable a =  a--class ToMaybe a where-    type ToMaybeT a-    toMaybe :: a -> ToMaybeT a--instance ToMaybe (SqlExpr (Maybe a)) where-    type ToMaybeT (SqlExpr (Maybe a)) = SqlExpr (Maybe a)-    toMaybe = id--instance ToMaybe (SqlExpr (Entity a)) where-    type ToMaybeT (SqlExpr (Entity a)) = SqlExpr (Maybe (Entity a))-    toMaybe = EMaybe--instance ToMaybe (SqlExpr (Value a)) where-    type ToMaybeT (SqlExpr (Value a)) = SqlExpr (Value (Maybe (Nullable a)))-    toMaybe = veryUnsafeCoerceSqlExprValue--instance (ToMaybe a, ToMaybe b) => ToMaybe (a :& b) where-    type ToMaybeT (a :& b) = (ToMaybeT a :& ToMaybeT b)-    toMaybe (a :& b) = (toMaybe a :& toMaybe b)--instance (ToMaybe a, ToMaybe b) => ToMaybe (a,b) where-    type ToMaybeT (a, b) = (ToMaybeT a, ToMaybeT b)-    toMaybe (a, b) = (toMaybe a, toMaybe b)--instance ( ToMaybe a , ToMaybe b , ToMaybe c) => ToMaybe (a,b,c) where-    type ToMaybeT (a, b, c) = (ToMaybeT a, ToMaybeT b, ToMaybeT c)-    toMaybe = to3 . toMaybe . from3--instance ( ToMaybe a , ToMaybe b , ToMaybe c , ToMaybe d) => ToMaybe (a,b,c,d) where-    type ToMaybeT (a, b, c, d) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d)-    toMaybe = to4 . toMaybe . from4--instance ( ToMaybe a , ToMaybe b , ToMaybe c , ToMaybe d , ToMaybe e) => ToMaybe (a,b,c,d,e) where-    type ToMaybeT (a, b, c, d, e) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e)-    toMaybe = to5 . toMaybe . from5--instance ( ToMaybe a-         , ToMaybe b-         , ToMaybe c-         , ToMaybe d-         , ToMaybe e-         , ToMaybe f-         ) => ToMaybe (a,b,c,d,e,f) where-    type ToMaybeT (a, b, c, d, e, f) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e, ToMaybeT f)-    toMaybe = to6 . toMaybe . from6--instance ( ToMaybe a-         , ToMaybe b-         , ToMaybe c-         , ToMaybe d-         , ToMaybe e-         , ToMaybe f-         , ToMaybe g-         ) => ToMaybe (a,b,c,d,e,f,g) where-    type ToMaybeT (a, b, c, d, e, f, g) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e, ToMaybeT f, ToMaybeT g)-    toMaybe = to7 . toMaybe . from7--instance ( ToMaybe a-         , ToMaybe b-         , ToMaybe c-         , ToMaybe d-         , ToMaybe e-         , ToMaybe f-         , ToMaybe g-         , ToMaybe h-         ) => ToMaybe (a,b,c,d,e,f,g,h) where-     type ToMaybeT (a, b, c, d, e, f, g, h) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e, ToMaybeT f, ToMaybeT g, ToMaybeT h)-     toMaybe = to8 . toMaybe . from8---- | 'FROM' clause, used to bring entities into scope.------ Internally, this function uses the `From` datatype and the--- `ToFrom` typeclass. Unlike the old `Database.Esqueleto.from`,--- this does not take a function as a parameter, but rather--- a value that represents a 'JOIN' tree constructed out of--- instances of `ToFrom`. This implementation eliminates certain--- types of runtime errors by preventing the construction of--- invalid SQL (e.g. illegal nested-@from@).-from :: ToFrom a  => a -> SqlQuery (ToFromT a)-from parts = do-    (a, clause) <- runFrom $ toFrom parts-    Q $ W.tell mempty{sdFromClause=[clause]}-    pure a-  where-    runFrom :: From a -> SqlQuery (a, FromClause)-    runFrom e@Table = do-        let ed = entityDef $ getVal e-        ident <- newIdentFor . DBName . unEntityNameDB $ getEntityDBName ed-        let entity = EEntity ident-        pure $ (entity, FromStart ident ed)-          where-            getVal :: From (SqlExpr (Entity ent)) -> Proxy ent-            getVal = const Proxy-    runFrom (SubQuery subquery) =-        fromSubQuery NormalSubQuery subquery--    runFrom (FromCte ident ref) =-        pure (ref, FromIdent ident)--    runFrom (SqlSetOperation operation) = do-        (aliasedOperation, ret) <- aliasQueries operation-        ident <- newIdentFor (DBName "u")-        ref <- toAliasReference ident ret-        pure (ref, FromQuery ident (operationToSql aliasedOperation) NormalSubQuery)--      where-        aliasQueries o =-            case o of-                SelectQueryP p q -> do-                    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ q-                    prevState <- Q $ lift S.get-                    aliasedRet <- toAlias ret-                    Q $ lift $ S.put prevState-                    let p' =-                          case p of-                            Parens -> Parens-                            Never ->-                              if (sdLimitClause sideData) /= mempty-                                  || length (sdOrderByClause sideData) > 0 then-                                Parens-                              else-                                Never-                    pure (SelectQueryP p' $ Q $ W.WriterT $ pure (aliasedRet, sideData), aliasedRet)-                SqlSetUnion     o1 o2 -> do-                    (o1', ret) <- aliasQueries o1-                    (o2', _  ) <- aliasQueries o2-                    pure (SqlSetUnion o1' o2', ret)-                SqlSetUnionAll  o1 o2 -> do-                    (o1', ret) <- aliasQueries o1-                    (o2', _  ) <- aliasQueries o2-                    pure (SqlSetUnionAll o1' o2', ret)-                SqlSetExcept    o1 o2 -> do-                    (o1', ret) <- aliasQueries o1-                    (o2', _  ) <- aliasQueries o2-                    pure (SqlSetExcept o1' o2', ret)-                SqlSetIntersect o1 o2 -> do-                    (o1', ret) <- aliasQueries o1-                    (o2', _  ) <- aliasQueries o2-                    pure (SqlSetIntersect o1' o2', ret)--        operationToSql o info =-            case o of-                SelectQueryP p q  ->-                    let (builder, values) = toRawSql SELECT info q-                    in (parensM p builder, values)-                SqlSetUnion     o1 o2 -> doSetOperation "UNION"     info o1 o2-                SqlSetUnionAll  o1 o2 -> doSetOperation "UNION ALL" info o1 o2-                SqlSetExcept    o1 o2 -> doSetOperation "EXCEPT"    info o1 o2-                SqlSetIntersect o1 o2 -> doSetOperation "INTERSECT" info o1 o2--        doSetOperation operationText info o1 o2 =-            let (q1, v1) = operationToSql o1 info-                (q2, v2) = operationToSql o2 info-            in (q1 <> " " <> operationText <> " " <> q2, v1 <> v2)--    runFrom (InnerJoinFrom leftPart (rightPart, on')) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- runFrom rightPart-        let ret = leftVal :& rightVal-        pure $ (ret, FromJoin leftFrom InnerJoinKind rightFrom (Just (on' ret)))-    runFrom (InnerJoinFromLateral leftPart (q, on')) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- fromSubQuery LateralSubQuery (q leftVal)-        let ret = leftVal :& rightVal-        pure $ (ret, FromJoin leftFrom InnerJoinKind rightFrom (Just (on' ret)))-    runFrom (CrossJoinFrom leftPart rightPart) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- runFrom rightPart-        let ret = leftVal :& rightVal-        pure $ (ret, FromJoin leftFrom CrossJoinKind rightFrom Nothing)-    runFrom (CrossJoinFromLateral leftPart q) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- fromSubQuery LateralSubQuery (q leftVal)-        let ret = leftVal :& rightVal-        pure $ (ret, FromJoin leftFrom CrossJoinKind rightFrom Nothing)-    runFrom (LeftJoinFrom leftPart (rightPart, on')) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- runFrom rightPart-        let ret = leftVal :& (toMaybe rightVal)-        pure $ (ret, FromJoin leftFrom LeftOuterJoinKind rightFrom (Just (on' ret)))-    runFrom (LeftJoinFromLateral leftPart (q, on')) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- fromSubQuery LateralSubQuery (q leftVal)-        let ret = leftVal :& (toMaybe rightVal)-        pure $ (ret, FromJoin leftFrom LeftOuterJoinKind rightFrom (Just (on' ret)))-    runFrom (RightJoinFrom leftPart (rightPart, on')) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- runFrom rightPart-        let ret = (toMaybe leftVal) :& rightVal-        pure $ (ret, FromJoin leftFrom RightOuterJoinKind rightFrom (Just (on' ret)))-    runFrom (FullJoinFrom leftPart (rightPart, on')) = do-        (leftVal, leftFrom) <- runFrom leftPart-        (rightVal, rightFrom) <- runFrom rightPart-        let ret = (toMaybe leftVal) :& (toMaybe rightVal)-        pure $ (ret, FromJoin leftFrom FullOuterJoinKind rightFrom (Just (on' ret)))--fromSubQuery-    ::-    ( SqlSelect a r-    , ToAlias a-    , ToAliasReference a-    )-    => SubQueryType -> SqlQuery a -> SqlQuery (a, FromClause)-fromSubQuery subqueryType subquery = do-    -- We want to update the IdentState without writing the query to side data-    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ subquery-    aliasedValue <- toAlias ret-    -- Make a fake query with the aliased results, this allows us to ensure that the query is only run once-    let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)-    -- Add the FromQuery that renders the subquery to our side data-    subqueryAlias <- newIdentFor (DBName "q")-    -- Pass the aliased results of the subquery to the outer query-    -- create aliased references from the outer query results (e.g value from subquery will be `subquery`.`value`),-    -- this is probably overkill as the aliases should already be unique but seems to be good practice.-    ref <- toAliasReference subqueryAlias aliasedValue-    pure (ref , FromQuery subqueryAlias (\info -> toRawSql SELECT info aliasedQuery) subqueryType)---- | @WITH@ clause used to introduce a [Common Table Expression (CTE)](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL#Common_table_expression).--- CTEs are supported in most modern SQL engines and can be useful--- in performance tuning. In Esqueleto, CTEs should be used as a--- subquery memoization tactic. When writing plain SQL, CTEs--- are sometimes used to organize the SQL code, in Esqueleto, this--- is better achieved through function that return 'SqlQuery' values.------ @--- select $ do--- cte <- with subQuery--- cteResult <- from cte--- where_ $ cteResult ...--- pure cteResult--- @------ __WARNING__: In some SQL engines using a CTE can diminish performance.--- In these engines the CTE is treated as an optimization fence. You should--- always verify that using a CTE will in fact improve your performance--- over a regular subquery.------ /Since: 3.4.0.0/-with :: ( ToAlias a-        , ToAliasReference a-        , SqlSelect a r-        ) => SqlQuery a -> SqlQuery (From a)-with query = do-    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ query-    aliasedValue <- toAlias ret-    let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)-    ident <- newIdentFor (DBName "cte")-    let clause = CommonTableExpressionClause NormalCommonTableExpression ident (\info -> toRawSql SELECT info aliasedQuery)-    Q $ W.tell mempty{sdCteClause = [clause]}-    ref <- toAliasReference ident aliasedValue-    pure $ FromCte ident ref---- | @WITH@ @RECURSIVE@ allows one to make a recursive subquery, which can--- reference itself. Like @WITH@, this is supported in most modern SQL engines.--- Useful for hierarchical, self-referential data, like a tree of data.------ @--- select $ do--- cte <- withRecursive---          (do $---              person <- from $ Table \@Person---              where_ $ person ^. PersonId ==. val personId---              pure person---          )---          unionAll_---          (\\self -> do $---              (p :& f :& p2 :& pSelf) <- from self---                       \`InnerJoin\` $ Table \@Follow---                       \`on\` (\\(p :& f) ->---                               p ^. PersonId ==. f ^. FollowFollower)---                       \`InnerJoin\` $ Table \@Person---                       \`on\` (\\(p :& f :& p2) ->---                               f ^. FollowFollowed ==. p2 ^. PersonId)---                       \`LeftOuterJoin\` self---                       \`on\` (\\(_ :& _ :& p2 :& pSelf) ->---                               just (p2 ^. PersonId) ==. pSelf ?. PersonId)---              where_ $ isNothing (pSelf ?. PersonId)---              groupBy (p2 ^. PersonId)---              pure p2---          )--- from cte--- @------ /Since: 3.4.0.0/-withRecursive :: ( ToAlias a-                 , ToAliasReference a-                 , SqlSelect a r-                 , RecursiveCteUnion unionKind-                 )-              => SqlQuery a-              -> unionKind-              -> (From a -> SqlQuery a)-              -> SqlQuery (From a)-withRecursive baseCase unionKind recursiveCase = do-    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ baseCase-    aliasedValue <- toAlias ret-    let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)-    ident <- newIdentFor (DBName "cte")-    ref <- toAliasReference ident aliasedValue-    let refFrom = FromCte ident ref-    let recursiveQuery = recursiveCase refFrom-    let clause = CommonTableExpressionClause RecursiveCommonTableExpression ident-                 (\info -> (toRawSql SELECT info aliasedQuery)-                        <> (unionKeyword unionKind, mempty)-                        <> (toRawSql SELECT info recursiveQuery)-                 )-    Q $ W.tell mempty{sdCteClause = [clause]}-    pure refFrom--{-# DEPRECATED ToAliasT "This type alias doesn't do anything. Please delete it. Will be removed in the next release." #-}-type ToAliasT a = a---- Tedious tuple magic-class ToAlias a where-    toAlias :: a -> SqlQuery a--instance ToAlias (SqlExpr (Value a)) where-    toAlias v@(EAliasedValue _ _) = pure v-    toAlias v = do-        ident <- newIdentFor (DBName "v")-        pure $ EAliasedValue ident v--instance ToAlias (SqlExpr (Entity a)) where-    toAlias v@(EAliasedEntityReference _ _) = pure v-    toAlias v@(EAliasedEntity _ _) = pure v-    toAlias (EEntity tableIdent) = do-       ident <- newIdentFor (DBName "v")-       pure $ EAliasedEntity ident tableIdent--instance ToAlias (SqlExpr (Maybe (Entity a))) where-    toAlias (EMaybe e) = EMaybe <$> toAlias e--instance (ToAlias a, ToAlias b) => ToAlias (a,b) where-    toAlias (a,b) = (,) <$> toAlias a <*> toAlias b--instance ( ToAlias a-         , ToAlias b-         , ToAlias c-         ) => ToAlias (a,b,c) where-    toAlias x = to3 <$> (toAlias $ from3 x)--instance ( ToAlias a-         , ToAlias b-         , ToAlias c-         , ToAlias d-         ) => ToAlias (a,b,c,d) where-    toAlias x = to4 <$> (toAlias $ from4 x)--instance ( ToAlias a-         , ToAlias b-         , ToAlias c-         , ToAlias d-         , ToAlias e-         ) => ToAlias (a,b,c,d,e) where-    toAlias x = to5 <$> (toAlias $ from5 x)--instance ( ToAlias a-         , ToAlias b-         , ToAlias c-         , ToAlias d-         , ToAlias e-         , ToAlias f-         ) => ToAlias (a,b,c,d,e,f) where-    toAlias x = to6 <$> (toAlias $ from6 x)--instance ( ToAlias a-         , ToAlias b-         , ToAlias c-         , ToAlias d-         , ToAlias e-         , ToAlias f-         , ToAlias g-         ) => ToAlias (a,b,c,d,e,f,g) where-    toAlias x = to7 <$> (toAlias $ from7 x)--instance ( ToAlias a-         , ToAlias b-         , ToAlias c-         , ToAlias d-         , ToAlias e-         , ToAlias f-         , ToAlias g-         , ToAlias h-         ) => ToAlias (a,b,c,d,e,f,g,h) where-    toAlias x = to8 <$> (toAlias $ from8 x)--{-# DEPRECATED ToAliasReferenceT "This type alias doesn't do anything. Please delete it. Will be removed in the next release." #-}-type ToAliasReferenceT a = a---- more tedious tuple magic-class ToAliasReference a where-    toAliasReference :: Ident -> a -> SqlQuery a--instance ToAliasReference (SqlExpr (Value a)) where-    toAliasReference aliasSource (EAliasedValue aliasIdent _) = pure $ EValueReference aliasSource (\_ -> aliasIdent)-    toAliasReference _           v@(ERaw _ _)                 = toAlias v-    toAliasReference _           v@(ECompositeKey _)          = toAlias v-    toAliasReference s             (EValueReference _ b)      = pure $ EValueReference s b--instance ToAliasReference (SqlExpr (Entity a)) where-    toAliasReference aliasSource (EAliasedEntity ident _) = pure $ EAliasedEntityReference aliasSource ident-    toAliasReference _ e@(EEntity _) = toAlias e-    toAliasReference s   (EAliasedEntityReference _ b) = pure $ EAliasedEntityReference s b--instance ToAliasReference (SqlExpr (Maybe (Entity a))) where-    toAliasReference s (EMaybe e) = EMaybe <$> toAliasReference s e---instance (ToAliasReference a, ToAliasReference b) => ToAliasReference (a, b) where-    toAliasReference ident (a,b) = (,) <$> (toAliasReference ident a) <*> (toAliasReference ident b)--instance ( ToAliasReference a-         , ToAliasReference b-         , ToAliasReference c-         ) => ToAliasReference (a,b,c) where-    toAliasReference ident x = fmap to3 $ toAliasReference ident $ from3 x--instance ( ToAliasReference a-         , ToAliasReference b-         , ToAliasReference c-         , ToAliasReference d-         ) => ToAliasReference (a,b,c,d) where-    toAliasReference ident x = fmap to4 $ toAliasReference ident $ from4 x--instance ( ToAliasReference a-         , ToAliasReference b-         , ToAliasReference c-         , ToAliasReference d-         , ToAliasReference e-         ) => ToAliasReference (a,b,c,d,e) where-    toAliasReference ident x = fmap to5 $ toAliasReference ident $ from5 x--instance ( ToAliasReference a-         , ToAliasReference b-         , ToAliasReference c-         , ToAliasReference d-         , ToAliasReference e-         , ToAliasReference f-         ) => ToAliasReference (a,b,c,d,e,f) where-    toAliasReference ident x = to6 <$> (toAliasReference ident $ from6 x)--instance ( ToAliasReference a-         , ToAliasReference b-         , ToAliasReference c-         , ToAliasReference d-         , ToAliasReference e-         , ToAliasReference f-         , ToAliasReference g-         ) => ToAliasReference (a,b,c,d,e,f,g) where-    toAliasReference ident x = to7 <$> (toAliasReference ident $ from7 x)--instance ( ToAliasReference a-         , ToAliasReference b-         , ToAliasReference c-         , ToAliasReference d-         , ToAliasReference e-         , ToAliasReference f-         , ToAliasReference g-         , ToAliasReference h-         ) => ToAliasReference (a,b,c,d,e,f,g,h) where-    toAliasReference ident x = to8 <$> (toAliasReference ident $ from8 x)--class RecursiveCteUnion a where-    unionKeyword :: a -> TLB.Builder--instance RecursiveCteUnion (a -> b -> Union a b) where-    unionKeyword _ = "\nUNION\n"--instance RecursiveCteUnion (a -> b -> UnionAll a b) where-    unionKeyword _ = "\nUNION ALL\n"
+ src/Database/Esqueleto/Experimental/From.hs view
@@ -0,0 +1,145 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DerivingStrategies #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-}++module Database.Esqueleto.Experimental.From+    where++import qualified Control.Monad.Trans.Writer as W+import Data.Coerce (coerce)+import Data.Proxy+import qualified Data.Text.Lazy.Builder as TLB+import Database.Esqueleto.Experimental.ToAlias+import Database.Esqueleto.Experimental.ToAliasReference+import Database.Esqueleto.Internal.Internal hiding (From(..), from, on)+import Database.Esqueleto.Internal.PersistentImport++import Database.Persist.Names (EntityNameDB(..))++-- | 'FROM' clause, used to bring entities into scope.+--+-- Internally, this function uses the `From` datatype.+-- Unlike the old `Database.Esqueleto.from`, this does not+-- take a function as a parameter, but rather a value that+-- represents a 'JOIN' tree constructed out of instances of `From`.+-- This implementation eliminates certain+-- types of runtime errors by preventing the construction of+-- invalid SQL (e.g. illegal nested-@from@).+from :: ToFrom a a' => a -> SqlQuery a'+from f = do+    (a, clause) <- unFrom (toFrom f)+    Q $ W.tell mempty{sdFromClause=[FromRaw $ clause]}+    pure a++type RawFn = NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue])++-- | Data type defining the "From" language. This should not+-- constructed directly in application code.+--+-- A @From@ is a SqlQuery which returns a reference to the result of calling from+-- and a function that produces a portion of a FROM clause. This gets passed to+-- the FromRaw FromClause constructor directly when converting+-- from a @From@ to a @SqlQuery@ using @from@+--+-- @since 3.5.0.0+newtype From a = From+    { unFrom :: SqlQuery (a, RawFn)}+++-- | A helper class primarily designed to allow using @SqlQuery@ directly in+-- a From expression. This is also useful for embedding a @SqlSetOperation@,+-- as well as supporting backwards compatibility for the+-- data constructor join tree used prior to /3.5.0.0/+--+-- @since 3.5.0.0+class ToFrom a r | a -> r where+    toFrom :: a -> From r+instance ToFrom (From a) a where+    toFrom = id++{-# DEPRECATED Table "@since 3.5.0.0 - use 'table' instead" #-}+data Table a = Table++instance PersistEntity ent => ToFrom (Table ent) (SqlExpr (Entity ent)) where+    toFrom _ = table++-- | Bring a PersistEntity into scope from a table+--+-- @+-- select $ from $ table \@People+-- @+--+-- @since 3.5.0.0+table :: forall ent. PersistEntity ent => From (SqlExpr (Entity ent))+table = From $ do+    let ed = entityDef (Proxy @ent)+    ident <- newIdentFor (coerce $ getEntityDBName ed)+    let entity = unsafeSqlEntity ident+    pure $ ( entity, const $ base ident ed )+      where+        base ident@(I identText) def info =+            let db = coerce $ getEntityDBName def+            in ( (fromDBName info (coerce db)) <>+                     if  db == identText+                     then mempty+                     else " AS " <> useIdent info ident+               , mempty+               )+++{-# DEPRECATED SubQuery "/Since: 3.4.0.0/ - It is no longer necessary to tag 'SqlQuery' values with @SubQuery@" #-}+newtype SubQuery a = SubQuery a+instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToFrom (SubQuery (SqlQuery a)) a where+    toFrom (SubQuery q) = selectQuery q+instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToFrom (SqlQuery a) a where+    toFrom = selectQuery++-- | Select from a subquery, often used in conjuction with joins but can be+-- used without any joins. Because @SqlQuery@ has a @ToFrom@ instance you probably+-- dont need to use this function directly.+--+-- @+-- select $+--      p <- from $+--              selectQuery do+--              p <- from $ table \@Person+--              limit 5+--              orderBy [ asc p ^. PersonAge ]+--      ...+-- @+--+-- @since 3.5.0.0+selectQuery :: (SqlSelect a r, ToAlias a, ToAliasReference a) => SqlQuery a -> From a+selectQuery subquery = From $ do+    -- We want to update the IdentState without writing the query to side data+    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ subquery+    aliasedValue <- toAlias ret+    -- Make a fake query with the aliased results, this allows us to ensure that the query is only run once+    let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)+    -- Add the FromQuery that renders the subquery to our side data+    subqueryAlias <- newIdentFor (DBName "q")+    -- Pass the aliased results of the subquery to the outer query+    -- create aliased references from the outer query results (e.g value from subquery will be `subquery`.`value`),+    -- this is probably overkill as the aliases should already be unique but seems to be good practice.+    ref <- toAliasReference subqueryAlias aliasedValue++    pure (ref, \_ info ->+            let (queryText,queryVals) = toRawSql SELECT info aliasedQuery+            in+            ( (parens queryText) <> " AS " <> useIdent info subqueryAlias+            , queryVals+            )+         )
+ src/Database/Esqueleto/Experimental/From/CommonTableExpression.hs view
@@ -0,0 +1,111 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeFamilies #-}++module Database.Esqueleto.Experimental.From.CommonTableExpression+    where++import qualified Control.Monad.Trans.Writer as W+import qualified Data.Text.Lazy.Builder as TLB+import Database.Esqueleto.Experimental.From+import Database.Esqueleto.Experimental.From.SqlSetOperation+import Database.Esqueleto.Experimental.ToAlias+import Database.Esqueleto.Experimental.ToAliasReference+import Database.Esqueleto.Internal.Internal hiding (From(..), from, on)++-- | @WITH@ clause used to introduce a [Common Table Expression (CTE)](https://en.wikipedia.org/wiki/Hierarchical_and_recursive_queries_in_SQL#Common_table_expression).+-- CTEs are supported in most modern SQL engines and can be useful+-- in performance tuning. In Esqueleto, CTEs should be used as a+-- subquery memoization tactic. When writing plain SQL, CTEs+-- are sometimes used to organize the SQL code, in Esqueleto, this+-- is better achieved through function that return 'SqlQuery' values.+--+-- @+-- select $ do+-- cte <- with subQuery+-- cteResult <- from cte+-- where_ $ cteResult ...+-- pure cteResult+-- @+--+-- __WARNING__: In some SQL engines using a CTE can diminish performance.+-- In these engines the CTE is treated as an optimization fence. You should+-- always verify that using a CTE will in fact improve your performance+-- over a regular subquery.+--+-- /Since: 3.4.0.0/+with :: ( ToAlias a+        , ToAliasReference a+        , SqlSelect a r+        ) => SqlQuery a -> SqlQuery (From a)+with query = do+    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ query+    aliasedValue <- toAlias ret+    let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)+    ident <- newIdentFor (DBName "cte")+    let clause = CommonTableExpressionClause NormalCommonTableExpression ident (\info -> toRawSql SELECT info aliasedQuery)+    Q $ W.tell mempty{sdCteClause = [clause]}+    ref <- toAliasReference ident aliasedValue+    pure $ From $ pure (ref, (\_ info -> (useIdent info ident, mempty)))++-- | @WITH@ @RECURSIVE@ allows one to make a recursive subquery, which can+-- reference itself. Like @WITH@, this is supported in most modern SQL engines.+-- Useful for hierarchical, self-referential data, like a tree of data.+--+-- @+-- select $ do+-- cte <- withRecursive+--          (do+--              person <- from $ table \@Person+--              where_ $ person ^. PersonId ==. val personId+--              pure person+--          )+--          unionAll_+--          (\\self -> do+--              (p :& f :& p2 :& pSelf) <- from self+--                       \`innerJoin\` $ table \@Follow+--                       \`on\` (\\(p :& f) ->+--                               p ^. PersonId ==. f ^. FollowFollower)+--                       \`innerJoin\` $ table \@Person+--                       \`on\` (\\(p :& f :& p2) ->+--                               f ^. FollowFollowed ==. p2 ^. PersonId)+--                       \`leftJoin\` self+--                       \`on\` (\\(_ :& _ :& p2 :& pSelf) ->+--                               just (p2 ^. PersonId) ==. pSelf ?. PersonId)+--              where_ $ isNothing (pSelf ?. PersonId)+--              groupBy (p2 ^. PersonId)+--              pure p2+--          )+-- from cte+-- @+--+-- /Since: 3.4.0.0/+withRecursive :: ( ToAlias a+                 , ToAliasReference a+                 , SqlSelect a r+                 )+              => SqlQuery a+              -> UnionKind+              -> (From a -> SqlQuery a)+              -> SqlQuery (From a)+withRecursive baseCase unionKind recursiveCase = do+    (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ baseCase+    aliasedValue <- toAlias ret+    let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)+    ident <- newIdentFor (DBName "cte")+    ref <- toAliasReference ident aliasedValue+    let refFrom = From (pure (ref, (\_ info -> (useIdent info ident, mempty))))+    let recursiveQuery = recursiveCase refFrom+    let clause = CommonTableExpressionClause RecursiveCommonTableExpression ident+                 (\info -> (toRawSql SELECT info aliasedQuery)+                        <> ("\n" <> (unUnionKind unionKind)  <> "\n", mempty)+                        <> (toRawSql SELECT info recursiveQuery)+                 )+    Q $ W.tell mempty{sdCteClause = [clause]}+    pure refFrom++newtype UnionKind = UnionKind { unUnionKind :: TLB.Builder }+instance Union_ UnionKind where+    union_ = UnionKind "UNION"+instance UnionAll_ UnionKind where+    unionAll_ = UnionKind "UNION ALL"
+ src/Database/Esqueleto/Experimental/From/Join.hs view
@@ -0,0 +1,401 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE UndecidableInstances #-}++{-# OPTIONS_GHC -fno-warn-orphans #-}++module Database.Esqueleto.Experimental.From.Join+    where++import Data.Bifunctor (first)+import Data.Kind (Constraint)+import Data.Proxy+import qualified Data.Text.Lazy.Builder as TLB+import Database.Esqueleto.Experimental.From+import Database.Esqueleto.Experimental.ToAlias+import Database.Esqueleto.Experimental.ToAliasReference+import Database.Esqueleto.Experimental.ToMaybe+import Database.Esqueleto.Internal.Internal hiding+       (From(..), from, fromJoin, on)+import GHC.TypeLits++-- | A left-precedence pair. Pronounced \"and\". Used to represent expressions+-- that have been joined together.+--+-- The precedence behavior can be demonstrated by:+--+-- @+-- a :& b :& c == ((a :& b) :& c)+-- @+--+-- See the examples at the beginning of this module to see how this+-- operator is used in 'JOIN' operations.+data (:&) a b = a :& b+infixl 2 :&++instance (ToMaybe a, ToMaybe b) => ToMaybe (a :& b) where+    type ToMaybeT (a :& b) = (ToMaybeT a :& ToMaybeT b)+    toMaybe (a :& b) = (toMaybe a :& toMaybe b)++class ValidOnClause a+instance {-# OVERLAPPABLE #-} ToFrom a a' => ValidOnClause a+instance ValidOnClause (a -> SqlQuery b)++-- | An @ON@ clause that describes how two tables are related. This should be+-- used as an infix operator after a 'JOIN'. For example,+--+-- @+-- select $+-- from $ table \@Person+-- \`innerJoin\` table \@BlogPost+-- \`on\` (\\(p :& bP) ->+--         p ^. PersonId ==. bP ^. BlogPostAuthorId)+-- @+on :: ValidOnClause a => a -> (b -> SqlExpr (Value Bool)) -> (a, b -> SqlExpr (Value Bool))+on = (,)+infix 9 `on`++type family ErrorOnLateral a :: Constraint where+  ErrorOnLateral (a -> SqlQuery b) = TypeError ('Text "LATERAL can only be used for INNER, LEFT, and CROSS join kinds.")+  ErrorOnLateral _ = ()++fromJoin :: TLB.Builder -> RawFn -> RawFn -> Maybe (SqlExpr (Value Bool)) -> RawFn+fromJoin joinKind lhs rhs monClause =+    \paren info ->+        first (parensM paren) $+        mconcat [ lhs Never info+                , (joinKind, mempty)+                , rhs Parens info+                , maybe mempty (makeOnClause info) monClause+                ]+    where+        makeOnClause info (ERaw _ f)        = first (" ON " <>) (f Never info)++type family HasOnClause actual expected :: Constraint where+    HasOnClause (a, b -> SqlExpr (Value Bool)) c = () -- Let the compiler handle the type mismatch+    HasOnClause a expected =+        TypeError ( 'Text "Missing ON clause for join with"+                    ':$$: 'ShowType a+                    ':$$: 'Text ""+                    ':$$: 'Text "Expected: "+                    ':$$: 'ShowType a+                    ':$$: 'Text "`on` " ':<>: 'ShowType (expected -> SqlExpr (Value Bool))+                    ':$$: 'Text ""+                  )+++-- | INNER JOIN+--+-- Used as an infix operator \`innerJoin\`+--+-- @+-- select $+-- from $ table \@Person+-- \`innerJoin\` table \@BlogPost+-- \`on\` (\\(p :& bp) ->+--         p ^. PersonId ==. bp ^. BlogPostAuthorId)+-- @+--+-- @since 3.5.0.0+innerJoin :: ( ToFrom a a'+             , ToFrom b b'+             , HasOnClause rhs (a' :& b')+             , rhs ~ (b, (a' :& b') -> SqlExpr (Value Bool))+             ) => a -> rhs -> From (a' :& b')+innerJoin lhs (rhs, on') = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (toFrom rhs)+     let ret = leftVal :& rightVal+     pure $ (ret, fromJoin " INNER JOIN " leftFrom rightFrom (Just $ on' ret))+++-- | INNER JOIN LATERAL+--+-- A Lateral subquery join allows the joined query to reference entities from the+-- left hand side of the join. Discards rows that don't match the on clause+--+-- Used as an infix operator \`innerJoinLateral\`+--+-- See example 6+--+-- @since 3.5.0.0+innerJoinLateral :: ( ToFrom a a'+                    , HasOnClause rhs (a' :& b)+                    , SqlSelect b r+                    , ToAlias b+                    , ToAliasReference b+                    , rhs ~ (a' -> SqlQuery b, (a' :& b) -> SqlExpr (Value Bool))+                    )+                 => a -> rhs -> From (a' :& b)+innerJoinLateral lhs (rhsFn, on') = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (selectQuery (rhsFn leftVal))+     let ret = leftVal :& rightVal+     pure $ (ret, fromJoin " INNER JOIN LATERAL " leftFrom rightFrom (Just $ on' ret))++-- | CROSS JOIN+--+-- Used as an infix \`crossJoin\`+--+-- @+-- select $ do+-- from $ table \@Person+-- \`crossJoin\` table \@BlogPost+-- @+--+-- @since 3.5.0.0+crossJoin :: ( ToFrom a a'+             , ToFrom b b'+             ) => a -> b -> From (a' :& b')+crossJoin lhs rhs = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (toFrom rhs)+     let ret = leftVal :& rightVal+     pure $ (ret, fromJoin " CROSS JOIN " leftFrom rightFrom Nothing)++-- | CROSS JOIN LATERAL+--+-- A Lateral subquery join allows the joined query to reference entities from the+-- left hand side of the join.+--+-- Used as an infix operator \`crossJoinLateral\`+--+-- See example 6+--+-- @since 3.5.0.0+crossJoinLateral :: ( ToFrom a a'+                    , SqlSelect b r+                    , ToAlias b+                    , ToAliasReference b+                    )+                 => a -> (a' -> SqlQuery b) -> From (a' :& b)+crossJoinLateral lhs rhsFn = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (selectQuery (rhsFn leftVal))+     let ret = leftVal :& rightVal+     pure $ (ret, fromJoin " CROSS JOIN LATERAL " leftFrom rightFrom Nothing)++-- | LEFT OUTER JOIN+--+-- Join where the right side may not exist.+-- If the on clause fails then the right side will be NULL'ed+-- Because of this the right side needs to be handled as a Maybe+--+-- Used as an infix operator \`leftJoin\`+--+-- @+-- select $+-- from $ table \@Person+-- \`leftJoin\` table \@BlogPost+-- \`on\` (\\(p :& bp) ->+--         p ^. PersonId ==. bp ?. BlogPostAuthorId)+-- @+--+-- @since 3.5.0.0+leftJoin :: ( ToFrom a a'+            , ToFrom b b'+            , ToMaybe b'+            , HasOnClause rhs (a' :& ToMaybeT b')+            , rhs ~ (b, (a' :& ToMaybeT b') -> SqlExpr (Value Bool))+            ) => a -> rhs -> From (a' :& ToMaybeT b')+leftJoin lhs (rhs, on') = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (toFrom rhs)+     let ret = leftVal :& toMaybe rightVal+     pure $ (ret, fromJoin " LEFT OUTER JOIN " leftFrom rightFrom (Just $ on' ret))++-- | LEFT OUTER JOIN LATERAL+--+-- Lateral join where the right side may not exist.+-- In the case that the query returns nothing or the on clause fails the right+-- side of the join will be NULL'ed+-- Because of this the right side needs to be handled as a Maybe+--+-- Used as an infix operator \`leftJoinLateral\`+--+-- See example 6 for how to use LATERAL+--+-- @since 3.5.0.0+leftJoinLateral :: ( ToFrom a a'+                   , SqlSelect b r+                   , HasOnClause rhs (a' :& ToMaybeT b)+                   , ToAlias b+                   , ToAliasReference b+                   , ToMaybe b+                   , rhs ~ (a' -> SqlQuery b, (a' :& ToMaybeT b) -> SqlExpr (Value Bool))+                   )+                 => a -> rhs -> From (a' :& ToMaybeT b)+leftJoinLateral lhs (rhsFn, on') = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (selectQuery (rhsFn leftVal))+     let ret = leftVal :& toMaybe rightVal+     pure $ (ret, fromJoin " LEFT OUTER JOIN LATERAL " leftFrom rightFrom (Just $ on' ret))++-- | RIGHT OUTER JOIN+--+-- Join where the left side may not exist.+-- If the on clause fails then the left side will be NULL'ed+-- Because of this the left side needs to be handled as a Maybe+--+-- Used as an infix operator \`rightJoin\`+--+-- @+-- select $+-- from $ table \@Person+-- \`rightJoin\` table \@BlogPost+-- \`on\` (\\(p :& bp) ->+--         p ?. PersonId ==. bp ^. BlogPostAuthorId)+-- @+--+-- @since 3.5.0.0+rightJoin :: ( ToFrom a a'+             , ToFrom b b'+             , ToMaybe a'+             , HasOnClause rhs (ToMaybeT a' :& b')+             , rhs ~ (b, (ToMaybeT a' :& b') -> SqlExpr (Value Bool))+             ) => a -> rhs -> From (ToMaybeT a' :& b')+rightJoin lhs (rhs, on') = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (toFrom rhs)+     let ret = toMaybe leftVal :& rightVal+     pure $ (ret, fromJoin " RIGHT OUTER JOIN " leftFrom rightFrom (Just $ on' ret))++-- | FULL OUTER JOIN+--+-- Join where both sides of the join may not exist.+-- Because of this the result needs to be handled as a Maybe+--+-- Used as an infix operator \`fullOuterJoin\`+--+-- @+-- select $+-- from $ table \@Person+-- \`fullOuterJoin\` table \@BlogPost+-- \`on\` (\\(p :& bp) ->+--         p ?. PersonId ==. bp ?. BlogPostAuthorId)+-- @+--+-- @since 3.5.0.0+fullOuterJoin :: ( ToFrom a a'+                 , ToFrom b b'+                 , ToMaybe a'+                 , ToMaybe b'+                 , HasOnClause rhs (ToMaybeT a' :& ToMaybeT b')+                 , rhs ~ (b, (ToMaybeT a' :& ToMaybeT b') -> SqlExpr (Value Bool))+                 ) => a -> rhs -> From (ToMaybeT a' :& ToMaybeT b')+fullOuterJoin lhs (rhs, on') = From $ do+     (leftVal, leftFrom) <- unFrom (toFrom lhs)+     (rightVal, rightFrom) <- unFrom (toFrom rhs)+     let ret = toMaybe leftVal :& toMaybe rightVal+     pure $ (ret, fromJoin " FULL OUTER JOIN " leftFrom rightFrom (Just $ on' ret))++infixl 2 `innerJoin`,+         `innerJoinLateral`,+         `leftJoin`,+         `leftJoinLateral`,+         `crossJoin`,+         `crossJoinLateral`,+         `rightJoin`,+         `fullOuterJoin`+++------ Compatibility for old syntax++data Lateral+data NotLateral++type family IsLateral a where+    IsLateral (a -> SqlQuery b, c) = Lateral+    IsLateral (a -> SqlQuery b) = Lateral+    IsLateral a = NotLateral++class DoInnerJoin lateral lhs rhs res | lateral rhs lhs -> res where+    doInnerJoin :: Proxy lateral -> lhs -> rhs -> From res++instance ( ToFrom a a'+         , ToFrom b b'+         , HasOnClause rhs (a' :& b')+         , rhs ~ (b, (a' :& b') -> SqlExpr (Value Bool))+         ) => DoInnerJoin NotLateral a rhs (a' :& b') where+    doInnerJoin _ = innerJoin++instance ( ToFrom a a'+         , SqlSelect b r+         , ToAlias b+         , ToAliasReference b+         , d ~ (a' :& b)+         ) => DoInnerJoin Lateral a (a' -> SqlQuery b, d -> SqlExpr (Value Bool)) d where+    doInnerJoin _ = innerJoinLateral++instance ( DoInnerJoin lateral lhs rhs r, lateral ~ IsLateral rhs )+           => ToFrom (InnerJoin lhs rhs) r where+     toFrom (InnerJoin a b) = doInnerJoin (Proxy @lateral) a b++class DoLeftJoin lateral lhs rhs res | lateral rhs lhs -> res where+    doLeftJoin :: Proxy lateral -> lhs -> rhs -> From res++instance ( ToFrom a a'+         , ToFrom b b'+         , ToMaybe b'+         , ToMaybeT b' ~ mb+         , HasOnClause rhs (a' :& mb)+         , rhs ~ (b, (a' :& mb) -> SqlExpr (Value Bool))+         ) => DoLeftJoin NotLateral a rhs (a' :& mb) where+    doLeftJoin _ = leftJoin++instance ( ToFrom a a'+         , ToMaybe b+         , d ~ (a' :& ToMaybeT b)+         , SqlSelect b r+         , ToAlias b+         , ToAliasReference b+         ) => DoLeftJoin Lateral a (a' -> SqlQuery b, d -> SqlExpr (Value Bool)) d where+    doLeftJoin _ = leftJoinLateral++instance ( DoLeftJoin lateral lhs rhs r, lateral ~ IsLateral rhs )+           => ToFrom (LeftOuterJoin lhs rhs) r where+     toFrom (LeftOuterJoin a b) = doLeftJoin (Proxy @lateral) a b++class DoCrossJoin lateral lhs rhs res | lateral lhs rhs -> res where+    doCrossJoin :: Proxy lateral -> lhs -> rhs -> From res++instance (ToFrom a a', ToFrom b b') => DoCrossJoin NotLateral a b (a' :& b') where+    doCrossJoin _ = crossJoin+instance (ToFrom a a', SqlSelect b r, ToAlias b, ToAliasReference b)+  => DoCrossJoin Lateral a (a' -> SqlQuery b) (a' :& b) where+    doCrossJoin _ = crossJoinLateral++instance (DoCrossJoin lateral lhs rhs r, IsLateral rhs ~ lateral)+  => ToFrom (CrossJoin lhs rhs) r where+    toFrom (CrossJoin a b) = doCrossJoin (Proxy @lateral) a b++instance ( ToFrom a a'+         , ToFrom b b'+         , ToMaybe a'+         , ToMaybeT a' ~ ma+         , HasOnClause rhs (ma :& b')+         , ErrorOnLateral b+         , rhs ~ (b, (ma :& b') -> SqlExpr (Value Bool))+         ) => ToFrom (RightOuterJoin a rhs) (ma :& b') where+    toFrom (RightOuterJoin a b) = rightJoin a b++instance ( ToFrom a a'+         , ToFrom b b'+         , ToMaybe a'+         , ToMaybeT a' ~ ma+         , ToMaybe b'+         , ToMaybeT b' ~ mb+         , HasOnClause rhs (ma :& mb)+         , ErrorOnLateral b+         , rhs ~ (b, (ma :& mb) -> SqlExpr (Value Bool))+         ) => ToFrom (FullOuterJoin a rhs) (ma :& mb) where+    toFrom (FullOuterJoin a b) = fullOuterJoin a b+
+ src/Database/Esqueleto/Experimental/From/SqlSetOperation.hs view
@@ -0,0 +1,130 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE PatternSynonyms #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeApplications #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE UndecidableInstances #-}++module Database.Esqueleto.Experimental.From.SqlSetOperation+        where++import Control.Arrow (first)+import Control.Monad.Trans.Class (lift)+import qualified Control.Monad.Trans.State as S+import qualified Control.Monad.Trans.Writer as W+import qualified Data.Text.Lazy.Builder as TLB+import Database.Esqueleto.Experimental.From+import Database.Esqueleto.Experimental.ToAlias+import Database.Esqueleto.Experimental.ToAliasReference+import Database.Esqueleto.Internal.Internal hiding (From(..), from, on)+import Database.Esqueleto.Internal.PersistentImport (PersistValue)++-- | Data type used to implement the SqlSetOperation language+-- this type is implemented in the same way as a @From@+--+-- Semantically a @SqlSetOperation@ is always a @From@ but not vice versa+--+-- @since 3.5.0.0+newtype SqlSetOperation a = SqlSetOperation+    { unSqlSetOperation :: NeedParens -> SqlQuery (a, IdentInfo -> (TLB.Builder, [PersistValue]))}++instance ToAliasReference a => ToFrom (SqlSetOperation a) a where+    toFrom setOperation = From $ do+        ident <- newIdentFor (DBName "u")+        (a, fromClause) <- unSqlSetOperation setOperation Never+        ref <- toAliasReference ident a+        pure (ref, \_ info -> (first parens $ fromClause info) <> (" AS " <> useIdent info ident, mempty))++-- | Type class to support direct use of @SqlQuery@ in a set operation tree+--+-- @since 3.5.0.0+class ToSqlSetOperation a r | a -> r where+    toSqlSetOperation :: a -> SqlSetOperation r+instance ToSqlSetOperation (SqlSetOperation a) a where+    toSqlSetOperation = id+instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToSqlSetOperation (SqlQuery a) a where+    toSqlSetOperation subquery =+        SqlSetOperation $ \p -> do+            (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ subquery+            state <- Q $ lift S.get+            aliasedValue <- toAlias ret+            Q $ lift $ S.put state+            let aliasedQuery = Q $ W.WriterT $ pure (aliasedValue, sideData)+            let p' =+                  case p of+                    Parens -> Parens+                    Never ->+                      if (sdLimitClause sideData) /= mempty+                          || length (sdOrderByClause sideData) > 0 then+                        Parens+                      else+                        Never+            pure (aliasedValue, \info -> first (parensM p') $ toRawSql SELECT info aliasedQuery)++-- | Helper function for defining set operations+-- @since 3.5.0.0+mkSetOperation :: (ToSqlSetOperation a a', ToSqlSetOperation b a')+               => TLB.Builder -> a -> b -> SqlSetOperation a'+mkSetOperation operation lhs rhs = SqlSetOperation $ \p -> do+    (leftValue, leftClause) <- unSqlSetOperation (toSqlSetOperation lhs) p+    (_, rightClause) <- unSqlSetOperation (toSqlSetOperation rhs) p+    pure (leftValue, \info -> leftClause info <> (operation, mempty) <> rightClause info)++{-# DEPRECATED Union "/Since: 3.4.0.0/ - Use the 'union_' function instead of the 'Union' data constructor" #-}+data Union a b = a `Union` b+instance ToSqlSetOperation a a' => ToSqlSetOperation (Union a a) a' where+    toSqlSetOperation (Union a b) = union_ a b++-- | Overloaded @union_@ function to support use in both 'SqlSetOperation'+-- and 'withRecursive'+--+-- @since 3.5.0.0+class Union_ a where+    -- | @UNION@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.+    union_ :: a++instance (ToSqlSetOperation a c, ToSqlSetOperation b c, res ~ SqlSetOperation c)+  => Union_ (a -> b -> res) where+    union_ = mkSetOperation " UNION "++-- | Overloaded @unionAll_@ function to support use in both 'SqlSetOperation'+-- and 'withRecursive'+--+-- @since 3.5.0.0+class UnionAll_ a where+    -- | @UNION@ @ALL@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.+    unionAll_ :: a+instance (ToSqlSetOperation a c, ToSqlSetOperation b c, res ~ SqlSetOperation c)+  => UnionAll_ (a -> b -> res) where+    unionAll_ = mkSetOperation " UNION ALL "++{-# DEPRECATED UnionAll "/Since: 3.4.0.0/ - Use the 'unionAll_' function instead of the 'UnionAll' data constructor" #-}+data UnionAll a b = a `UnionAll` b+instance ToSqlSetOperation a a' => ToSqlSetOperation (UnionAll a a) a' where+    toSqlSetOperation (UnionAll a b) = unionAll_ a b++{-# DEPRECATED Except "/Since: 3.4.0.0/ - Use the 'except_' function instead of the 'Except' data constructor" #-}+data Except a b = a `Except` b+instance ToSqlSetOperation a a' => ToSqlSetOperation (Except a a) a' where+    toSqlSetOperation (Except a b) = except_ a b++-- | @EXCEPT@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.+except_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'+except_ = mkSetOperation " EXCEPT "++{-# DEPRECATED Intersect "/Since: 3.4.0.0/ - Use the 'intersect_' function instead of the 'Intersect' data constructor" #-}+data Intersect a b = a `Intersect` b+instance ToSqlSetOperation a a' => ToSqlSetOperation (Intersect a a) a' where+    toSqlSetOperation (Intersect a b) = intersect_ a b++-- | @INTERSECT@ SQL set operation. Can be used as an infix function between 'SqlQuery' values.+intersect_ :: (ToSqlSetOperation a a', ToSqlSetOperation b a') => a -> b -> SqlSetOperation a'+intersect_ = mkSetOperation " INTERSECT "++{-# DEPRECATED SelectQuery "/Since: 3.4.0.0/ - It is no longer necessary to tag 'SqlQuery' values with @SelectQuery@" #-}+pattern SelectQuery a = a+
+ src/Database/Esqueleto/Experimental/ToAlias.hs view
@@ -0,0 +1,92 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeFamilies #-}++module Database.Esqueleto.Experimental.ToAlias+    where++import Database.Esqueleto.Internal.Internal hiding (From, from, on)+import Database.Esqueleto.Internal.PersistentImport++{-# DEPRECATED ToAliasT "This type alias doesn't do anything. Please delete it. Will be removed in the next release." #-}+type ToAliasT a = a++-- Tedious tuple magic+class ToAlias a where+    toAlias :: a -> SqlQuery a++instance ToAlias (SqlExpr (Value a)) where+    toAlias e@(ERaw m f)+      | Just _ <- sqlExprMetaAlias m = pure e+      | otherwise = do+            ident <- newIdentFor (DBName "v")+            pure $ ERaw noMeta{sqlExprMetaAlias = Just ident} f++instance ToAlias (SqlExpr (Entity a)) where+    toAlias e@(ERaw m f)+      | Just _ <- sqlExprMetaAlias m = pure e+      | otherwise = do+           ident <- newIdentFor (DBName "v")+           pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f++instance ToAlias (SqlExpr (Maybe (Entity a))) where+    -- FIXME: Code duplication because the compiler doesnt like half final encoding+    toAlias e@(ERaw m f)+      | Just _ <- sqlExprMetaAlias m = pure e+      | otherwise = do+           ident <- newIdentFor (DBName "v")+           pure $ ERaw m{sqlExprMetaIsReference = False, sqlExprMetaAlias = Just ident} f++instance (ToAlias a, ToAlias b) => ToAlias (a,b) where+    toAlias (a,b) = (,) <$> toAlias a <*> toAlias b++instance ( ToAlias a+         , ToAlias b+         , ToAlias c+         ) => ToAlias (a,b,c) where+    toAlias x = to3 <$> (toAlias $ from3 x)++instance ( ToAlias a+         , ToAlias b+         , ToAlias c+         , ToAlias d+         ) => ToAlias (a,b,c,d) where+    toAlias x = to4 <$> (toAlias $ from4 x)++instance ( ToAlias a+         , ToAlias b+         , ToAlias c+         , ToAlias d+         , ToAlias e+         ) => ToAlias (a,b,c,d,e) where+    toAlias x = to5 <$> (toAlias $ from5 x)++instance ( ToAlias a+         , ToAlias b+         , ToAlias c+         , ToAlias d+         , ToAlias e+         , ToAlias f+         ) => ToAlias (a,b,c,d,e,f) where+    toAlias x = to6 <$> (toAlias $ from6 x)++instance ( ToAlias a+         , ToAlias b+         , ToAlias c+         , ToAlias d+         , ToAlias e+         , ToAlias f+         , ToAlias g+         ) => ToAlias (a,b,c,d,e,f,g) where+    toAlias x = to7 <$> (toAlias $ from7 x)++instance ( ToAlias a+         , ToAlias b+         , ToAlias c+         , ToAlias d+         , ToAlias e+         , ToAlias f+         , ToAlias g+         , ToAlias h+         ) => ToAlias (a,b,c,d,e,f,g,h) where+    toAlias x = to8 <$> (toAlias $ from8 x)
+ src/Database/Esqueleto/Experimental/ToAliasReference.hs view
@@ -0,0 +1,90 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TypeFamilies #-}++module Database.Esqueleto.Experimental.ToAliasReference+    where++import Data.Coerce+import Database.Esqueleto.Internal.Internal hiding (From, from, on)+import Database.Esqueleto.Internal.PersistentImport++{-# DEPRECATED ToAliasReferenceT "This type alias doesn't do anything. Please delete it. Will be removed in the next release." #-}+type ToAliasReferenceT a = a++-- more tedious tuple magic+class ToAliasReference a where+    toAliasReference :: Ident -> a -> SqlQuery a++instance ToAliasReference (SqlExpr (Value a)) where+    toAliasReference aliasSource (ERaw m _)+      | Just alias <- sqlExprMetaAlias m = pure $ ERaw m{sqlExprMetaIsReference = True} $ \_ info ->+          (useIdent info aliasSource <> "." <> useIdent info alias, [])+    toAliasReference _ e = pure e++instance ToAliasReference (SqlExpr (Entity a)) where+    toAliasReference aliasSource (ERaw m _)+      | Just _ <- sqlExprMetaAlias m =+          pure $ ERaw m{sqlExprMetaIsReference = True} $ \_ info ->+            (useIdent info aliasSource, [])+    toAliasReference _ e = pure e++instance ToAliasReference (SqlExpr (Maybe (Entity a))) where+    toAliasReference aliasSource e =+        coerce <$> toAliasReference aliasSource (coerce e :: SqlExpr (Entity a))+++instance (ToAliasReference a, ToAliasReference b) => ToAliasReference (a, b) where+    toAliasReference ident (a,b) = (,) <$> (toAliasReference ident a) <*> (toAliasReference ident b)++instance ( ToAliasReference a+         , ToAliasReference b+         , ToAliasReference c+         ) => ToAliasReference (a,b,c) where+    toAliasReference ident x = fmap to3 $ toAliasReference ident $ from3 x++instance ( ToAliasReference a+         , ToAliasReference b+         , ToAliasReference c+         , ToAliasReference d+         ) => ToAliasReference (a,b,c,d) where+    toAliasReference ident x = fmap to4 $ toAliasReference ident $ from4 x++instance ( ToAliasReference a+         , ToAliasReference b+         , ToAliasReference c+         , ToAliasReference d+         , ToAliasReference e+         ) => ToAliasReference (a,b,c,d,e) where+    toAliasReference ident x = fmap to5 $ toAliasReference ident $ from5 x++instance ( ToAliasReference a+         , ToAliasReference b+         , ToAliasReference c+         , ToAliasReference d+         , ToAliasReference e+         , ToAliasReference f+         ) => ToAliasReference (a,b,c,d,e,f) where+    toAliasReference ident x = to6 <$> (toAliasReference ident $ from6 x)++instance ( ToAliasReference a+         , ToAliasReference b+         , ToAliasReference c+         , ToAliasReference d+         , ToAliasReference e+         , ToAliasReference f+         , ToAliasReference g+         ) => ToAliasReference (a,b,c,d,e,f,g) where+    toAliasReference ident x = to7 <$> (toAliasReference ident $ from7 x)++instance ( ToAliasReference a+         , ToAliasReference b+         , ToAliasReference c+         , ToAliasReference d+         , ToAliasReference e+         , ToAliasReference f+         , ToAliasReference g+         , ToAliasReference h+         ) => ToAliasReference (a,b,c,d,e,f,g,h) where+    toAliasReference ident x = to8 <$> (toAliasReference ident $ from8 x)+
+ src/Database/Esqueleto/Experimental/ToMaybe.hs view
@@ -0,0 +1,79 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeFamilies #-}++module Database.Esqueleto.Experimental.ToMaybe+    where++import Database.Esqueleto.Internal.Internal hiding (From(..), from, on)+import Database.Esqueleto.Internal.PersistentImport (Entity(..))++type family Nullable a where+    Nullable (Maybe a) = a+    Nullable a =  a++class ToMaybe a where+    type ToMaybeT a+    toMaybe :: a -> ToMaybeT a++instance ToMaybe (SqlExpr (Maybe a)) where+    type ToMaybeT (SqlExpr (Maybe a)) = SqlExpr (Maybe a)+    toMaybe = id++instance ToMaybe (SqlExpr (Entity a)) where+    type ToMaybeT (SqlExpr (Entity a)) = SqlExpr (Maybe (Entity a))+    toMaybe (ERaw f m) = (ERaw f m)++instance ToMaybe (SqlExpr (Value a)) where+    type ToMaybeT (SqlExpr (Value a)) = SqlExpr (Value (Maybe (Nullable a)))+    toMaybe = veryUnsafeCoerceSqlExprValue+++instance (ToMaybe a, ToMaybe b) => ToMaybe (a,b) where+    type ToMaybeT (a, b) = (ToMaybeT a, ToMaybeT b)+    toMaybe (a, b) = (toMaybe a, toMaybe b)++instance ( ToMaybe a , ToMaybe b , ToMaybe c) => ToMaybe (a,b,c) where+    type ToMaybeT (a, b, c) = (ToMaybeT a, ToMaybeT b, ToMaybeT c)+    toMaybe = to3 . toMaybe . from3++instance ( ToMaybe a , ToMaybe b , ToMaybe c , ToMaybe d) => ToMaybe (a,b,c,d) where+    type ToMaybeT (a, b, c, d) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d)+    toMaybe = to4 . toMaybe . from4++instance ( ToMaybe a , ToMaybe b , ToMaybe c , ToMaybe d , ToMaybe e) => ToMaybe (a,b,c,d,e) where+    type ToMaybeT (a, b, c, d, e) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e)+    toMaybe = to5 . toMaybe . from5++instance ( ToMaybe a+         , ToMaybe b+         , ToMaybe c+         , ToMaybe d+         , ToMaybe e+         , ToMaybe f+         ) => ToMaybe (a,b,c,d,e,f) where+    type ToMaybeT (a, b, c, d, e, f) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e, ToMaybeT f)+    toMaybe = to6 . toMaybe . from6++instance ( ToMaybe a+         , ToMaybe b+         , ToMaybe c+         , ToMaybe d+         , ToMaybe e+         , ToMaybe f+         , ToMaybe g+         ) => ToMaybe (a,b,c,d,e,f,g) where+    type ToMaybeT (a, b, c, d, e, f, g) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e, ToMaybeT f, ToMaybeT g)+    toMaybe = to7 . toMaybe . from7++instance ( ToMaybe a+         , ToMaybe b+         , ToMaybe c+         , ToMaybe d+         , ToMaybe e+         , ToMaybe f+         , ToMaybe g+         , ToMaybe h+         ) => ToMaybe (a,b,c,d,e,f,g,h) where+     type ToMaybeT (a, b, c, d, e, f, g, h) = (ToMaybeT a, ToMaybeT b, ToMaybeT c, ToMaybeT d, ToMaybeT e, ToMaybeT f, ToMaybeT g, ToMaybeT h)+     toMaybe = to8 . toMaybe . from8+
src/Database/Esqueleto/Internal/Internal.hs view
@@ -65,12 +65,12 @@ import Database.Persist.Sql.Util        ( entityColumnCount        , keyAndEntityColumnNames-       , hasNaturalKey        , isIdField        , parseEntityValues        ) import Text.Blaze.Html (Html) import Data.Coerce (coerce)+import Data.Kind (Type)  -- | (Internal) Start a 'from' query with an entity. 'from' -- does two kinds of magic using 'fromStart', 'fromJoin' and@@ -90,13 +90,13 @@     ( PersistEntity a     , BackendCompatible SqlBackend (PersistEntityBackend a)     )-    => SqlQuery (SqlExpr (PreprocessedFrom (SqlExpr (Entity a))))+    => SqlQuery (PreprocessedFrom (SqlExpr (Entity a))) fromStart = do     let ed = entityDef (Proxy :: Proxy a)     ident <- newIdentFor (coerce $ getEntityDBName ed)-    let ret = EEntity ident+    let ret = unsafeSqlEntity ident         f' = FromStart ident ed-    return (EPreprocessedFrom ret f')+    return (PreprocessedFrom ret f')  -- | Copied from @persistent@ newtype DBName = DBName { unDBName :: T.Text }@@ -106,22 +106,22 @@     :: ( PersistEntity a        , BackendCompatible SqlBackend (PersistEntityBackend a)        )-    => SqlQuery (SqlExpr (PreprocessedFrom (SqlExpr (Maybe (Entity a)))))+    => SqlQuery (PreprocessedFrom (SqlExpr (Maybe (Entity a)))) fromStartMaybe = maybelize <$> fromStart   where     maybelize-        :: SqlExpr (PreprocessedFrom (SqlExpr (Entity a)))-        -> SqlExpr (PreprocessedFrom (SqlExpr (Maybe (Entity a))))-    maybelize (EPreprocessedFrom ret f') = EPreprocessedFrom (EMaybe ret) f'+        :: PreprocessedFrom (SqlExpr (Entity a))+        -> PreprocessedFrom (SqlExpr (Maybe (Entity a)))+    maybelize (PreprocessedFrom e f') = PreprocessedFrom (coerce e) f'  -- | (Internal) Do a @JOIN@. fromJoin     :: IsJoinKind join-    => SqlExpr (PreprocessedFrom a)-    -> SqlExpr (PreprocessedFrom b)-    -> SqlQuery (SqlExpr (PreprocessedFrom (join a b)))-fromJoin (EPreprocessedFrom lhsRet lhsFrom)-         (EPreprocessedFrom rhsRet rhsFrom) = Q $ do+    => PreprocessedFrom a+    -> PreprocessedFrom b+    -> SqlQuery (PreprocessedFrom (join a b))+fromJoin (PreprocessedFrom lhsRet lhsFrom)+         (PreprocessedFrom rhsRet rhsFrom) = Q $ do     let ret = smartJoin lhsRet rhsRet         from' =             FromJoin@@ -129,13 +129,13 @@                 (reifyJoinKind ret) -- JOIN                 rhsFrom             -- RHS                 Nothing             -- ON-    return (EPreprocessedFrom ret from')+    return (PreprocessedFrom ret from')  -- | (Internal) Finish a @JOIN@. fromFinish-  :: SqlExpr (PreprocessedFrom a)+  :: PreprocessedFrom a   -> SqlQuery a-fromFinish (EPreprocessedFrom ret f') = Q $ do+fromFinish (PreprocessedFrom ret f') = Q $ do     W.tell mempty { sdFromClause = [f'] }     return ret @@ -259,12 +259,23 @@  -- | Ascending order of this field or SqlExpression. asc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy-asc  = EOrderBy ASC+asc = orderByExpr " ASC"  -- | Descending order of this field or SqlExpression. desc :: PersistField a => SqlExpr (Value a) -> SqlExpr OrderBy-desc = EOrderBy DESC+desc = orderByExpr " DESC" +orderByExpr :: TLB.Builder -> SqlExpr (Value a) -> SqlExpr OrderBy+orderByExpr orderByType (ERaw m f)+  | Just fields <- sqlExprMetaCompositeFields m =+        ERaw noMeta $ \_ info ->+            let fs = fields info+                vals = repeat []+            in uncommas' $ zip (map (<> orderByType) fs) vals+  | otherwise =+      ERaw noMeta $ \_ info ->+          first (<> orderByType) $ f Never info+ -- | @LIMIT@.  Limit the number of returned rows. limit :: Int64 -> SqlQuery () limit  n = Q $ W.tell mempty { sdLimitClause = Limit (Just n) Nothing  }@@ -335,7 +346,7 @@ -- -- @since 2.2.4 don :: SqlExpr (Value a) -> SqlExpr DistinctOn-don = EDistinctOn+don = coerce  -- | A convenience function that calls both 'distinctOn' and -- 'orderBy'.  In other words,@@ -361,15 +372,15 @@         act   where     toDistinctOn :: SqlExpr OrderBy -> SqlExpr DistinctOn-    toDistinctOn (EOrderBy _ f) = EDistinctOn f-    toDistinctOn EOrderRandom =-        error "We can't select distinct by a random order!"+    toDistinctOn (ERaw m f) = ERaw m $ \p info ->+        let (b, vals) = f p info+        in (TLB.fromLazyText $ head $ TL.splitOn " " $ TLB.toLazyText b, vals)  -- | @ORDER BY random()@ clause. -- -- @since 1.3.10 rand :: SqlExpr OrderBy-rand = EOrderRandom+rand = ERaw noMeta $ \_ _ -> ("RANDOM()", [])  -- | @HAVING@. --@@ -531,13 +542,16 @@ subSelectUnsafe = sub SELECT  -- | Project a field of an entity.-(^.)-    :: forall typ val. (PersistEntity val, PersistField typ)+(^.) :: forall typ val . (PersistEntity val, PersistField typ)     => SqlExpr (Entity val)     -> EntityField val typ     -> SqlExpr (Value typ)-(EAliasedEntityReference source base) ^. field =-    EValueReference source (\_ -> aliasedEntityColumnIdent base fieldDef)+ERaw m f ^. field+    | isIdField field = idFieldValue+    | Just alias <- sqlExprMetaAlias m =+        ERaw noMeta $ \_ info ->+            f Never info <> ("." <> useIdent info (aliasedEntityColumnIdent alias fieldDef), [])+    | otherwise = ERaw noMeta $ \_ info -> (dot info $ persistFieldDef field, [])   where     fieldDef =         if isIdField field then@@ -545,48 +559,27 @@             NEL.head $ getEntityKeyFields ed         else             persistFieldDef field--    ed = entityDef $ getEntityVal (Proxy :: Proxy (SqlExpr (Entity val)))--e ^. field-    | isIdField field = idFieldValue-    | otherwise = ERaw Never $ \info -> (dot info $ persistFieldDef field, [])-  where     idFieldValue =         case getEntityKeyFields ed of             idField :| [] ->-                ERaw Never    $ \info -> (dot info idField, [])+                ERaw noMeta $ \_ info -> (dot info idField, [])              idFields ->-                ECompositeKey $ \info ->  NEL.toList $ dot info <$> idFields-+                let renderedFields info = dot info <$> NEL.toList idFields+                in ERaw noMeta{ sqlExprMetaCompositeFields = Just renderedFields} $+                    \p info -> (parensM p $ uncommas $ renderedFields info, [])      ed = entityDef $ getEntityVal (Proxy :: Proxy (SqlExpr (Entity val))) -    dot info fieldDef =-        useIdent info sourceIdent <> "." <> fieldIdent+    dot info fieldDef' =+        sourceIdent info <> "." <> fieldIdent       where-        sourceIdent =-            case e of-                EEntity ident -> ident-                EAliasedEntity baseI _ -> baseI-                EAliasedEntityReference a b ->-                    error $ unwords-                        [ "Used (^.) with an EAliasedEntityReference."-                        , "Please file this as an Esqueleto bug."-                        , "EAliasedEntityReference", show a, show b-                        ]-        fieldIdent =-            case e of-                EEntity _ -> fromDBName info (coerce $ fieldDB fieldDef)-                EAliasedEntity baseI _ -> useIdent info $ aliasedEntityColumnIdent baseI fieldDef-                EAliasedEntityReference a b ->-                    error $ unwords-                        [ "Used (^.) with an EAliasedEntityReference."-                        , "Please file this as an Esqueleto bug."-                        , "EAliasedEntityReference", show a, show b-                        ]-+        sourceIdent = fmap fst $ f Never+        fieldIdent+            | Just baseI <- sqlExprMetaAlias m =+                useIdent info $ aliasedEntityColumnIdent baseI fieldDef'+            | otherwise =+                fromDBName info (coerce $ fieldDB fieldDef')  -- | Project an SqlExpression that may be null, guarding against null cases. withNonNull@@ -599,16 +592,15 @@     f $ veryUnsafeCoerceSqlExprValue field  -- | Project a field of an entity that may be null.-(?.)-    :: (PersistEntity val, PersistField typ)+(?.) :: ( PersistEntity val , PersistField typ)     => SqlExpr (Maybe (Entity val))     -> EntityField val typ     -> SqlExpr (Value (Maybe typ))-EMaybe r ?. field = just (r ^. field)+ERaw m f ?. field = just (ERaw m f ^. field)  -- | Lift a constant value from Haskell-land to the query. val  :: PersistField typ => typ -> SqlExpr (Value typ)-val v = ERaw Never $ const ("?", [toPersistValue v])+val v = ERaw noMeta $ \_ _ -> ("?", [toPersistValue v])  -- | @IS NULL@ comparison. --@@ -634,27 +626,23 @@ isNothing :: PersistField typ => SqlExpr (Value (Maybe typ)) -> SqlExpr (Value Bool) isNothing v =     case v of-        ERaw p f ->-            isNullExpr $ first (parensM p) . f-        EAliasedValue i _ ->-            isNullExpr $ aliasedValueIdentToRawSql i-        EValueReference i i' ->-            isNullExpr $ valueReferenceToRawSql i i'-        ECompositeKey f ->-            ERaw Parens $ flip (,) [] . (intersperseB " AND " . map (<> " IS NULL")) . f+        ERaw m f ->+            case sqlExprMetaCompositeFields m of+                Just fields ->+                    ERaw noMeta $ \p info ->+                        first (parensM p) . flip (,) [] . (intersperseB " AND " . map (<> " IS NULL")) $ fields info+                Nothing ->+                    ERaw noMeta $ \p info ->+                        first (parensM p) . isNullExpr $ f Never info   where-    isNullExpr :: (IdentInfo -> (TLB.Builder, [PersistValue])) -> SqlExpr (Value Bool)-    isNullExpr g = ERaw Parens $ first ((<> " IS NULL")) . g+    isNullExpr :: (TLB.Builder, a) -> (TLB.Builder, a)+    isNullExpr = first ((<> " IS NULL"))  -- | Analogous to 'Just', promotes a value of type @typ@ into -- one of type @Maybe typ@.  It should hold that @'val' . Just -- === just . 'val'@. just :: SqlExpr (Value typ) -> SqlExpr (Value (Maybe typ))-just exprVal = case exprVal of-    ERaw p f -> ERaw p f-    ECompositeKey f -> ECompositeKey f-    EAliasedValue i v -> EAliasedValue i (just v)-    EValueReference i i' -> EValueReference i i'+just = veryUnsafeCoerceSqlExprValue  -- | @NULL@ value. nothing :: SqlExpr (Value (Maybe typ))@@ -663,23 +651,20 @@ -- | Join nested 'Maybe's in a 'Value' into one. This is useful when -- calling aggregate functions on nullable fields. joinV :: SqlExpr (Value (Maybe (Maybe typ))) -> SqlExpr (Value (Maybe typ))-joinV exprMM = case exprMM of-    ERaw p f -> ERaw p f-    ECompositeKey f -> ECompositeKey f-    EAliasedValue i v -> EAliasedValue i (joinV v)-    EValueReference i i' -> EValueReference i i'+joinV = veryUnsafeCoerceSqlExprValue   countHelper :: Num a => TLB.Builder -> TLB.Builder -> SqlExpr (Value typ) -> SqlExpr (Value a) countHelper open close v =     case v of-        ERaw _ f -> countRawSql f-        EAliasedValue i _ -> countRawSql $ aliasedValueIdentToRawSql i-        EValueReference i i' -> countRawSql $ valueReferenceToRawSql i i'-        ECompositeKey _ -> countRows+        ERaw meta f ->+            if hasCompositeKeyMeta meta then+                countRows+            else+                countRawSql (f Never)   where     countRawSql :: (IdentInfo -> (TLB.Builder, [PersistValue])) -> SqlExpr (Value a)-    countRawSql x = ERaw Never $ first (\b -> "COUNT" <> open <> parens b <> close) . x+    countRawSql x = ERaw noMeta $ \_ -> first (\b -> "COUNT" <> open <> parens b <> close) . x  -- | @COUNT(*)@ value. countRows :: Num a => SqlExpr (Value a)@@ -696,19 +681,16 @@ countDistinct = countHelper "(DISTINCT " ")"  not_ :: SqlExpr (Value Bool) -> SqlExpr (Value Bool)-not_ v = ERaw Never (\info -> first ("NOT " <>) $ x info)+not_ v = ERaw noMeta $ \p info -> first ("NOT " <>) $ x p info   where-    x info =+    x p info =         case v of-            ERaw p f ->-                let (b, vals) = f info-                in (parensM p b, vals)-            ECompositeKey _      ->-                throw (CompositeKeyErr NotError)-            EAliasedValue i _    ->-                aliasedValueIdentToRawSql i info-            EValueReference i i' ->-                valueReferenceToRawSql i i' info+            ERaw m f ->+                if hasCompositeKeyMeta m then+                    throw (CompositeKeyErr NotError)+                else+                    let (b, vals) = f Never info+                    in (parensM p b, vals)  (==.) :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (Value typ) -> SqlExpr (Value Bool) (==.) = unsafeSqlBinOpComposite " = " " AND "@@ -905,13 +887,13 @@ -- | Execute a subquery @SELECT@ in an SqlExpression.  Returns a -- list of values. subList_select :: PersistField a => SqlQuery (SqlExpr (Value a)) -> SqlExpr (ValueList a)-subList_select         = EList . sub_select+subList_select query = ERaw noMeta $ \_ info -> first parens $ toRawSql SELECT info query + -- | Lift a list of constant value from Haskell-land to the query. valList :: PersistField typ => [typ] -> SqlExpr (ValueList typ)-valList []   = EEmptyList-valList vals = EList $ ERaw Parens $ const ( uncommas ("?" <$ vals)-                                           , map toPersistValue vals )+valList []   = ERaw noMeta $ \_ _ -> ("()", [])+valList vals = ERaw noMeta $ \p -> const (parensM p (uncommas ("?" <$ vals)), map toPersistValue vals )  -- | Same as 'just' but for 'ValueList'.  Most of the time you -- won't need it, though, because you can use 'just' from@@ -919,8 +901,7 @@ -- -- @since 2.2.12 justList :: SqlExpr (ValueList typ) -> SqlExpr (ValueList (Maybe typ))-justList EEmptyList = EEmptyList-justList (EList v)  = EList (just v)+justList (ERaw m f) = ERaw m f  -- | @IN@ operator. For example if you want to select all @Person@s by a list -- of IDs:@@ -942,11 +923,23 @@ -- -- Where @personIds@ is of type @[Key Person]@. in_ :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)-v `in_`   e = ifNotEmptyList e False $ unsafeSqlBinOp     " IN " v (veryUnsafeCoerceSqlExprValueList e)+(ERaw _ v) `in_` (ERaw _ list) =+    ERaw noMeta $ \_ info ->+        let (b1, vals1) = v Parens info+            (b2, vals2) = list Parens info+        in+        if b2 == "()" then+            ("FALSE", [])+        else+            (b1 <> " IN " <> b2, vals1 <> vals2)  -- | @NOT IN@ operator. notIn :: PersistField typ => SqlExpr (Value typ) -> SqlExpr (ValueList typ) -> SqlExpr (Value Bool)-v `notIn` e = ifNotEmptyList e True  $ unsafeSqlBinOp " NOT IN " v (veryUnsafeCoerceSqlExprValueList e)+(ERaw _ v) `notIn` (ERaw _ list) =+    ERaw noMeta $ \_ info ->+        let (b1, vals1) = v Parens info+            (b2, vals2) = list Parens info+        in (b1 <> " NOT IN " <> b2, vals1 <> vals2)  -- | @EXISTS@ operator.  For example: --@@ -959,58 +952,52 @@ -- return person -- @ exists :: SqlQuery () -> SqlExpr (Value Bool)-exists    = unsafeSqlFunction     "EXISTS " . existsHelper+exists q = ERaw noMeta $ \p info ->+    let ERaw _ f = existsHelper q+        (b, vals) = f Never info+    in ( parensM p $ "EXISTS " <> b, vals)  -- | @NOT EXISTS@ operator. notExists :: SqlQuery () -> SqlExpr (Value Bool)-notExists = unsafeSqlFunction "NOT EXISTS " . existsHelper+notExists q = ERaw noMeta $ \p info ->+    let ERaw _ f = existsHelper q+        (b, vals) = f Never info+    in ( parensM p $ "NOT EXISTS " <> b, vals)  -- | @SET@ clause used on @UPDATE@s.  Note that while it's not -- a type error to use this function on a @SELECT@, it will -- most certainly result in a runtime error.-set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Update val)] -> SqlQuery ()+set :: PersistEntity val => SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update] -> SqlQuery () set ent upds = Q $ W.tell mempty { sdSetClause = map apply upds }   where-    apply (ESet f) = SetClause (f ent)+    apply f = SetClause (f ent) -(=.)  :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> SqlExpr (Update val)+(=.)  :: (PersistEntity val, PersistField typ) => EntityField val typ -> SqlExpr (Value typ) -> (SqlExpr (Entity val) -> SqlExpr Update ) field  =. expr = setAux field (const expr) -(+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)+(+=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> (SqlExpr (Entity val) -> SqlExpr Update) field +=. expr = setAux field (\ent -> ent ^. field +. expr) -(-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)+(-=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> (SqlExpr (Entity val) -> SqlExpr Update) field -=. expr = setAux field (\ent -> ent ^. field -. expr) -(*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)+(*=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> (SqlExpr (Entity val) -> SqlExpr Update) field *=. expr = setAux field (\ent -> ent ^. field *. expr) -(/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> SqlExpr (Update val)+(/=.) :: (PersistEntity val, PersistField a) => EntityField val a -> SqlExpr (Value a) -> (SqlExpr (Entity val) -> SqlExpr Update) field /=. expr = setAux field (\ent -> ent ^. field /. expr)  -- | Apply a 'PersistField' constructor to @SqlExpr Value@ arguments. (<#) :: (a -> b) -> SqlExpr (Value a) -> SqlExpr (Insertion b)-(<#) _ (ERaw _ f)        = EInsert Proxy f-(<#) _ (ECompositeKey _) = throw (CompositeKeyErr ToInsertionError)-(<#) _ (EAliasedValue i _) = EInsert Proxy $ aliasedValueIdentToRawSql i-(<#) _ (EValueReference i i') = EInsert Proxy $ valueReferenceToRawSql i i'-+(<#) _ (ERaw _ f)        = ERaw noMeta f  -- | Apply extra @SqlExpr Value@ arguments to a 'PersistField' constructor (<&>) :: SqlExpr (Insertion (a -> b)) -> SqlExpr (Value a) -> SqlExpr (Insertion b)-(EInsert _ f) <&> v =-    EInsert Proxy $ \x ->-        let (fb, fv) = f x-            (gb, gv) = g x-        in-            (fb <> ", " <> gb, fv ++ gv)-  where-    g =-        case v of-            ERaw _ f' -> f'-            EAliasedValue i _ -> aliasedValueIdentToRawSql i-            EValueReference i i' -> valueReferenceToRawSql i i'-            ECompositeKey _ -> throw (CompositeKeyErr CombineInsertionError)+(ERaw _ f) <&> (ERaw _ g) =+    ERaw noMeta $ \_ info ->+        let (fb, fv) = f Never info+            (gb, gv) = g Never info+        in (fb <> ", " <> gb, fv ++ gv)  -- | @CASE@ statement.  For example: --@@ -1300,18 +1287,15 @@ renderUpdates     :: (BackendCompatible SqlBackend backend)     => backend-    -> [SqlExpr (Update val)]+    -> [SqlExpr (Entity val) -> SqlExpr Update]     -> (TLB.Builder, [PersistValue]) renderUpdates conn = uncommas' . concatMap renderUpdate   where-    mk :: SqlExpr (Value ()) -> [(TLB.Builder, [PersistValue])]-    mk (ERaw _ f)             = [f info]-    mk (ECompositeKey _)      = throw (CompositeKeyErr MakeSetError) -- FIXME-    mk (EAliasedValue i _)    = [aliasedValueIdentToRawSql i info]-    mk (EValueReference i i') = [valueReferenceToRawSql i i' info]+    mk :: SqlExpr Update -> [(TLB.Builder, [PersistValue])]+    mk (ERaw _ f)             = [f Never info] -    renderUpdate :: SqlExpr (Update val) -> [(TLB.Builder, [PersistValue])]-    renderUpdate (ESet f) = mk (f undefined) -- second parameter of f is always unused+    renderUpdate :: (SqlExpr (Entity val) -> SqlExpr Update) -> [(TLB.Builder, [PersistValue])]+    renderUpdate f = mk (f undefined) -- second parameter of f is always unused     info = (projectBackend conn, initialIdentState)  -- | Data type that represents an @INNER JOIN@ (see 'LeftOuterJoin' for an example).@@ -1390,9 +1374,6 @@  instance Exception OnClauseWithoutMatchingJoinException --- | (Internal) Phantom type used to process 'from' (see 'fromStart').-data PreprocessedFrom a- -- | Phantom type used by 'orderBy', 'asc' and 'desc'. data OrderBy @@ -1401,7 +1382,7 @@  -- | Phantom type for a @SET@ operation on an entity of the given -- type (see 'set' and '(=.)').-data Update typ+data Update  -- | Phantom type used by 'insertSelect'. data Insertion a@@ -1467,7 +1448,7 @@ -- key on a query into another (cf. 'toBaseId'). class ToBaseId ent where     -- | e.g. @type BaseEnt MyBase = MyChild@-    type BaseEnt ent :: *+    type BaseEnt ent :: Type     -- | Convert from the key of the BaseEnt(ity) to the key of the child entity.     -- This function is not actually called, but that it typechecks proves this operation is safe.     toBaseIdWitness :: Key (BaseEnt ent) -> Key ent@@ -1634,7 +1615,7 @@ -- | (Internal) Class that implements the @JOIN@ 'from' magic -- (see 'fromStart'). class FromPreprocess a where-    fromPreprocess :: SqlQuery (SqlExpr (PreprocessedFrom a))+    fromPreprocess :: SqlQuery (PreprocessedFrom a)  instance     (PersistEntity val, BackendCompatible SqlBackend (PersistEntityBackend val))@@ -1764,8 +1745,7 @@     = FromStart Ident EntityDef     | FromJoin FromClause JoinKind FromClause (Maybe (SqlExpr (Value Bool)))     | OnClause (SqlExpr (Value Bool))-    | FromQuery Ident (IdentInfo -> (TLB.Builder, [PersistValue])) SubQueryType-    | FromIdent Ident+    | FromRaw (NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue]))  data CommonTableExpressionKind     = RecursiveCommonTableExpression@@ -1785,8 +1765,7 @@     FromStart i _ -> Set.singleton i     FromJoin lhs _ rhs _ -> collectIdents lhs <> collectIdents rhs     OnClause _ -> mempty-    FromQuery _ _ _ -> mempty-    FromIdent _ -> mempty+    FromRaw _ -> mempty  instance Show FromClause where     show fc = case fc of@@ -1808,10 +1787,8 @@             ]         OnClause expr ->             "(OnClause " <> render' expr <> ")"-        FromQuery ident _ subQueryType ->-            "(FromQuery " <> show ident <> " " <> show subQueryType <> ")"-        FromIdent ident ->-            "(FromIdent " <> show ident <> ")"+        FromRaw _ ->+            "(FromRaw _)"        where         dummy = mkSqlBackend MkSqlBackendArgs@@ -1820,7 +1797,7 @@         render' = T.unpack . renderExpr dummy  -- | A part of a @SET@ clause.-newtype SetClause = SetClause (SqlExpr (Value ()))+newtype SetClause = SetClause (SqlExpr Update)  -- | Collect 'OnClause's on 'FromJoin's.  Returns the first -- unmatched 'OnClause's data on error.  Returns a list without@@ -1865,14 +1842,12 @@     findRightmostIdent (FromStart i _) = Just i     findRightmostIdent (FromJoin _ _ r _) = findRightmostIdent r     findRightmostIdent (OnClause {}) = Nothing-    findRightmostIdent (FromQuery _ _ _) = Nothing-    findRightmostIdent (FromIdent _) = Nothing+    findRightmostIdent (FromRaw _) = Nothing      findLeftmostIdent (FromStart i _) = Just i     findLeftmostIdent (FromJoin l _ _ _) = findLeftmostIdent l     findLeftmostIdent (OnClause {}) = Nothing-    findLeftmostIdent (FromQuery _ _ _) = Nothing-    findLeftmostIdent (FromIdent _) = Nothing+    findLeftmostIdent (FromRaw _) = Nothing      tryMatch         :: Set Ident@@ -2023,135 +1998,88 @@ useIdent :: IdentInfo -> Ident -> TLB.Builder useIdent info (I ident) = fromDBName info $ DBName ident +data SqlExprMeta = SqlExprMeta+    { -- A composite key.+      --+      -- Persistent uses the same 'PersistList' constructor for both+      -- fields which are (homogeneous) lists of values and the+      -- (probably heterogeneous) values of a composite primary key.+      --+      -- We need to treat composite keys as fields.  For example, we+      -- have to support using ==., otherwise you wouldn't be able to+      -- join.  OTOH, lists of values should be treated exactly the+      -- same as any other scalar value.+      --+      -- In particular, this is valid for persistent via rawSql for+      -- an F field that is a list:+      --+      --   A.F in ?    -- [PersistList [foo, bar]]+      --+      -- However, this is not for a composite key entity:+      --+      --   A.ID = ?    -- [PersistList [foo, bar]]+      --+      -- The ID field doesn't exist on the DB for a composite key+      -- table, it exists only on the Haskell side.  Those variations+      -- also don't work:+      --+      --   (A.KeyA, A.KeyB) = ?    -- [PersistList [foo, bar]]+      --   [A.KeyA, A.KeyB] = ?    -- [PersistList [foo, bar]]+      --+      -- We have to generate:+      --+      --   A.KeyA = ? AND A.KeyB = ?      -- [foo, bar]+      --+      -- Note that the PersistList had to be deconstructed into its+      -- components.+      --+      -- In order to disambiguate behaviors, this constructor is used+      -- /only/ to represent a composite field access.  It does not+      -- represent a 'PersistList', not even if the 'PersistList' is+      -- used in the context of a composite key.  That's because it's+      -- impossible, e.g., for 'val' to disambiguate between these+      -- uses.+      sqlExprMetaCompositeFields :: Maybe (IdentInfo -> [TLB.Builder])+    , sqlExprMetaAlias :: Maybe Ident -- Alias ident if this is an aliased value/entity+    , sqlExprMetaIsReference :: Bool -- Is this SqlExpr a reference to the selected value/entity (supports subqueries)+    }++-- | Empty 'SqlExprMeta' if you are constructing an 'ERaw' probably use this+-- for your meta+noMeta :: SqlExprMeta+noMeta = SqlExprMeta+    { sqlExprMetaCompositeFields = Nothing+    , sqlExprMetaAlias = Nothing+    , sqlExprMetaIsReference = False+    }++-- | Does this meta contain values for composite fields.+-- This field is field out for composite key values+hasCompositeKeyMeta :: SqlExprMeta -> Bool+hasCompositeKeyMeta = Maybe.isJust . sqlExprMetaCompositeFields+ entityAsValue     :: SqlExpr (Entity val)     -> SqlExpr (Value (Entity val))-entityAsValue eent =-    case eent of-        EEntity ident ->-            identToRaw ident-        EAliasedEntity ident _ ->-            identToRaw ident-        EAliasedEntityReference _ ident ->-            identToRaw ident-  where-    identToRaw ident =-        ERaw Never $ \identInfo ->-            ( useIdent identInfo ident-            , []-            )+entityAsValue = coerce  entityAsValueMaybe     :: SqlExpr (Maybe (Entity val))     -> SqlExpr (Value (Maybe (Entity val)))-entityAsValueMaybe (EMaybe eent) =-    case eent of-        EEntity ident ->-            identToRaw ident-        EAliasedEntity ident _ ->-            identToRaw ident-        EAliasedEntityReference _ ident ->-            identToRaw ident-  where-    identToRaw ident =-        ERaw Never $ \identInfo ->-            ( useIdent identInfo ident-            , []-            )-+entityAsValueMaybe = coerce  -- | An expression on the SQL backend. ----- There are many comments describing the constructors of this--- data type.  However, Haddock doesn't like GADTs, so you'll have to read them by hitting \"Source\".-data SqlExpr a where-    -- An entity, created by 'from' (cf. 'fromStart').-    EEntity  :: Ident -> SqlExpr (Entity val)-    --                Base     Table-    EAliasedEntity :: Ident -> Ident -> SqlExpr (Entity val)-    --                         Source   Base-    EAliasedEntityReference :: Ident -> Ident -> SqlExpr (Entity val)--    -- Just a tag stating that something is nullable.-    EMaybe   :: SqlExpr a -> SqlExpr (Maybe a)--    -- Raw expression: states whether parenthesis are needed-    -- around this expression, and takes information about the SQL-    -- connection (mainly for escaping names) and returns both an-    -- string ('TLB.Builder') and a list of values to be-    -- interpolated by the SQL backend.-    ERaw     :: NeedParens -> (IdentInfo -> (TLB.Builder, [PersistValue])) -> SqlExpr (Value a)---    -- A raw expression with an alias-    EAliasedValue :: Ident -> SqlExpr (Value a) -> SqlExpr (Value a)--    -- A reference to an aliased field in a table or subquery-    EValueReference :: Ident -> (IdentInfo -> Ident) -> SqlExpr (Value a)--    -- A composite key.-    ---    -- Persistent uses the same 'PersistList' constructor for both-    -- fields which are (homogeneous) lists of values and the-    -- (probably heterogeneous) values of a composite primary key.-    ---    -- We need to treat composite keys as fields.  For example, we-    -- have to support using ==., otherwise you wouldn't be able to-    -- join.  OTOH, lists of values should be treated exactly the-    -- same as any other scalar value.-    ---    -- In particular, this is valid for persistent via rawSql for-    -- an F field that is a list:-    ---    --   A.F in ?    -- [PersistList [foo, bar]]-    ---    -- However, this is not for a composite key entity:-    ---    --   A.ID = ?    -- [PersistList [foo, bar]]-    ---    -- The ID field doesn't exist on the DB for a composite key-    -- table, it exists only on the Haskell side.  Those variations-    -- also don't work:-    ---    --   (A.KeyA, A.KeyB) = ?    -- [PersistList [foo, bar]]-    --   [A.KeyA, A.KeyB] = ?    -- [PersistList [foo, bar]]-    ---    -- We have to generate:-    ---    --   A.KeyA = ? AND A.KeyB = ?      -- [foo, bar]-    ---    -- Note that the PersistList had to be deconstructed into its-    -- components.-    ---    -- In order to disambiguate behaviors, this constructor is used-    -- /only/ to represent a composite field access.  It does not-    -- represent a 'PersistList', not even if the 'PersistList' is-    -- used in the context of a composite key.  That's because it's-    -- impossible, e.g., for 'val' to disambiguate between these-    -- uses.-    ECompositeKey :: (IdentInfo -> [TLB.Builder]) -> SqlExpr (Value a)--    -- 'EList' and 'EEmptyList' are used by list operators.-    EList      :: SqlExpr (Value a) -> SqlExpr (ValueList a)-    EEmptyList :: SqlExpr (ValueList a)--    -- A 'SqlExpr' accepted only by 'orderBy'.-    EOrderBy :: OrderByType -> SqlExpr (Value a) -> SqlExpr OrderBy--    EOrderRandom :: SqlExpr OrderBy--    -- A 'SqlExpr' accepted only by 'distinctOn'.-    EDistinctOn :: SqlExpr (Value a) -> SqlExpr DistinctOn--    -- A 'SqlExpr' accepted only by 'set'.-    ESet :: (SqlExpr (Entity val) -> SqlExpr (Value ())) -> SqlExpr (Update val)--    -- An internal 'SqlExpr' used by the 'from' hack.-    EPreprocessedFrom :: a -> FromClause -> SqlExpr (PreprocessedFrom a)+-- Raw expression: Contains a 'SqlExprMeta' and a function for+-- building the expr. It recieves a parameter telling it whether+-- it is in a parenthesized context, and takes information about the SQL+-- connection (mainly for escaping names) and returns both an+-- string ('TLB.Builder') and a list of values to be+-- interpolated by the SQL backend.+data SqlExpr a = ERaw SqlExprMeta (NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue])) -    -- Used by 'insertSelect'.-    EInsert  :: Proxy a -> (IdentInfo -> (TLB.Builder, [PersistValue])) -> SqlExpr (Insertion a)-    EInsertFinal :: PersistEntity a => SqlExpr (Insertion a) -> SqlExpr InsertFinal+-- | Data type to support from hack+data PreprocessedFrom a = PreprocessedFrom a FromClause  -- | Phantom type used to mark a @INSERT INTO@ query. data InsertFinal@@ -2178,13 +2106,14 @@     :: (PersistEntity val, PersistField typ)     => EntityField val typ     -> (SqlExpr (Entity val) -> SqlExpr (Value typ))-    -> SqlExpr (Update val)-setAux field mkVal = ESet $ \ent -> unsafeSqlBinOp " = " name (mkVal ent)-  where-    name = ERaw Never $ \info -> (fieldName info field, mempty)+    -> (SqlExpr (Entity val) -> SqlExpr Update)+setAux field value = \ent -> ERaw noMeta $ \_ info ->+    let ERaw _ valueF = value ent+        (valueToSet, valueVals) = valueF Parens info+    in (fieldName info field <> " = " <> valueToSet, valueVals)  sub :: PersistField a => Mode -> SqlQuery (SqlExpr (Value a)) -> SqlExpr (Value a)-sub mode query = ERaw Parens $ \info -> toRawSql mode info query+sub mode query = ERaw noMeta $ \_ info -> first parens $ toRawSql mode info query  fromDBName :: IdentInfo -> DBName -> TLB.Builder fromDBName (conn, _) = TLB.fromText . flip getEscapedRawName conn . unDBName@@ -2192,47 +2121,34 @@ existsHelper :: SqlQuery () -> SqlExpr (Value Bool) existsHelper = sub SELECT . (>> return true)   where-    true :: SqlExpr (Value Bool)+    true  :: SqlExpr (Value Bool)     true = val True -ifNotEmptyList :: SqlExpr (ValueList a) -> Bool -> SqlExpr (Value Bool) -> SqlExpr (Value Bool)-ifNotEmptyList EEmptyList b _ = val b-ifNotEmptyList (EList _)  _ x = x- -- | (Internal) Create a case statement. -- -- Since: 2.1.1 unsafeSqlCase :: PersistField a => [(SqlExpr (Value Bool), SqlExpr (Value a))] -> SqlExpr (Value a) -> SqlExpr (Value a)-unsafeSqlCase when v = ERaw Never buildCase+unsafeSqlCase when v = ERaw noMeta buildCase   where-    buildCase :: IdentInfo -> (TLB.Builder, [PersistValue])-    buildCase info =-        let (elseText, elseVals) = valueToRawSqlParens SqlCaseError v info-            (whenText, whenVals) = mapWhen when info+    buildCase :: NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue])+    buildCase _ info =+        let (elseText, elseVals) = valueToSql v Parens info+            (whenText, whenVals) = mapWhen when Parens info         in ( "CASE" <> whenText <> " ELSE " <> elseText <> " END", whenVals <> elseVals) -    mapWhen :: [(SqlExpr (Value Bool), SqlExpr (Value a))] -> IdentInfo -> (TLB.Builder, [PersistValue])-    mapWhen []    _    = throw (UnexpectedCaseErr UnsafeSqlCaseError)-    mapWhen when' info = foldl (foldHelp info) (mempty, mempty) when'+    mapWhen :: [(SqlExpr (Value Bool), SqlExpr (Value a))] -> NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue])+    mapWhen []    _ _    = throw (UnexpectedCaseErr UnsafeSqlCaseError)+    mapWhen when' p info = foldl (foldHelp p info) (mempty, mempty) when' -    foldHelp :: IdentInfo -> (TLB.Builder, [PersistValue]) -> (SqlExpr (Value Bool), SqlExpr (Value a)) -> (TLB.Builder, [PersistValue])-    foldHelp _ _ (ECompositeKey _, _) = throw (CompositeKeyErr FoldHelpError)-    foldHelp _ _ (_, ECompositeKey _) = throw (CompositeKeyErr FoldHelpError)-    foldHelp info (b0, vals0) (v1, v2) =-        let (b1, vals1) = valueToRawSqlParens SqlCaseError v1 info-            (b2, vals2) = valueToRawSqlParens SqlCaseError v2 info++    foldHelp :: NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue]) -> (SqlExpr (Value Bool), SqlExpr (Value a)) -> (TLB.Builder, [PersistValue])+    foldHelp p info (b0, vals0) (v1, v2) =+        let (b1, vals1) = valueToSql v1 p info+            (b2, vals2) = valueToSql v2 p info         in ( b0 <> " WHEN " <> b1 <> " THEN " <> b2, vals0 <> vals1 <> vals2 ) --- | (Internal) Convert a value to a raw SQL builder, preserving parens around--- 'ERaw' SQL expressions. This is useful for turning values into function or--- operator arguments.------ Since: 3.4.0.2-valueToRawSqlParens :: UnexpectedValueError -> SqlExpr (Value a) -> IdentInfo -> (TLB.Builder, [PersistValue])-valueToRawSqlParens _ (ERaw p f) = (first (parensM p)) . f-valueToRawSqlParens e (ECompositeKey _) = throw (CompositeKeyErr e)-valueToRawSqlParens _ (EAliasedValue i _) = aliasedValueIdentToRawSql i-valueToRawSqlParens _ (EValueReference i i') = valueReferenceToRawSql i i'+    valueToSql :: SqlExpr (Value a) -> NeedParens -> IdentInfo -> (TLB.Builder, [PersistValue])+    valueToSql (ERaw _ f) p = f p  -- | (Internal) Create a custom binary operator.  You /should/ -- /not/ use this function directly since its type is very@@ -2247,32 +2163,31 @@ -- In the example above, we constraint the arguments to be of the -- same type and constraint the result to be a boolean value. unsafeSqlBinOp :: TLB.Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c)-unsafeSqlBinOp op (ERaw p1 f1) (ERaw p2 f2) = ERaw Parens f+unsafeSqlBinOp op (ERaw m1 f1) (ERaw m2 f2)+  | not (hasCompositeKeyMeta m1 || hasCompositeKeyMeta m2) = ERaw noMeta f   where-    f info =-        let (b1, vals1) = f1 info-            (b2, vals2) = f2 info+    f p info =+        let (b1, vals1) = f1 Parens info+            (b2, vals2) = f2 Parens info         in-            ( parensM p1 b1 <> op <> parensM p2 b2+            ( parensM p (b1 <> op <> b2)             , vals1 <> vals2             ) unsafeSqlBinOp op a b = unsafeSqlBinOp op (construct a) (construct b)   where     construct :: SqlExpr (Value a) -> SqlExpr (Value a)-    construct (ERaw p f) =-        ERaw (if p == Never then Parens else Never) $ \info ->-            let (b1, vals) = f info-                build ("?", [PersistList vals']) =-                    (uncommas $ replicate (length vals') "?", vals')-                build expr = expr-             in-                build (parensM p b1, vals)-    construct (ECompositeKey f) =-        ERaw Parens $ \info -> (uncommas $ f info, mempty)-    construct (EAliasedValue i _) =-        ERaw Never $ aliasedValueIdentToRawSql i-    construct (EValueReference i i') =-        ERaw Never $ valueReferenceToRawSql i i'+    construct (ERaw m f) =+        case sqlExprMetaCompositeFields m of+            Just fields ->+                ERaw noMeta $ \_ info -> (parens $ uncommas $ fields info, mempty)+            Nothing ->+                ERaw noMeta $ \p info ->+                    let (b1, vals) = f (if p == Never then Parens else Never) info+                        build ("?", [PersistList vals']) =+                            (uncommas $ replicate (length vals') "?", vals')+                        build expr = expr+                     in+                        first (parensM p) $ build (b1, vals) {-# INLINE unsafeSqlBinOp #-}  -- | Similar to 'unsafeSqlBinOp', but may also be applied to@@ -2300,18 +2215,16 @@ --   no placeholders and split it on the commas. unsafeSqlBinOpComposite :: TLB.Builder -> TLB.Builder -> SqlExpr (Value a) -> SqlExpr (Value b) -> SqlExpr (Value c) unsafeSqlBinOpComposite op sep a b-    | isCompositeKey a || isCompositeKey b = ERaw Parens $ compose (listify a) (listify b)+    | isCompositeKey a || isCompositeKey b = ERaw noMeta $ const $ compose (listify a) (listify b)     | otherwise = unsafeSqlBinOp op a b   where     isCompositeKey :: SqlExpr (Value x) -> Bool-    isCompositeKey (ECompositeKey _) = True-    isCompositeKey _ = False+    isCompositeKey (ERaw m _) = hasCompositeKeyMeta m      listify :: SqlExpr (Value x) -> IdentInfo -> ([TLB.Builder], [PersistValue])-    listify (ECompositeKey f)      = flip (,) [] . f-    listify (ERaw _ f)             = deconstruct . f-    listify (EAliasedValue i _)    = deconstruct . (aliasedValueIdentToRawSql i)-    listify (EValueReference i i') = deconstruct . (valueReferenceToRawSql i i')+    listify (ERaw m f)+        | Just k <- sqlExprMetaCompositeFields m = flip (,) [] . k+        | otherwise = deconstruct . f Parens      deconstruct :: (TLB.Builder, [PersistValue]) -> ([TLB.Builder], [PersistValue])     deconstruct ("?", [PersistList vals]) = (replicate (length vals) "?", vals)@@ -2328,19 +2241,19 @@         bc = intersperseB sep [x <> op <> y | (x, y) <- zip b1 b2]         vc = v1 <> v2 + -- | (Internal) A raw SQL value.  The same warning from -- 'unsafeSqlBinOp' applies to this function as well. unsafeSqlValue :: TLB.Builder -> SqlExpr (Value a)-unsafeSqlValue v = ERaw Never $ const (v, mempty)+unsafeSqlValue v = ERaw noMeta $ \_ _ -> (v, mempty) {-# INLINE unsafeSqlValue #-} +unsafeSqlEntity :: PersistEntity ent => Ident -> SqlExpr (Entity ent)+unsafeSqlEntity ident = ERaw noMeta $ \_ info ->+    (useIdent info ident, [])+ valueToFunctionArg :: IdentInfo -> SqlExpr (Value a) -> (TLB.Builder, [PersistValue])-valueToFunctionArg info v =-    case v of-        ERaw _ f             -> f info-        EAliasedValue i _    -> aliasedValueIdentToRawSql i info-        EValueReference i i' -> valueReferenceToRawSql i i' info-        ECompositeKey _      -> throw (CompositeKeyErr SqlFunctionError)+valueToFunctionArg info (ERaw _ f) = f Never info  -- | (Internal) A raw SQL function.  Once again, the same warning -- from 'unsafeSqlBinOp' applies to this function as well.@@ -2348,7 +2261,7 @@     :: UnsafeSqlFunctionArgument a     => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlFunction name arg =-    ERaw Never $ \info ->+    ERaw noMeta $ \_ info ->         let (argsTLB, argsVals) =               uncommas' $ map (valueToFunctionArg info) $ toArgList arg         in@@ -2362,7 +2275,7 @@     :: UnsafeSqlFunctionArgument a     => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlExtractSubField subField arg =-    ERaw Never $ \info ->+    ERaw noMeta $ \_ info ->         let (argsTLB, argsVals) =                 uncommas' $ map (valueToFunctionArg info) $ toArgList arg         in@@ -2374,25 +2287,16 @@     :: UnsafeSqlFunctionArgument a     => TLB.Builder -> a -> SqlExpr (Value b) unsafeSqlFunctionParens name arg =-    ERaw Never $ \info ->-        let (argsTLB, argsVals) =-                uncommas' $ map (\v -> valueToRawSqlParens SqlFunctionError v info) $ toArgList arg-        in-            (name <> parens argsTLB, argsVals)+    ERaw noMeta $ \_ info ->+        let valueToFunctionArgParens (ERaw _ f) = f Never info+            (argsTLB, argsVals) =+                uncommas' $ map valueToFunctionArgParens $ toArgList arg+        in (name <> parens argsTLB, argsVals)  -- | (Internal) An explicit SQL type cast using CAST(value as type). -- See 'unsafeSqlBinOp' for warnings. unsafeSqlCastAs :: T.Text -> SqlExpr (Value a) -> SqlExpr (Value b)-unsafeSqlCastAs t v = ERaw Never ((first (\value -> "CAST" <> parens (value <> " AS " <> TLB.fromText t))) . valueToText)-  where-    valueToText info =-        case v of-            (ERaw p f) ->-              let (b, vals) = f info-              in (parensM p b, vals)-            EAliasedValue i _ -> aliasedValueIdentToRawSql i info-            EValueReference i i' -> valueReferenceToRawSql i i' info-            ECompositeKey _ -> throw (CompositeKeyErr SqlCastAsError)+unsafeSqlCastAs t (ERaw _ f) = ERaw noMeta $ \_ -> ((first (\value -> "CAST" <> parens (value <> " AS " <> TLB.fromText t))) . f Never)  -- | (Internal) This class allows 'unsafeSqlFunction' to work with different -- numbers of arguments; specifically it allows providing arguments to a sql@@ -2523,17 +2427,13 @@ -- 'SqlExpr (Value b)'.  You should /not/ use this function -- unless you know what you're doing! veryUnsafeCoerceSqlExprValue :: SqlExpr (Value a) -> SqlExpr (Value b)-veryUnsafeCoerceSqlExprValue (ERaw p f)             = ERaw p f-veryUnsafeCoerceSqlExprValue (ECompositeKey f)      = ECompositeKey f-veryUnsafeCoerceSqlExprValue (EAliasedValue i v)    = EAliasedValue i (veryUnsafeCoerceSqlExprValue v)-veryUnsafeCoerceSqlExprValue (EValueReference i i') = EValueReference i i'+veryUnsafeCoerceSqlExprValue = coerce   -- | (Internal) Coerce a value's type from 'SqlExpr (ValueList -- a)' to 'SqlExpr (Value a)'.  Does not work with empty lists. veryUnsafeCoerceSqlExprValueList :: SqlExpr (ValueList a) -> SqlExpr (Value a)-veryUnsafeCoerceSqlExprValueList (EList v)  = v-veryUnsafeCoerceSqlExprValueList EEmptyList = throw (UnexpectedCaseErr EmptySqlExprValueList)+veryUnsafeCoerceSqlExprValueList = coerce   ----------------------------------------------------------------------@@ -2685,14 +2585,14 @@     :: (MonadIO m)     => SqlQuery ()     -> SqlWriteT m ()-delete = void . deleteCount+delete a = void $ deleteCount a  -- | Same as 'delete', but returns the number of rows affected. deleteCount     :: (MonadIO m)     => SqlQuery ()     -> SqlWriteT m Int64-deleteCount = rawEsqueleto DELETE+deleteCount a = rawEsqueleto DELETE a  -- | Execute an @esqueleto@ @UPDATE@ query inside @persistent@'s -- 'SqlPersistT' monad.  Note that currently there are no type@@ -2713,7 +2613,7 @@     )     => (SqlExpr (Entity val) -> SqlQuery ())     -> SqlWriteT m ()-update = void . updateCount+update a = void $ updateCount a  -- | Same as 'update', but returns the number of rows affected. updateCount@@ -2723,11 +2623,12 @@     )     => (SqlExpr (Entity val) -> SqlQuery ())     -> SqlWriteT m Int64-updateCount = rawEsqueleto UPDATE . from+updateCount a = rawEsqueleto UPDATE $ from a  builderToText :: TLB.Builder -> T.Text builderToText = TL.toStrict . TLB.toLazyTextWith defaultChunkSize   where+    defaultChunkSize :: Int     defaultChunkSize = 1024 - 32  -- | (Internal) Pretty prints a 'SqlQuery' into a SQL query.@@ -2769,7 +2670,7 @@         , makeGroupBy    info groupByClause         , makeHaving     info havingClause         , makeOrderBy    info orderByClauses-        , makeLimit      info limitClause orderByClauses+        , makeLimit      info limitClause         , makeLocking         lockingClause         ] @@ -2903,7 +2804,7 @@                 first (("SELECT DISTINCT ON (" <>) . (<> ") "))                 $ uncommas' (processExpr <$> exprs)       where-        processExpr (EDistinctOn f) = materializeExpr info f+        processExpr e = materializeExpr info (coerce e :: SqlExpr (Value a))     withCols v = v <> sqlSelectCols info ret     plain    v = (v, []) @@ -2933,18 +2834,7 @@                 , maybe mempty makeOnClause monClause                 ]     mk _ (OnClause _) = throw (UnexpectedCaseErr MakeFromError)-    mk _ (FromQuery ident f subqueryType) =-        let (queryText, queryVals) = f info-            lateralKeyword =-              case subqueryType of-                NormalSubQuery -> ""-                LateralSubQuery -> "LATERAL "-        in-            ( lateralKeyword <> (parens queryText) <> " AS " <> useIdent info ident-            , queryVals-            )-    mk _ (FromIdent ident) =-        (useIdent info ident, mempty)+    mk paren (FromRaw f) = f paren info      base ident@(I identText) def =         let db@(DBName dbText) = coerce $ getEntityDBName def@@ -2961,38 +2851,22 @@     fromKind RightOuterJoinKind = " RIGHT OUTER JOIN "     fromKind FullOuterJoinKind  = " FULL OUTER JOIN " -    makeOnClause (ERaw _ f)        = first (" ON " <>) (f info)-    makeOnClause (ECompositeKey _) = throw (CompositeKeyErr MakeOnClauseError)-    makeOnClause (EAliasedValue _ _) = throw (AliasedValueErr MakeOnClauseError)-    makeOnClause (EValueReference _ _) = throw (AliasedValueErr MakeOnClauseError)+    makeOnClause (ERaw _ f)        = first (" ON " <>) (f Never info)      mkExc :: SqlExpr (Value Bool) -> OnClauseWithoutMatchingJoinException     mkExc (ERaw _ f) =         OnClauseWithoutMatchingJoinException $-            TL.unpack $ TLB.toLazyText $ fst (f info)-    mkExc (ECompositeKey _) = throw (CompositeKeyErr MakeExcError)-    mkExc (EAliasedValue _ _) = throw (AliasedValueErr MakeExcError)-    mkExc (EValueReference _ _) = throw (AliasedValueErr MakeExcError)+            TL.unpack $ TLB.toLazyText $ fst (f Never info)  makeSet :: IdentInfo -> [SetClause] -> (TLB.Builder, [PersistValue]) makeSet _    [] = mempty makeSet info os = first ("\nSET " <>) . uncommas' $ concatMap mk os   where-    mk (SetClause (ERaw _ f))             = [f info]-    mk (SetClause (ECompositeKey _))      = throw (CompositeKeyErr MakeSetError) -- FIXME-    mk (SetClause (EAliasedValue i _))    = [aliasedValueIdentToRawSql i info]-    mk (SetClause (EValueReference i i')) = [valueReferenceToRawSql i i' info]+    mk (SetClause (ERaw _ f))             = [f Never info]  makeWhere :: IdentInfo -> WhereClause -> (TLB.Builder, [PersistValue])-makeWhere _    NoWhere                       = mempty-makeWhere info (Where v) = first ("\nWHERE " <>) $ x info-  where-    x =-        case v of-            ERaw _ f             -> f-            EAliasedValue i _    -> aliasedValueIdentToRawSql i-            EValueReference i i' -> valueReferenceToRawSql i i'-            ECompositeKey _      -> throw (CompositeKeyErr MakeWhereError)+makeWhere _    NoWhere            = mempty+makeWhere info (Where (ERaw _ f)) = first ("\nWHERE " <>) $ f Never info  makeGroupBy :: IdentInfo -> GroupByClause -> (TLB.Builder, [PersistValue]) makeGroupBy _ (GroupBy []) = (mempty, [])@@ -3002,21 +2876,11 @@     build = uncommas' $ map match fields      match :: SomeValue -> (TLB.Builder, [PersistValue])-    match (SomeValue (ERaw _ f)) = f info-    match (SomeValue (ECompositeKey f)) = (uncommas $ f info, mempty)-    match (SomeValue (EAliasedValue i _)) = aliasedValueIdentToRawSql i info-    match (SomeValue (EValueReference i i')) = valueReferenceToRawSql i i' info+    match (SomeValue (ERaw _ f)) = f Never info  makeHaving :: IdentInfo -> WhereClause -> (TLB.Builder, [PersistValue]) makeHaving _    NoWhere   = mempty-makeHaving info (Where v) = first ("\nHAVING " <>) $ x info-  where-    x =-        case v of-            ERaw _ f             -> f-            EAliasedValue i _    -> aliasedValueIdentToRawSql i-            EValueReference i i' -> valueReferenceToRawSql i i'-            ECompositeKey _      -> throw (CompositeKeyErr MakeHavingError)+makeHaving info (Where (ERaw _ f)) = first ("\nHAVING " <>) $ f Never info  -- makeHaving, makeWhere and makeOrderBy makeOrderByNoNewline@@ -3025,22 +2889,7 @@ makeOrderByNoNewline info os = first ("ORDER BY " <>) . uncommas' $ concatMap mk os   where     mk :: OrderByClause -> [(TLB.Builder, [PersistValue])]-    mk (EOrderBy t (ECompositeKey f)) =-        let fs = f info-            vals = repeat []-        in zip (map (<> orderByType t) fs) vals-    mk (EOrderBy t v) =-        let x =-                case v of-                    ERaw p f -> (first (parensM p)) . f-                    EAliasedValue i _ -> aliasedValueIdentToRawSql i-                    EValueReference i i' -> valueReferenceToRawSql i i'-                    ECompositeKey _ -> undefined -- defined above-        in [ first (<> orderByType t) $ x info ]-    mk EOrderRandom = [first (<> "RANDOM()") mempty]--    orderByType ASC  = " ASC"-    orderByType DESC = " DESC"+    mk (ERaw _ f) = [f Never info]  makeOrderBy :: IdentInfo -> [OrderByClause] -> (TLB.Builder, [PersistValue]) makeOrderBy _ [] = mempty@@ -3048,11 +2897,10 @@     let (tlb, vals) = makeOrderByNoNewline info is     in ("\n" <> tlb, vals) -{-# DEPRECATED EOrderRandom "Since 2.6.0: `rand` ordering function is not uniform across all databases! To avoid accidental partiality it will be removed in the next major version." #-}--makeLimit :: IdentInfo -> LimitClause -> [OrderByClause] -> (TLB.Builder, [PersistValue])-makeLimit (conn, _) (Limit ml mo) orderByClauses =+makeLimit :: IdentInfo -> LimitClause -> (TLB.Builder, [PersistValue])+makeLimit (conn, _) (Limit ml mo) =     let limitRaw = getConnLimitOffset (v ml, v mo) "\n" conn+        v :: Maybe Int64 -> Int         v = maybe 0 fromIntegral     in (TLB.fromText limitRaw, mempty) @@ -3067,13 +2915,6 @@ parens :: TLB.Builder -> TLB.Builder parens b = "(" <> (b <> ")") -aliasedValueIdentToRawSql :: Ident -> IdentInfo -> (TLB.Builder, [PersistValue])-aliasedValueIdentToRawSql i info = (useIdent info i, mempty)--valueReferenceToRawSql ::  Ident -> (IdentInfo -> Ident) -> IdentInfo -> (TLB.Builder, [PersistValue])-valueReferenceToRawSql sourceIdent columnIdentF info =-    (useIdent info sourceIdent <> "." <> useIdent info (columnIdentF info), mempty)- aliasedEntityColumnIdent :: Ident -> FieldDef -> Ident aliasedEntityColumnIdent (I baseIdent) field =     I (baseIdent <> "_" <> (unDBName $ coerce $ fieldDB field))@@ -3106,18 +2947,22 @@   -- | @INSERT INTO@ hack.-instance SqlSelect (SqlExpr InsertFinal) InsertFinal where-    sqlInsertInto info (EInsertFinal (EInsert p _)) =+instance PersistEntity e => SqlSelect (SqlExpr (Insertion e)) (Insertion e) where+    sqlInsertInto info e =         let fields =                 uncommas $                 map (fromDBName info . coerce . fieldDB) $                 getEntityFields $-                entityDef p+                entityDef (proxy e)++            proxy :: SqlExpr (Insertion a) -> Proxy a+            proxy = const Proxy+             table  =-                fromDBName info . DBName . coerce . getEntityDBName . entityDef $ p+                fromDBName info . DBName . coerce . getEntityDBName . entityDef . proxy         in-            ("INSERT INTO " <> table <> parens fields <> "\n", [])-    sqlSelectCols info (EInsertFinal (EInsert _ f)) = f info+            ("INSERT INTO " <> table e <> parens fields <> "\n", [])+    sqlSelectCols info (ERaw _ f) = f Never info     sqlSelectColCount   = const 0     sqlSelectProcessRow =       const (Right (throw (UnexpectedCaseErr InsertionFinalError)))@@ -3143,39 +2988,38 @@  -- | You may return an 'Entity' from a 'select' query. instance PersistEntity a => SqlSelect (SqlExpr (Entity a)) (Entity a) where-    sqlSelectCols info expr@(EEntity ident) = ret-      where-        process ed =-            uncommas-            $ map ((name <>) . TLB.fromText)-            $ NEL.toList-            $ keyAndEntityColumnNames ed (fst info)-        -- 'name' is the biggest difference between 'RawSql' and-        -- 'SqlSelect'.  We automatically create names for tables-        -- (since it's not the user who's writing the FROM-        -- clause), while 'rawSql' assumes that it's just the-        -- name of the table (which doesn't allow self-joins, for-        -- example).-        name = useIdent info ident <> "."-        ret = let ed = entityDef $ getEntityVal $ return expr-              in (process ed, mempty)-    sqlSelectCols info expr@(EAliasedEntity aliasIdent tableIdent) = ret-      where-        process ed = uncommas $-                     map ((name <>) . aliasName) $-                     unescapedColumnNames ed-        aliasName columnName = (fromDBName info columnName) <> " AS " <> aliasedColumnName aliasIdent info (unDBName columnName)-        name = useIdent info tableIdent <> "."-        ret = let ed = entityDef $ getEntityVal $ return expr-              in (process ed, mempty)-    sqlSelectCols info expr@(EAliasedEntityReference sourceIdent baseIdent) = ret-      where-        process ed = uncommas $-                     map ((name <>) . aliasedColumnName baseIdent info . unDBName) $-                     unescapedColumnNames ed-        name = useIdent info sourceIdent <> "."-        ret = let ed = entityDef $ getEntityVal $ return expr-              in (process ed, mempty)+    sqlSelectCols info expr@(ERaw m f)+      | Just baseIdent <- sqlExprMetaAlias m, False <- sqlExprMetaIsReference m =+          let process = uncommas $+                           map ((name <>) . aliasName) $+                           unescapedColumnNames ed+              aliasName columnName = (fromDBName info columnName) <> " AS " <> aliasedColumnName baseIdent info (unDBName columnName)+              name = fst (f Never info) <> "."+              ed = entityDef $ getEntityVal $ return expr+          in (process, mempty)+      | Just baseIdent <- sqlExprMetaAlias m, True <- sqlExprMetaIsReference m =+          let process = uncommas $+                           map ((name <>) . aliasedColumnName baseIdent info . unDBName) $+                           unescapedColumnNames ed+              name = fst (f Never info) <> "."+              ed = entityDef $ getEntityVal $ return expr+          in (process, mempty)+      | otherwise =+          let process =+                  uncommas+                  $ map ((name <>) . TLB.fromText)+                  $ NEL.toList+                  $ keyAndEntityColumnNames ed (fst info)+              -- 'name' is the biggest difference between 'RawSql' and+              -- 'SqlSelect'.  We automatically create names for tables+              -- (since it's not the user who's writing the FROM+              -- clause), while 'rawSql' assumes that it's just the+              -- name of the table (which doesn't allow self-joins, for+              -- example).+              name = fst (f Never info) <> "."+              ed = entityDef $ getEntityVal $ return expr+          in (process, mempty)+     sqlSelectColCount = entityColumnCount . entityDef . getEntityVal     sqlSelectProcessRow = parseEntityValues ed       where@@ -3186,7 +3030,7 @@  -- | You may return a possibly-@NULL@ 'Entity' from a 'select' query. instance PersistEntity a => SqlSelect (SqlExpr (Maybe (Entity a))) (Maybe (Entity a)) where-    sqlSelectCols info (EMaybe ent) = sqlSelectCols info ent+    sqlSelectCols info e = sqlSelectCols info (coerce e :: SqlExpr (Entity a))     sqlSelectColCount = sqlSelectColCount . fromEMaybe       where         fromEMaybe :: Proxy (SqlExpr (Maybe e)) -> Proxy (SqlExpr e)@@ -3206,18 +3050,13 @@  -- | Materialize a @SqlExpr (Value a)@. materializeExpr :: IdentInfo -> SqlExpr (Value a) -> (TLB.Builder, [PersistValue])-materializeExpr info (ERaw p f) =-    let (b, vals) = f info-    in (parensM p b, vals)-materializeExpr info (ECompositeKey f) =-    let bs = f info-    in (uncommas $ map (parensM Parens) bs, [])-materializeExpr info (EAliasedValue ident x) =-    let (b, vals) = materializeExpr info x-    in (b <> " AS " <> (useIdent info ident), vals)-materializeExpr info (EValueReference sourceIdent columnIdent) =-    valueReferenceToRawSql sourceIdent columnIdent info+materializeExpr info (ERaw m f)+    | Just fields <- sqlExprMetaCompositeFields m = (uncommas $ fmap parens $ fields info, [])+    | Just alias <- sqlExprMetaAlias m+    , not (sqlExprMetaIsReference m) = first (<> " AS " <> useIdent info alias) (f Parens info)+    | otherwise = f Parens info + -- | You may return tuples (up to 16-tuples) and tuples of tuples -- from a 'select' query. instance (SqlSelect a ra, SqlSelect b rb) => SqlSelect (a, b) (ra, rb) where@@ -3724,14 +3563,14 @@     :: (MonadIO m, PersistEntity a)     => SqlQuery (SqlExpr (Insertion a))     -> SqlWriteT m ()-insertSelect = void . insertSelectCount+insertSelect a = void $ insertSelectCount a  -- | Insert a 'PersistField' for every selected value, return the count afterward insertSelectCount     :: (MonadIO m, PersistEntity a)     => SqlQuery (SqlExpr (Insertion a))     -> SqlWriteT m Int64-insertSelectCount = rawEsqueleto INSERT_INTO . fmap EInsertFinal+insertSelectCount a = rawEsqueleto INSERT_INTO a  -- | Renders an expression into 'Text'. Only useful for creating a textual -- representation of the clauses passed to an "On" clause.@@ -3739,20 +3578,8 @@ -- @since 3.2.0 renderExpr :: SqlBackend -> SqlExpr (Value Bool) -> T.Text renderExpr sqlBackend e = case e of-    ERaw _ mkBuilderValues -> do-        let (builder, _) = mkBuilderValues (sqlBackend, initialIdentState)-         in (builderToText builder)-    ECompositeKey mkInfo ->-        throw-          . RenderExprUnexpectedECompositeKey-          . builderToText-          . mconcat-          . mkInfo-          $ (sqlBackend, initialIdentState)-    EAliasedValue i _   ->-        builderToText $ useIdent (sqlBackend, initialIdentState) i-    EValueReference i i' ->-        let (builder, _) = valueReferenceToRawSql i i' (sqlBackend, initialIdentState)+    ERaw _ mkBuilderValues ->+         let (builder, _) = mkBuilderValues Never (sqlBackend, initialIdentState)          in (builderToText builder)  -- | An exception thrown by 'RenderExpr' - it's not designed to handle composite
− src/Database/Esqueleto/Internal/Language.hs
@@ -1,140 +0,0 @@-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE EmptyDataDecls #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}---- | This is an internal module, anything exported by this module--- may change without a major version bump.  Please use only--- "Database.Esqueleto" if possible.------ This module is deprecated as of 3.4.0.1, and will be removed in 3.5.0.0.-module Database.Esqueleto.Internal.Language-    {-# DEPRECATED "Use Database.Esqueleto.Internal.Internal instead. This module will be removed in 3.5.0.0 " #-}-    ( -- * The pretty face-      from-    , Value(..)-    , ValueList(..)-    , SomeValue(..)-    , ToSomeValues(..)-    , InnerJoin(..)-    , CrossJoin(..)-    , LeftOuterJoin(..)-    , RightOuterJoin(..)-    , FullOuterJoin(..)-    , OnClauseWithoutMatchingJoinException(..)-    , OrderBy-    , DistinctOn-    , Update-    , Insertion-    , LockingKind(..)-    , SqlString-    , ToBaseId(..)-      -- * The guts-    , JoinKind(..)-    , IsJoinKind(..)-    , BackendCompatible(..)-    , PreprocessedFrom-    , From-    , FromPreprocess-    , when_-    , then_-    , else_-    , where_-    , on-    , groupBy-    , orderBy-    , rand-    , asc-    , desc-    , limit-    , offset-    , distinct-    , distinctOn-    , don-    , distinctOnOrderBy-    , having-    , locking-    , sub_select-    , (^.)-    , (?.)-    , val-    , isNothing-    , just-    , nothing-    , joinV-    , withNonNull-    , countRows-    , count-    , countDistinct-    , not_-    , (==.)-    , (>=.)-    , (>.)-    , (<=.)-    , (<.)-    , (!=.)-    , (&&.)-    , (||.)-    , between-    , (+.)-    , (-.)-    , (/.)-    , (*.)-    , random_-    , round_-    , ceiling_-    , floor_-    , min_-    , max_-    , sum_-    , avg_-    , castNum-    , castNumM-    , coalesce-    , coalesceDefault-    , lower_-    , upper_-    , trim_-    , ltrim_-    , rtrim_-    , length_-    , left_-    , right_-    , like-    , ilike-    , (%)-    , concat_-    , (++.)-    , castString-    , subList_select-    , valList-    , justList-    , in_-    , notIn-    , exists-    , notExists-    , set-    , (=.)-    , (+=.)-    , (-=.)-    , (*=.)-    , (/=.)-    , case_-    , toBaseId-    , (<#)-    , (<&>)-    , subSelect-    , subSelectMaybe-    , subSelectCount-    , subSelectList-    , subSelectForeign-    , subSelectUnsafe-    ) where--import Database.Esqueleto.Internal.Internal-import Database.Esqueleto.Internal.PersistentImport
src/Database/Esqueleto/Internal/PersistentImport.hs view
@@ -138,7 +138,6 @@     , getEntityId     , getEntityDBName     , getEntityUniques-    , getEntityDBName     ) where  import Database.Persist.Sql hiding
− src/Database/Esqueleto/Internal/Sql.hs
@@ -1,78 +0,0 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE DeriveDataTypeable #-}-{-# LANGUAGE EmptyDataDecls #-}-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE GADTs #-}-{-# LANGUAGE InstanceSigs #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE Rank2Types #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE UndecidableInstances #-}----- | This is an internal module, anything exported by this module--- may change without a major version bump.  Please use only--- "Database.Esqueleto" if possible.------ This module is deprecated as of 3.4.0.1, and will be removed in 3.5.0.0.-module Database.Esqueleto.Internal.Sql-    {-# DEPRECATED "Use Database.Esqueleto.Internal.Internal instead. This module will be removed in 3.5.0.0 " #-}-    ( -- * The pretty face-      SqlQuery-    , SqlExpr(..)-    , SqlEntity-    , select-    , selectSource-    , delete-    , deleteCount-    , update-    , updateCount-    , insertSelect-    , insertSelectCount-      -- * The guts-    , unsafeSqlCase-    , unsafeSqlBinOp-    , unsafeSqlBinOpComposite-    , unsafeSqlValue-    , unsafeSqlCastAs-    , unsafeSqlFunction-    , unsafeSqlExtractSubField-    , UnsafeSqlFunctionArgument-    , OrderByClause-    , rawSelectSource-    , runSource-    , rawEsqueleto-    , toRawSql-    , Mode(..)-    , NeedParens(..)-    , IdentState-    , renderExpr-    , initialIdentState-    , IdentInfo-    , SqlSelect(..)-    , veryUnsafeCoerceSqlExprValue-    , veryUnsafeCoerceSqlExprValueList-    -- * Helper functions-    , renderQueryToText-    , renderQuerySelect-    , renderQueryUpdate-    , renderQueryDelete-    , renderQueryInsertInto-    , makeOrderByNoNewline-    , uncommas'-    , parens-    , toArgList-    , builderToText-    , Ident(..)-    , valkey-    , valJ-    , deleteKey-    , associateJoin-    ) where--import Database.Esqueleto.Internal.Internal
+ src/Database/Esqueleto/Legacy.hs view
@@ -0,0 +1,415 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE GADTs #-}+{-# LANGUAGE RankNTypes #-}++-- | WARNING+--+-- This module is introduced in version @3.5.0.0@ to provide a smooth migration+-- experience from this legacy syntax to the new and improved syntax. If you've+-- imported this module, it means you've decided to use the old syntax for+-- a little bit longer, rather than migrate to the new stuff. That's fine!+--+-- But you should know that this module, and all of the legacy syntax, will be+-- completely removed from the library in version @4.0.0.0@.+--+-- The @esqueleto@ EDSL (embedded domain specific language).+-- This module replaces @Database.Persist@, so instead of+-- importing that module you should just import this one:+--+-- @+-- -- For a module using just esqueleto.+-- import Database.Esqueleto+-- @+--+-- If you need to use @persistent@'s default support for queries+-- as well, either import it qualified:+--+-- @+-- -- For a module that mostly uses esqueleto.+-- import Database.Esqueleto+-- import qualified Database.Persist as P+-- @+--+-- or import @esqueleto@ itself qualified:+--+-- @+-- -- For a module that uses esqueleto just on some queries.+-- import Database.Persist+-- import qualified Database.Esqueleto as E+-- @+--+-- Other than identifier name clashes, @esqueleto@ does not+-- conflict with @persistent@ in any way.+module Database.Esqueleto.Legacy+  ( -- * Setup+    -- $setup++    -- * Introduction+    -- $introduction++    -- * Getting started+    -- $gettingstarted++    -- * @esqueleto@'s Language+    where_, on, groupBy, orderBy, rand, asc, desc, limit, offset+             , distinct, distinctOn, don, distinctOnOrderBy, having, locking+             , sub_select, (^.), (?.)+             , val, isNothing, just, nothing, joinV, withNonNull+             , countRows, count, countDistinct+             , not_, (==.), (>=.), (>.), (<=.), (<.), (!=.), (&&.), (||.)+             , between, (+.), (-.), (/.), (*.)+             , random_, round_, ceiling_, floor_+             , min_, max_, sum_, avg_, castNum, castNumM+             , coalesce, coalesceDefault+             , lower_, upper_, trim_, ltrim_, rtrim_, length_, left_, right_+             , like, ilike, (%), concat_, (++.), castString+             , subList_select, valList, justList+             , in_, notIn, exists, notExists+             , set, (=.), (+=.), (-=.), (*=.), (/=.)+             , case_, toBaseId+  , subSelect+  , subSelectMaybe+  , subSelectCount+  , subSelectForeign+  , subSelectList+  , subSelectUnsafe+  , ToBaseId(..)+  , when_+  , then_+  , else_+  , from+  , Value(..)+  , ValueList(..)+  , OrderBy+  , DistinctOn+  , LockingKind(..)+  , SqlString+    -- ** Joins+  , InnerJoin(..)+  , CrossJoin(..)+  , LeftOuterJoin(..)+  , RightOuterJoin(..)+  , FullOuterJoin(..)+  , JoinKind(..)+  , OnClauseWithoutMatchingJoinException(..)+    -- * SQL backend+  , SqlQuery+  , SqlExpr+  , SqlEntity+  , select+  , selectSource+  , delete+  , deleteCount+  , update+  , updateCount+  , insertSelect+  , insertSelectCount+  , (<#)+  , (<&>)+  -- ** Rendering Queries+  , renderQueryToText+  , renderQuerySelect+  , renderQueryUpdate+  , renderQueryDelete+  , renderQueryInsertInto+    -- * Internal.Language+  , From+    -- * RDBMS-specific modules+    -- $rdbmsSpecificModules++    -- * Helpers+  , valkey+  , valJ+  , associateJoin++    -- * Re-exports+    -- $reexports+  , deleteKey+  , module Database.Esqueleto.Internal.PersistentImport+  ) where++import Database.Esqueleto.Internal.Internal+import Database.Esqueleto.Internal.PersistentImport+++-- $setup+--+-- If you're already using @persistent@, then you're ready to use+-- @esqueleto@, no further setup is needed.  If you're just+-- starting a new project and would like to use @esqueleto@, take+-- a look at @persistent@'s book first+-- (<http://www.yesodweb.com/book/persistent>) to learn how to+-- define your schema.+++----------------------------------------------------------------------+++-- $introduction+--+-- The main goals of @esqueleto@ are to:+--+--   * Be easily translatable to SQL.  When you take a look at a+--   @esqueleto@ query, you should be able to know exactly how+--   the SQL query will end up.  (As opposed to being a+--   relational algebra EDSL such as HaskellDB, which is+--   non-trivial to translate into SQL.)+--+--   * Support the most widely used SQL features.  We'd like you to be+--   able to use @esqueleto@ for all of your queries, no+--   exceptions.  Send a pull request or open an issue on our+--   project page (<https://github.com/prowdsponsor/esqueleto>) if+--   there's anything missing that you'd like to see.+--+--   * Be as type-safe as possible.  We strive to provide as many+--   type checks as possible.  If you get bitten by some invalid+--   code that type-checks, please open an issue on our project+--   page so we can take a look.+--+-- However, it is /not/ a goal to be able to write portable SQL.+-- We do not try to hide the differences between DBMSs from you,+-- and @esqueleto@ code that works for one database may not work+-- on another.  This is a compromise we have to make in order to+-- give you as much control over the raw SQL as possible without+-- losing too much convenience.  This also means that you may+-- type-check a query that doesn't work on your DBMS.+++----------------------------------------------------------------------+++-- $gettingstarted+--+-- We like clean, easy-to-read EDSLs.  However, in order to+-- achieve this goal we've used a lot of type hackery, leading to+-- some hard-to-read type signatures.  On this section, we'll try+-- to build some intuition about the syntax.+--+-- For the following examples, we'll use this example schema:+--+-- @+-- share [mkPersist sqlSettings, mkMigrate \"migrateAll\"] [persist|+--   Person+--     name String+--     age Int Maybe+--     deriving Eq Show+--   BlogPost+--     title String+--     authorId PersonId+--     deriving Eq Show+--   Follow+--     follower PersonId+--     followed PersonId+--     deriving Eq Show+-- |]+-- @+--+-- Most of @esqueleto@ was created with @SELECT@ statements in+-- mind, not only because they're the most common but also+-- because they're the most complex kind of statement.  The most+-- simple kind of @SELECT@ would be:+--+-- @+-- SELECT *+-- FROM Person+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+-- do people <- 'select' $+--              'from' $ \\person -> do+--              return person+--    liftIO $ mapM_ (putStrLn . personName . entityVal) people+-- @+--+-- The expression above has type @SqlPersist m ()@, while+-- @people@ has type @[Entity Person]@.  The query above will be+-- translated into exactly the same query we wrote manually, but+-- instead of @SELECT *@ it will list all entity fields (using+-- @*@ is not robust).  Note that @esqueleto@ knows that we want+-- an @Entity Person@ just because of the @personName@ that we're+-- printing later.+--+-- However, most of the time we need to filter our queries using+-- @WHERE@.  For example:+--+-- @+-- SELECT *+-- FROM Person+-- WHERE Person.name = \"John\"+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+-- 'select' $+-- 'from' $ \\p -> do+-- 'where_' (p '^.' PersonName '==.' 'val' \"John\")+-- return p+-- @+--+-- Although @esqueleto@'s code is a bit more noisy, it's has+-- almost the same structure (save from the @return@).  The+-- @('^.')@ operator is used to project a field from an entity.+-- The field name is the same one generated by @persistent@'s+-- Template Haskell functions.  We use 'val' to lift a constant+-- Haskell value into the SQL query.+--+-- Another example would be:+--+-- @+-- SELECT *+-- FROM Person+-- WHERE Person.age >= 18+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+-- 'select' $+-- 'from' $ \\p -> do+-- 'where_' (p '^.' PersonAge '>=.' 'just' ('val' 18))+-- return p+-- @+--+-- Since @age@ is an optional @Person@ field, we use 'just' to lift+-- @'val' 18 :: SqlExpr (Value Int)@ into @just ('val' 18) ::+-- SqlExpr (Value (Maybe Int))@.+--+-- Implicit joins are represented by tuples.  For example, to get+-- the list of all blog posts and their authors, we could write:+--+-- @+-- SELECT BlogPost.*, Person.*+-- FROM BlogPost, Person+-- WHERE BlogPost.authorId = Person.id+-- ORDER BY BlogPost.title ASC+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+-- 'select' $+-- 'from' $ \\(b, p) -> do+-- 'where_' (b '^.' BlogPostAuthorId '==.' p '^.' PersonId)+-- 'orderBy' ['asc' (b '^.' BlogPostTitle)]+-- return (b, p)+-- @+--+-- However, you may want your results to include people who don't+-- have any blog posts as well using a @LEFT OUTER JOIN@:+--+-- @+-- SELECT Person.*, BlogPost.*+-- FROM Person LEFT OUTER JOIN BlogPost+-- ON Person.id = BlogPost.authorId+-- ORDER BY Person.name ASC, BlogPost.title ASC+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+-- 'select' $+-- 'from' $ \\(p `'LeftOuterJoin`` mb) -> do+-- 'on' ('just' (p '^.' PersonId) '==.' mb '?.' BlogPostAuthorId)+-- 'orderBy' ['asc' (p '^.' PersonName), 'asc' (mb '?.' BlogPostTitle)]+-- return (p, mb)+-- @+--+-- On a @LEFT OUTER JOIN@ the entity on the right hand side may+-- not exist (i.e. there may be a @Person@ without any+-- @BlogPost@s), so while @p :: SqlExpr (Entity Person)@, we have+-- @mb :: SqlExpr (Maybe (Entity BlogPost))@.  The whole+-- expression above has type @SqlPersist m [(Entity Person, Maybe+-- (Entity BlogPost))]@.  Instead of using @(^.)@, we used+-- @('?.')@ to project a field from a @Maybe (Entity a)@.+--+-- We are by no means limited to joins of two tables, nor by+-- joins of different tables.  For example, we may want a list+-- of the @Follow@ entity:+--+-- @+-- SELECT P1.*, Follow.*, P2.*+-- FROM Person AS P1+-- INNER JOIN Follow ON P1.id = Follow.follower+-- INNER JOIN Person AS P2 ON P2.id = Follow.followed+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+-- 'select' $+-- 'from' $ \\(p1 `'InnerJoin`` f `'InnerJoin`` p2) -> do+-- 'on' (p1 '^.' PersonId '==.' f '^.' FollowFollower)+-- 'on' (p2 '^.' PersonId '==.' f '^.' FollowFollowed)+-- return (p1, f, p2)+-- @+--+-- We also currently support @UPDATE@ and @DELETE@ statements.+-- For example:+--+-- @+-- do 'update' $ \\p -> do+--      'set' p [ PersonName '=.' 'val' \"João\" ]+--      'where_' (p '^.' PersonName '==.' 'val' \"Joao\")+--    'delete' $+--      'from' $ \\p -> do+--      'where_' (p '^.' PersonAge '<.' 'just' ('val' 14))+-- @+--+-- The results of queries can also be used for insertions.+-- In @SQL@, we might write the following, inserting a new blog+-- post for every user:+--+-- @+-- INSERT INTO BlogPost+-- SELECT ('Group Blog Post', id)+-- FROM Person+-- @+--+-- In @esqueleto@, we may write the same query above as:+--+-- @+--  'insertSelect' $ 'from' $ \\p->+--  return $ BlogPost '<#' \"Group Blog Post\" '<&>' (p '^.' PersonId)+-- @+--+-- Individual insertions can be performed through Persistent's+-- 'insert' function, reexported for convenience.+++----------------------------------------------------------------------+++-- $reexports+--+-- We re-export many symbols from @persistent@ for convenince:+--+--  * \"Store functions\" from "Database.Persist".+--+--  * Everything from "Database.Persist.Class" except for+--    @PersistQuery@ and @delete@ (use 'deleteKey' instead).+--+--  * Everything from "Database.Persist.Types" except for+--    @Update@, @SelectOpt@, @BackendSpecificFilter@ and @Filter@.+--+--  * Everything from "Database.Persist.Sql" except for+--    @deleteWhereCount@ and @updateWhereCount@.+++----------------------------------------------------------------------+++-- $rdbmsSpecificModules+--+-- There are many differences between SQL syntax and functions+-- supported by different RDBMSs.  Since version 2.2.8,+-- @esqueleto@ includes modules containing functions that are+-- specific to a given RDBMS.+--+--  * PostgreSQL: "Database.Esqueleto.PostgreSQL".+--+-- In order to use these functions, you need to explicitly import+-- their corresponding modules, they're not re-exported here.
src/Database/Esqueleto/PostgreSQL.hs view
@@ -33,14 +33,12 @@ #if __GLASGOW_HASKELL__ < 804 import Data.Semigroup #endif-import Control.Arrow (first, (***))+import Control.Arrow (first) import Control.Exception (throw) import Control.Monad (void) import Control.Monad.IO.Class (MonadIO(..)) import qualified Control.Monad.Trans.Reader as R import Data.Int (Int64)-import Data.List.NonEmpty (NonEmpty((:|)))-import qualified Data.List.NonEmpty as NonEmpty import Data.Proxy (Proxy(..)) import qualified Data.Text.Internal.Builder as TLB import Data.Time.Clock (UTCTime)@@ -85,18 +83,18 @@     -> a     -> [OrderByClause]     -> SqlExpr (Value b)-unsafeSqlAggregateFunction name mode args orderByClauses = ERaw Never $ \info ->+unsafeSqlAggregateFunction name mode args orderByClauses = ERaw noMeta $ \_ info ->     let (orderTLB, orderVals) = makeOrderByNoNewline info orderByClauses         -- Don't add a space if we don't have order by clauses         orderTLBSpace =             case orderByClauses of-                [] -> ""+                []    -> ""                 (_:_) -> " "         (argsTLB, argsVals) =-            uncommas' $ map (\v -> valueToRawSqlParens SqlFunctionError v info) $ toArgList args+            uncommas' $ map (\(ERaw _ f) -> f Never info) $ toArgList args         aggMode =             case mode of-                AggModeAll -> ""+                AggModeAll      -> ""                 -- ALL is the default, so we don't need to                 -- specify it                 AggModeDistinct -> "DISTINCT "@@ -184,7 +182,7 @@     )     => record     -- ^ new record to insert-    -> [SqlExpr (Update record)]+    -> [SqlExpr (Entity record) -> SqlExpr Update]     -- ^ updates to perform if the record already exists     -> R.ReaderT SqlBackend m (Entity record)     -- ^ the record in the database after the operation@@ -202,7 +200,7 @@     -- ^ uniqueness constraint to find by     -> record     -- ^ new record to insert-    -> [SqlExpr (Update record)]+    -> [SqlExpr (Entity record) -> SqlExpr Update]     -- ^ updates to perform if the record already exists     -> R.ReaderT SqlBackend m (Entity record)     -- ^ the record in the database after the operation@@ -278,13 +276,13 @@     -- a unique "MyUnique 0", "MyUnique undefined" would work as well.     -> SqlQuery (SqlExpr (Insertion val))     -- ^ Insert query.-    -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Update val)])+    -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update])     -- ^ A list of updates to be applied in case of the constraint being     -- violated. The expression takes the current and excluded value to produce     -- the updates.     -> SqlWriteT m ()-insertSelectWithConflict unique query =-    void . insertSelectWithConflictCount unique query+insertSelectWithConflict unique query a =+    void $ insertSelectWithConflictCount unique query a  -- | Same as 'insertSelectWithConflict' but returns the number of rows affected. --@@ -294,22 +292,22 @@      . (FinalResult a, KnowResult a ~ Unique val, MonadIO m, PersistEntity val)     => a     -> SqlQuery (SqlExpr (Insertion val))-    -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Update val)])+    -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Entity val) -> SqlExpr Update])     -> SqlWriteT m Int64 insertSelectWithConflictCount unique query conflictQuery = do     conn <- R.ask     uncurry rawExecuteCount $         combine-            (toRawSql INSERT_INTO (conn, initialIdentState) (fmap EInsertFinal query))+            (toRawSql INSERT_INTO (conn, initialIdentState) query)             (conflict conn)   where     proxy :: Proxy val     proxy = Proxy     updates = conflictQuery entCurrent entExcluded     combine (tlb1,vals1) (tlb2,vals2) = (builderToText (tlb1 `mappend` tlb2), vals1 ++ vals2)-    entExcluded = EEntity $ I "excluded"+    entExcluded = unsafeSqlEntity (I "excluded")     tableName = unEntityNameDB . getEntityDBName . entityDef-    entCurrent = EEntity $ I (tableName proxy)+    entCurrent = unsafeSqlEntity (I (tableName proxy))     uniqueDef = toUniqueDef unique     constraint = TLB.fromText . unConstraintNameDB . uniqueDBName $ uniqueDef     renderedUpdates :: (BackendCompatible SqlBackend backend) => backend -> (TLB.Builder, [PersistValue])@@ -357,13 +355,11 @@     -> SqlExpr (Value Bool)     -- ^ Filter clause     -> SqlExpr (Value a)-filterWhere aggExpr clauseExpr = ERaw Never $ \info ->+filterWhere aggExpr clauseExpr = ERaw noMeta $ \_ info ->     let (aggBuilder, aggValues) = case aggExpr of-            ERaw _ aggF     -> aggF info-            ECompositeKey _ -> throw $ CompositeKeyErr FilterWhereAggError+            ERaw _ aggF     -> aggF Never info         (clauseBuilder, clauseValues) = case clauseExpr of-            ERaw _ clauseF  -> clauseF info-            ECompositeKey _ -> throw $ CompositeKeyErr FilterWhereClauseError+            ERaw _ clauseF  -> clauseF Never info     in ( aggBuilder <> " FILTER (WHERE " <> clauseBuilder <> ")"        , aggValues <> clauseValues        )
src/Database/Esqueleto/PostgreSQL/JSON.hs view
@@ -136,9 +136,8 @@     ) where  import Data.Text (Text)-import Database.Esqueleto.Internal.Language hiding ((-.), (?.), (||.))+import Database.Esqueleto.Internal.Internal hiding ((-.), (?.), (||.)) import Database.Esqueleto.Internal.PersistentImport-import Database.Esqueleto.Internal.Sql import Database.Esqueleto.PostgreSQL.JSON.Instances  infixl 6 ->., ->>., #>., #>>.
src/Database/Esqueleto/PostgreSQL/JSON/Instances.hs view
@@ -15,9 +15,8 @@ import Data.Text (Text) import qualified Data.Text as T (concat, pack) import qualified Data.Text.Encoding as TE (decodeUtf8, encodeUtf8)-import Database.Esqueleto (Value, just, val) import Database.Esqueleto.Internal.PersistentImport-import Database.Esqueleto.Internal.Sql (SqlExpr)+import Database.Esqueleto.Internal.Internal (SqlExpr, Value, just, val) import GHC.Generics (Generic)  -- | Newtype wrapper around any type with a JSON representation.
test/Common/Test.hs view
@@ -1,6 +1,6 @@ {-# LANGUAGE CPP #-}-{-# LANGUAGE DataKinds #-} {-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE EmptyDataDecls #-}@@ -93,7 +93,7 @@ import qualified Data.Text.Internal.Lazy as TL import qualified Data.Text.Lazy.Builder as TLB import qualified Database.Esqueleto.Internal.ExprParser as P-import qualified Database.Esqueleto.Internal.Sql as EI+import qualified Database.Esqueleto.Internal.Internal as EI import qualified UnliftIO.Resource as R  -- Test schema@@ -387,7 +387,7 @@                     v `shouldBe` [Value 1]      describe "subSelectList" $ do-        it "is safe on empty databases as well as good databases" $ do+        it "is safe on empty databases as well as good databases" $ run $ do             let query =                     from $ \n -> do                     where_ $ n ^. NumbersInt `in_` do@@ -396,16 +396,15 @@                             where_ $ n' ^. NumbersInt >=. val 3                             pure (n' ^. NumbersInt)                     pure n--            empty <- run $ do-                select query+            empty <- select query -            full <- run $ do+            full <- do                 setup                 select query -            empty `shouldBe` []-            full `shouldSatisfy` (not . null)+            liftIO $ do+                empty `shouldBe` []+                full `shouldSatisfy` (not . null)      describe "subSelectMaybe" $ do         it "is equivalent to joinV . subSelect" $ do@@ -770,7 +769,7 @@         insert_ $ Frontcover number ""         articleId <- insert $ Article "title" number         articleMetaE <- insert' (ArticleMetadata articleId)-        result <- select . from $ \articleMetadata -> do+        result <- select $ from $ \articleMetadata -> do           where_ $ (articleMetadata ^. ArticleMetadataId) ==. (val ((ArticleMetadataKey articleId)))           pure articleMetadata         liftIO $ [articleMetaE] `shouldBe` result@@ -864,7 +863,7 @@     it "respects the associativity of joins" $       run $ do           void $ insert p1-          ps <- select . from $+          ps <- select $ from $                     \((p :: SqlExpr (Entity Person))                      `LeftOuterJoin`                       ((_q :: SqlExpr (Entity Person))@@ -890,12 +889,14 @@         l1Deeds <- mapM (\k -> insert' $ Deed k (entityKey l1e)) (map show [1..3 :: Int])         let l1WithDeeds = do d <- l1Deeds                              pure (l1e, Just d)-        ret <- select $ Experimental.from $ do-          (lords :& deeds) <--              Experimental.from $ Table @Lord-              `LeftOuterJoin` Table @Deed-              `Experimental.on` (\(l :& d) -> just (l ^. LordId) ==. d ?. DeedOwnerId)-          pure (lords, deeds)+        let q = Experimental.from $ do+                  (lords :& deeds) <-+                      Experimental.from $ Table @Lord+                      `LeftOuterJoin` Table @Deed+                      `Experimental.on` (\(l :& d) -> just (l ^. LordId) ==. d ?. DeedOwnerId)+                  pure (lords, deeds)++        ret <- select q         liftIO $ ret `shouldMatchList` ((l3e, Nothing) : l1WithDeeds)      it "lets you order by alias" $ run $ do@@ -1080,17 +1081,6 @@                         ( val $ PointKey 1 2                         , val $ PointKey 5 6 )                 liftIO $ ret `shouldBe` [()]-            it "works when using ECompositeKey constructor" $ run $ do-                insert_ $ Point 1 2 ""-                ret <--                  select $-                  from $ \p -> do-                  where_ $-                    p ^. PointId-                      `between`-                        ( EI.ECompositeKey $ const ["3", "4"]-                        , EI.ECompositeKey $ const ["5", "6"] )-                liftIO $ ret `shouldBe` []      it "works with avg_" $ run $ do         _ <- insert' p1@@ -1331,7 +1321,7 @@           liftIO $ ret `shouldBe` [ Value t1, Value t2, Value t3 ]      it "works on a simple example (select . distinct)" $-      selDistTest (select . distinct)+      selDistTest (\a -> select $ distinct a)      it "works on a simple example (distinct (return ()))" $       selDistTest (\act -> select $ distinct (return ()) >> act)@@ -1868,9 +1858,10 @@       (c, expr) <- run $ do         conn <- ask         let Right c = P.mkEscapeChar conn+        let user = EI.unsafeSqlEntity (EI.I "user")+            blogPost = EI.unsafeSqlEntity (EI.I "blog_post")         pure $ (,) c $ EI.renderExpr conn $-          EI.EEntity (EI.I "user") ^. PersonId-          ==. EI.EEntity (EI.I "blog_post") ^. BlogPostAuthorId+          user ^. PersonId ==. blogPost ^. BlogPostAuthorId       expr         `shouldBe`           Text.intercalate (Text.singleton c) ["", "user", ".", "id", ""]@@ -1881,23 +1872,6 @@     it "renders ? for a val" $ do       expr <- run $ ask >>= \c -> pure $ EI.renderExpr c (val (PersonKey 0) ==. val (PersonKey 1))       expr `shouldBe` "? = ?"--  describe "EEntity Ident behavior" $ do-      let render :: SqlExpr (Entity val) -> Text.Text-          render (EI.EEntity (EI.I ident)) = ident-          render _ = error "guess we gotta handle this in the test suite now"-      it "renders sensibly" $ run $ do-          _ <- insert $ Foo 2-          _ <- insert $ Foo 3-          _ <- insert $ Person "hello" Nothing Nothing 3-          results <- select $-              from $ \(a `LeftOuterJoin` b) -> do-              on $ a ^. FooName ==. b ^. PersonFavNum-              pure (val (render a), val (render b))-          liftIO $-              head results-              `shouldBe`-              (Value "Foo", Value "Person")    describe "ExprParser" $ do     let parse parser = AP.parseOnly (parser '#')
test/MySQL/Test.hs view
@@ -24,6 +24,7 @@        , defaultConnectInfo        , withMySQLConn        )+ import System.Environment import Test.Hspec @@ -190,7 +191,7 @@               pure $ foo ^. FooName  -        ret <- select $ Experimental.from $ SelectQuery q1 `Union` SelectQuery q2+        ret <- select $ Experimental.from $ q1 `union_` q2         liftIO $ ret `shouldMatchList` [Value 1, Value 2, Value 4, Value 5]  
test/PostgreSQL/Test.hs view
@@ -35,7 +35,7 @@ import Database.Esqueleto hiding (random_) import Database.Esqueleto.Experimental hiding (from, on, random_) import qualified Database.Esqueleto.Experimental as Experimental-import qualified Database.Esqueleto.Internal.Sql as ES+import qualified Database.Esqueleto.Internal.Internal as ES import Database.Esqueleto.PostgreSQL (random_) import qualified Database.Esqueleto.PostgreSQL as EP import Database.Esqueleto.PostgreSQL.JSON hiding ((-.), (?.), (||.))@@ -272,7 +272,7 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.arrayAggWith EP.AggModeAll (p ^. PersonName) [])       liftIO $ L.sort ret `shouldBe` L.sort (map personName people) @@ -289,7 +289,7 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.arrayAggWith EP.AggModeDistinct (p ^. PersonAge) [])       liftIO $ L.sort ret `shouldBe` [Nothing, Just 17, Just 36] @@ -310,7 +310,7 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.arrayAggWith EP.AggModeAll (p ^. PersonName) [])       liftIO $ L.sort ret `shouldBe` L.sort (map personName people) @@ -329,7 +329,7 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.arrayAggWith EP.AggModeDistinct (p ^. PersonAge)                    [asc $ p ^. PersonAge])       liftIO $ ret `shouldBe` [Just 17, Just 36, Nothing]@@ -354,13 +354,13 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.stringAggWith EP.AggModeAll (p ^. PersonName) (val " ")[])       liftIO $ (L.sort $ words ret) `shouldBe` L.sort (map personName people)      it "works with zero rows" $ run $ do       [Value ret] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.stringAggWith EP.AggModeAll (p ^. PersonName) (val " ")[])       liftIO $ ret `shouldBe` Nothing @@ -378,7 +378,7 @@       let people = [p1, p2, p3 {personName = "John"}, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return $ EP.stringAggWith EP.AggModeDistinct (p ^. PersonName) (val " ")                    []       liftIO $ (L.sort $ words ret) `shouldBe`@@ -401,7 +401,7 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return $ EP.stringAggWith EP.AggModeAll (p ^. PersonName) (val " ")                     [desc $ p ^. PersonName]       liftIO $ (words ret)@@ -422,7 +422,7 @@       let people = [p1, p2, p3 {personName = "John"}, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p ->+        select $ from $ \p ->           return $ EP.stringAggWith EP.AggModeDistinct (p ^. PersonName) (val " ")                    [desc $ p ^. PersonName]       liftIO $ (words ret) `shouldBe`@@ -439,12 +439,12 @@       let people = [p1, p2, p3, p4, p5]       mapM_ insert people       [Value (Just ret)] <--        select . from $ \p -> return (EP.arrayAgg (p ^. PersonName))+        select $ from $ \p -> return (EP.arrayAgg (p ^. PersonName))       liftIO $ L.sort ret `shouldBe` L.sort (map personName people)      it "works on zero rows" $ run $ do       [Value ret] <--        select . from $ \p -> return (EP.arrayAgg (p ^. PersonName))+        select $ from $ \p -> return (EP.arrayAgg (p ^. PersonName))       liftIO $ ret `shouldBe` Nothing   describe "arrayAggWith" testArrayAggWith   describe "stringAgg" $ do@@ -459,7 +459,7 @@         liftIO $ L.sort (words ret) `shouldBe` L.sort (map personName people)     it "works on zero rows" $ run $ do       [Value ret] <--        select . from $ \p -> return (EP.stringAgg (p ^. PersonName) (val " "))+        select $ from $ \p -> return (EP.stringAgg (p ^. PersonName) (val " "))       liftIO $ ret `shouldBe` Nothing   describe "stringAggWith" testStringAggWith @@ -471,7 +471,7 @@                    , Person "4" (Just 8)  Nothing 2                    , Person "5" (Just 9)  Nothing 2                    ]-      ret <- select . from $ \(person :: SqlExpr (Entity Person)) -> do+      ret <- select $ from $ \(person :: SqlExpr (Entity Person)) -> do         groupBy (person ^. PersonFavNum)         return . EP.arrayRemoveNull . EP.maybeArray . EP.arrayAgg           $ person ^. PersonAge@@ -481,7 +481,7 @@   describe "maybeArray" $ do     it "Coalesces NULL into an empty array" $ run $ do       [Value ret] <--        select . from $ \p ->+        select $ from $ \p ->           return (EP.maybeArray $ EP.arrayAgg (p ^. PersonName))       liftIO $ ret `shouldBe` [] @@ -1134,19 +1134,22 @@       -- Person "Mitch"  Nothing   Nothing   5       _ <- insert p5 -      usersByAge <- (fmap . fmap) (\(Value a, Value b, Value c) -> (a, b, c)) <$> select $ from $ \users -> do-        groupBy $ users ^. PersonAge-        return-          ( users ^. PersonAge-          -- Nothing: [Rachel { favNum = 2 }, Mitch { favNum = 5 }] = 2-          -- Just 36: [John { favNum = 1 } (excluded)] = 0-          -- Just 17: [Mike { favNum = 3 }, Livia { favNum = 4 }] = 2-          , count (users ^. PersonId) `EP.filterWhere` (users ^. PersonFavNum >=. val 2)-          -- Nothing: [Rachel { favNum = 2 } (excluded), Mitch { favNum = 5 } (excluded)] = 0-          -- Just 36: [John { favNum = 1 }] = 1-          -- Just 17: [Mike { favNum = 3 } (excluded), Livia { favNum = 4 } (excluded)] = 0-          , count (users ^. PersonFavNum) `EP.filterWhere` (users ^. PersonFavNum <. val 2)-          )+      usersByAge <- fmap coerce <$> do+          select $ from $ \users -> do+            groupBy $ users ^. PersonAge+            return+              ( users ^. PersonAge :: SqlExpr (Value (Maybe Int))+              -- Nothing: [Rachel { favNum = 2 }, Mitch { favNum = 5 }] = 2+              -- Just 36: [John { favNum = 1 } (excluded)] = 0+              -- Just 17: [Mike { favNum = 3 }, Livia { favNum = 4 }] = 2+              , count (users ^. PersonId) `EP.filterWhere` (users ^. PersonFavNum >=. val 2)+                :: SqlExpr (Value Int)+              -- Nothing: [Rachel { favNum = 2 } (excluded), Mitch { favNum = 5 } (excluded)] = 0+              -- Just 36: [John { favNum = 1 }] = 1+              -- Just 17: [Mike { favNum = 3 } (excluded), Livia { favNum = 4 } (excluded)] = 0+              , count (users ^. PersonFavNum) `EP.filterWhere` (users ^. PersonFavNum <. val 2)+                :: SqlExpr (Value Int)+              )        liftIO $ usersByAge `shouldMatchList`         ( [ (Nothing, 2, 0)@@ -1167,19 +1170,20 @@       -- Person "Mitch"  Nothing   Nothing   5       _ <- insert p5 -      usersByAge <- (fmap . fmap) (\(Value a, Value b, Value c) -> (a, b, c)) <$> select $ from $ \users -> do-        groupBy $ users ^. PersonAge-        return-          ( users ^. PersonAge-          -- Nothing: [Rachel { favNum = 2 }, Mitch { favNum = 5 }] = Just 7-          -- Just 36: [John { favNum = 1 } (excluded)] = Nothing-          -- Just 17: [Mike { favNum = 3 }, Livia { favNum = 4 }] = Just 7-          , sum_ (users ^. PersonFavNum) `EP.filterWhere` (users ^. PersonFavNum >=. val 2)-          -- Nothing: [Rachel { favNum = 2 } (excluded), Mitch { favNum = 5 } (excluded)] = Nothing-          -- Just 36: [John { favNum = 1 }] = Just 1-          -- Just 17: [Mike { favNum = 3 } (excluded), Livia { favNum = 4 } (excluded)] = Nothing-          , sum_ (users ^. PersonFavNum) `EP.filterWhere` (users ^. PersonFavNum <. val 2)-          )+      usersByAge <- fmap (\(Value a, Value b, Value c) -> (a, b, c)) <$> do+          select $ from $ \users -> do+            groupBy $ users ^. PersonAge+            return+              ( users ^. PersonAge+              -- Nothing: [Rachel { favNum = 2 }, Mitch { favNum = 5 }] = Just 7+              -- Just 36: [John { favNum = 1 } (excluded)] = Nothing+              -- Just 17: [Mike { favNum = 3 }, Livia { favNum = 4 }] = Just 7+              , sum_ (users ^. PersonFavNum) `EP.filterWhere` (users ^. PersonFavNum >=. val 2)+              -- Nothing: [Rachel { favNum = 2 } (excluded), Mitch { favNum = 5 } (excluded)] = Nothing+              -- Just 36: [John { favNum = 1 }] = Just 1+              -- Just 17: [Mike { favNum = 3 } (excluded), Livia { favNum = 4 } (excluded)] = Nothing+              , sum_ (users ^. PersonFavNum) `EP.filterWhere` (users ^. PersonFavNum <. val 2)+              )        liftIO $ usersByAge `shouldMatchList`         ( [ (Nothing, Just 7, Nothing)@@ -1197,7 +1201,7 @@         void $ select $ do           limitedLordsCte <-             Experimental.with $ do-              lords <- Experimental.from $ Experimental.Table @Lord+              lords <- Experimental.from $ Experimental.table @Lord               limit 10               pure lords           lords <- Experimental.from limitedLordsCte@@ -1260,9 +1264,9 @@       _ <- run $ do         select $ do             l :& c <--              Experimental.from $ Table @Lord+              Experimental.from $ table @Lord               `CrossJoin` \lord -> do-                    deed <- Experimental.from $ Table @Deed+                    deed <- Experimental.from $ table @Deed                     where_ $ lord ^. LordId ==. deed ^. DeedOwnerId                     pure $ countRows @Int             pure (l, c)@@ -1271,11 +1275,11 @@     it "supports INNER JOIN LATERAL" $ do       run $ do         let subquery lord = do-                            deed <- Experimental.from $ Table @Deed+                            deed <- Experimental.from $ table @Deed                             where_ $ lord ^. LordId ==. deed ^. DeedOwnerId                             pure $ countRows @Int         res <- select $ do-          l :& c <- Experimental.from $ Table @Lord+          l :& c <- Experimental.from $ table @Lord                           `InnerJoin` subquery                           `Experimental.on` (const $ val True)           pure (l, c)@@ -1287,9 +1291,9 @@     it "supports LEFT JOIN LATERAL" $ do       run $ do         res <- select $ do-          l :& c <- Experimental.from $ Table @Lord+          l :& c <- Experimental.from $ table @Lord                           `LeftOuterJoin` (\lord -> do-                                    deed <- Experimental.from $ Table @Deed+                                    deed <- Experimental.from $ table @Deed                                     where_ $ lord ^. LordId ==. deed ^. DeedOwnerId                                     pure $ countRows @Int)                           `Experimental.on` (const $ val True)@@ -1303,9 +1307,9 @@     it "compile error on RIGHT JOIN LATERAL" $ do       run $ do         res <- select $ do-          l :& c <- Experimental.from $ Table @Lord+          l :& c <- Experimental.from $ table @Lord                           `RightOuterJoin` (\lord -> do-                                      deed <- Experimental.from $ Table @Deed+                                      deed <- Experimental.from $ table @Deed                                       where_ $ lord ?. LordId ==. just (deed ^. DeedOwnerId)                                       pure $ countRows @Int)                           `Experimental.on` (const $ val True)@@ -1316,9 +1320,9 @@     it "compile error on FULL OUTER JOIN LATERAL" $ do       run $ do         res <- select $ do-          l :& c <- Experimental.from $ Table @Lord+          l :& c <- Experimental.from $ table @Lord                           `FullOuterJoin` (\lord -> do-                                      deed <- Experimental.from $ Table @Deed+                                      deed <- Experimental.from $ table @Deed                                       where_ $ lord ?. LordId ==. just (deed ^. DeedOwnerId)                                       pure $ countRows @Int)                           `Experimental.on` (const $ val True)
test/SQLite/Test.hs view
@@ -1,21 +1,20 @@-{-# LANGUAGE ScopedTypeVariables-           , FlexibleContexts-           , RankNTypes-           , TypeFamilies-           , OverloadedStrings-#-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RankNTypes #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-}  module Main (main) where  import Control.Monad (void) import Control.Monad.IO.Class (MonadIO(liftIO))-import Control.Monad.Logger (runStderrLoggingT, runNoLoggingT)+import Control.Monad.Logger (runNoLoggingT, runStderrLoggingT) import Control.Monad.Trans.Reader (ReaderT)-import Database.Persist.Sqlite (withSqliteConn)-import Database.Sqlite (SqliteException)+import qualified Control.Monad.Trans.Resource as R import Database.Esqueleto hiding (random_) import Database.Esqueleto.SQLite (random_)-import qualified Control.Monad.Trans.Resource as R+import Database.Persist.Sqlite (withSqliteConn)+import Database.Sqlite (SqliteException) import Test.Hspec  import Common.Test@@ -169,7 +168,7 @@     describe "Test SQLite locking" $ do       testLocking withConn -    fdescribe "SQLite specific tests" $ do+    describe "SQLite specific tests" $ do       testAscRandom random_ run       testRandomMath run       testSqliteRandom