Merge branch 'master' into format-config

This commit is contained in:
Matt Parsons 2020-10-29 15:39:01 -06:00 committed by GitHub
commit 51c546aed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 179 additions and 275 deletions

View File

@ -1,3 +1,9 @@
3.4.0.1
=======
- @arthurxavierx
- [#221](https://github.com/bitemyapp/esqueleto/pull/221)
- Deprecate `ToAliasT` and `ToAliasReferenceT`
3.4.0.0 3.4.0.0
======= =======
- @belevy, @charukiewicz - @belevy, @charukiewicz

View File

@ -1,7 +1,7 @@
cabal-version: 1.12 cabal-version: 1.12
name: esqueleto name: esqueleto
version: 3.4.0.0 version: 3.4.0.1
synopsis: Type-safe EDSL for SQL queries on persistent backends. 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. 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.
. .

View File

@ -56,9 +56,7 @@ module Database.Esqueleto.Experimental
, ToMaybe(..) , ToMaybe(..)
, ToMaybeT , ToMaybeT
, ToAlias(..) , ToAlias(..)
, ToAliasT
, ToAliasReference(..) , ToAliasReference(..)
, ToAliasReferenceT
-- * The Normal Stuff -- * The Normal Stuff
, where_ , where_
@ -653,75 +651,61 @@ data From a where
:: PersistEntity ent :: PersistEntity ent
=> From (SqlExpr (Entity ent)) => From (SqlExpr (Entity ent))
SubQuery SubQuery
:: ( SqlSelect a' r :: ( SqlSelect a r
, SqlSelect a'' r'
, ToAlias a , ToAlias a
, a' ~ ToAliasT a , ToAliasReference a
, ToAliasReference a'
, ToAliasReferenceT a' ~ a''
) )
=> SqlQuery a => SqlQuery a
-> From a'' -> From a
FromCte FromCte
:: Ident :: Ident
-> a -> a
-> From a -> From a
SqlSetOperation SqlSetOperation
:: ( SqlSelect a' r :: ( SqlSelect a r
, ToAlias a , ToAlias a
, a' ~ ToAliasT a , ToAliasReference a
, ToAliasReference a'
, ToAliasReferenceT a' ~ a''
) )
=> SqlSetOperation a => SqlSetOperation a
-> From a'' -> From a
InnerJoinFrom InnerJoinFrom
:: From a :: From a
-> (From b, (a :& b) -> SqlExpr (Value Bool)) -> (From b, (a :& b) -> SqlExpr (Value Bool))
-> From (a :& b) -> From (a :& b)
InnerJoinFromLateral InnerJoinFromLateral
:: ( SqlSelect b' r :: ( SqlSelect b r
, SqlSelect b'' r'
, ToAlias b , ToAlias b
, b' ~ ToAliasT b , ToAliasReference b
, ToAliasReference b'
, ToAliasReferenceT b' ~ b''
) )
=> From a => From a
-> ((a -> SqlQuery b), (a :& b'') -> SqlExpr (Value Bool)) -> ((a -> SqlQuery b), (a :& b) -> SqlExpr (Value Bool))
-> From (a :& b'') -> From (a :& b)
CrossJoinFrom CrossJoinFrom
:: From a :: From a
-> From b -> From b
-> From (a :& b) -> From (a :& b)
CrossJoinFromLateral CrossJoinFromLateral
:: ( SqlSelect b' r :: ( SqlSelect b r
, SqlSelect b'' r'
, ToAlias b , ToAlias b
, b' ~ ToAliasT b , ToAliasReference b
, ToAliasReference b'
, ToAliasReferenceT b' ~ b''
) )
=> From a => From a
-> (a -> SqlQuery b) -> (a -> SqlQuery b)
-> From (a :& b'') -> From (a :& b)
LeftJoinFrom LeftJoinFrom
:: ToMaybe b :: ToMaybe b
=> From a => From a
-> (From b, (a :& ToMaybeT b) -> SqlExpr (Value Bool)) -> (From b, (a :& ToMaybeT b) -> SqlExpr (Value Bool))
-> From (a :& ToMaybeT b) -> From (a :& ToMaybeT b)
LeftJoinFromLateral LeftJoinFromLateral
:: ( SqlSelect b' r :: ( SqlSelect b r
, SqlSelect b'' r'
, ToAlias b , ToAlias b
, b' ~ ToAliasT b , ToAliasReference b
, ToAliasReference b' , ToMaybe b
, ToAliasReferenceT b' ~ b''
, ToMaybe b''
) )
=> From a => From a
-> ((a -> SqlQuery b), (a :& ToMaybeT b'') -> SqlExpr (Value Bool)) -> ((a -> SqlQuery b), (a :& ToMaybeT b) -> SqlExpr (Value Bool))
-> From (a :& ToMaybeT b'') -> From (a :& ToMaybeT b)
RightJoinFrom RightJoinFrom
:: ToMaybe a :: ToMaybe a
=> From a => From a
@ -763,23 +747,24 @@ type JoinErrorMsg jk = 'Text "Missing on statement for " ':<>: 'Text jk
type family ToFromT a where type family ToFromT a where
ToFromT (From a) = a ToFromT (From a) = a
ToFromT (SqlQuery a) = ToAliasReferenceT (ToAliasT a) ToFromT (SqlQuery a) = a
ToFromT (Union a b) = ToAliasReferenceT (ToAliasT (SetOperationT a)) ToFromT (Union a b) = SetOperationT a
ToFromT (UnionAll a b) = ToAliasReferenceT (ToAliasT (SetOperationT a)) ToFromT (UnionAll a b) = SetOperationT a
ToFromT (Except a b) = ToAliasReferenceT (ToAliasT (SetOperationT a)) ToFromT (Except a b) = SetOperationT a
ToFromT (Intersect a b) = ToAliasReferenceT (ToAliasT (SetOperationT a)) ToFromT (Intersect a b) = SetOperationT a
ToFromT (SqlSetOperation a) = ToAliasReferenceT (ToAliasT a) ToFromT (SqlSetOperation a) = a
ToFromT (InnerJoin a (b, c -> SqlExpr (Value Bool))) = c ToFromT (InnerJoin a (b, c -> SqlExpr (Value Bool))) = c
ToFromT (LeftOuterJoin a (b, c -> SqlExpr (Value Bool))) = c ToFromT (LeftOuterJoin a (b, c -> SqlExpr (Value Bool))) = c
ToFromT (RightOuterJoin a (b, c -> SqlExpr (Value Bool))) = c ToFromT (RightOuterJoin a (b, c -> SqlExpr (Value Bool))) = c
ToFromT (FullOuterJoin a (b, c -> SqlExpr (Value Bool))) = c ToFromT (FullOuterJoin a (b, c -> SqlExpr (Value Bool))) = c
ToFromT (CrossJoin a (c -> SqlQuery b)) = ToFromT a :& ToAliasReferenceT (ToAliasT b) ToFromT (CrossJoin a (c -> SqlQuery b)) = ToFromT a :& b
ToFromT (CrossJoin a b) = ToFromT a :& ToFromT b ToFromT (CrossJoin a b) = ToFromT a :& ToFromT b
ToFromT (InnerJoin a b) = TypeError (JoinErrorMsg "InnerJoin") ToFromT (InnerJoin a b) = TypeError (JoinErrorMsg "InnerJoin")
ToFromT (LeftOuterJoin a b) = TypeError (JoinErrorMsg "LeftOuterJoin") ToFromT (LeftOuterJoin a b) = TypeError (JoinErrorMsg "LeftOuterJoin")
ToFromT (RightOuterJoin a b) = TypeError (JoinErrorMsg "RightOuterJoin") ToFromT (RightOuterJoin a b) = TypeError (JoinErrorMsg "RightOuterJoin")
ToFromT (FullOuterJoin a b) = TypeError (JoinErrorMsg "FullOuterJoin") ToFromT (FullOuterJoin a b) = TypeError (JoinErrorMsg "FullOuterJoin")
data Lateral data Lateral
data NotLateral data NotLateral
@ -805,64 +790,34 @@ instance {-# OVERLAPPABLE #-} ToFrom (LeftOuterJoin a b) where
instance {-# OVERLAPPABLE #-} ToFrom (RightOuterJoin a b) where instance {-# OVERLAPPABLE #-} ToFrom (RightOuterJoin a b) where
toFrom = undefined toFrom = undefined
instance {-# OVERLAPPABLE #-} ToFrom (FullOuterJoin a b) where instance {-# OVERLAPPABLE #-} ToFrom (FullOuterJoin a b) where
toFrom = undefined toFrom = undefined
instance instance ( ToAlias a
( ToAlias a , ToAliasReference a
, a' ~ ToAliasT a , SqlSelect a r
, ToAliasReference a' ) => ToFrom (SqlQuery a) where
, a'' ~ ToAliasReferenceT a'
, SqlSelect a' r'
, SqlSelect a'' r'
)
=>
ToFrom (SqlQuery a)
where
toFrom = SubQuery toFrom = SubQuery
instance instance ( SqlSelect c r
( SqlSelect c' r
, SqlSelect c'' r'
, ToAlias c , ToAlias c
, c' ~ ToAliasT c , ToAliasReference c
, ToAliasReference c'
, ToAliasReferenceT c' ~ c''
, ToSetOperation a c , ToSetOperation a c
, ToSetOperation b c , ToSetOperation b c
, c ~ SetOperationT a , c ~ SetOperationT a
) ) => ToFrom (Union a b) where
=>
ToFrom (Union a b)
where
toFrom u = SqlSetOperation $ toSetOperation u toFrom u = SqlSetOperation $ toSetOperation u
instance instance ( SqlSelect c r
( SqlSelect c' r
, SqlSelect c'' r'
, ToAlias c , ToAlias c
, c' ~ ToAliasT c , ToAliasReference c
, ToAliasReference c'
, ToAliasReferenceT c' ~ c''
, ToSetOperation a c , ToSetOperation a c
, ToSetOperation b c , ToSetOperation b c
, c ~ SetOperationT a , c ~ SetOperationT a
) ) => ToFrom (UnionAll a b) where
=>
ToFrom (UnionAll a b)
where
toFrom u = SqlSetOperation $ toSetOperation u toFrom u = SqlSetOperation $ toSetOperation u
instance instance (SqlSelect a r, ToAlias a, ToAliasReference a) => ToFrom (SqlSetOperation a) where
( SqlSelect a' r
, SqlSelect a'' r'
, ToAlias a
, a' ~ ToAliasT a
, ToAliasReference a'
, ToAliasReferenceT a' ~ a''
)
=>
ToFrom (SqlSetOperation a)
where
-- If someone uses just a plain SelectQuery it should behave like a normal subquery -- If someone uses just a plain SelectQuery it should behave like a normal subquery
toFrom (SelectQueryP _ q) = SubQuery q toFrom (SelectQueryP _ q) = SubQuery q
-- Otherwise use the SqlSetOperation -- Otherwise use the SqlSetOperation
@ -871,36 +826,22 @@ instance
class ToInnerJoin lateral lhs rhs res where class ToInnerJoin lateral lhs rhs res where
toInnerJoin :: Proxy lateral -> lhs -> rhs -> (res -> SqlExpr (Value Bool)) -> From res toInnerJoin :: Proxy lateral -> lhs -> rhs -> (res -> SqlExpr (Value Bool)) -> From res
instance instance ( SqlSelect b r
( SqlSelect bAlias r
, SqlSelect bAliasRef r'
, ToAlias b , ToAlias b
, bAlias ~ ToAliasT b , ToAliasReference b
, ToAliasReference bAlias
, bAliasRef ~ ToAliasReferenceT bAlias
, ToFrom a , ToFrom a
, ToFromT a ~ a' , ToFromT a ~ a'
) ) => ToInnerJoin Lateral a (a' -> SqlQuery b) (a' :& b) where
=>
ToInnerJoin Lateral a (a' -> SqlQuery b) (a' :& bAliasRef)
where
toInnerJoin _ lhs q on' = InnerJoinFromLateral (toFrom lhs) (q, on') toInnerJoin _ lhs q on' = InnerJoinFromLateral (toFrom lhs) (q, on')
instance instance (ToFrom a, ToFromT a ~ a', ToFrom b, ToFromT b ~ b')
(ToFrom a, ToFromT a ~ a', ToFrom b, ToFromT b ~ b') => ToInnerJoin NotLateral a b (a' :& b') where
=>
ToInnerJoin NotLateral a b (a' :& b')
where
toInnerJoin _ lhs rhs on' = InnerJoinFrom (toFrom lhs) (toFrom rhs, on') toInnerJoin _ lhs rhs on' = InnerJoinFrom (toFrom lhs) (toFrom rhs, on')
instance instance ( ToFrom a
( ToFrom a
, ToFromT a ~ a' , ToFromT a ~ a'
, ToInnerJoin (IsLateral b) a b b' , ToInnerJoin (IsLateral b) a b b'
) ) => ToFrom (InnerJoin a (b, b' -> SqlExpr (Value Bool))) where
=>
ToFrom (InnerJoin a (b, b' -> SqlExpr (Value Bool)))
where
toFrom (InnerJoin lhs (rhs, on')) = toFrom (InnerJoin lhs (rhs, on')) =
let let
toProxy :: b -> Proxy (IsLateral b) toProxy :: b -> Proxy (IsLateral b)
@ -918,61 +859,43 @@ instance
toFrom (CrossJoin lhs rhs) = CrossJoinFrom (toFrom lhs) (toFrom rhs) toFrom (CrossJoin lhs rhs) = CrossJoinFrom (toFrom lhs) (toFrom rhs)
instance {-# OVERLAPPING #-} instance {-# OVERLAPPING #-}
( ToFrom a ( ToFrom a
, ToFromT a ~ a' , ToFromT a ~ a'
, SqlSelect bAlias r , SqlSelect b r
, SqlSelect bAliasRef r'
, ToAlias b , ToAlias b
, bAlias ~ ToAliasT b , ToAliasReference b
, ToAliasReference bAlias
, bAliasRef ~ ToAliasReferenceT bAlias
) )
=> => ToFrom (CrossJoin a (a' -> SqlQuery b)) where
ToFrom (CrossJoin a (a' -> SqlQuery b))
where
toFrom (CrossJoin lhs q) = CrossJoinFromLateral (toFrom lhs) q toFrom (CrossJoin lhs q) = CrossJoinFromLateral (toFrom lhs) q
class ToLeftJoin lateral lhs rhs res where class ToLeftJoin lateral lhs rhs res where
toLeftJoin :: Proxy lateral -> lhs -> rhs -> (res -> SqlExpr (Value Bool)) -> From res toLeftJoin :: Proxy lateral -> lhs -> rhs -> (res -> SqlExpr (Value Bool)) -> From res
instance instance ( ToFrom a
( ToFrom a
, ToFromT a ~ a' , ToFromT a ~ a'
, SqlSelect bAlias r , SqlSelect b r
, SqlSelect bAliasRef r'
, ToAlias b , ToAlias b
, bAlias ~ ToAliasT b , ToAliasReference b
, ToAliasReference bAlias , ToMaybe b
, bAliasRef ~ ToAliasReferenceT bAlias , mb ~ ToMaybeT b
, ToMaybe bAliasRef ) => ToLeftJoin Lateral a (a' -> SqlQuery b) (a' :& mb) where
, mb ~ ToMaybeT bAliasRef
)
=>
ToLeftJoin Lateral a (a' -> SqlQuery b) (a' :& mb)
where
toLeftJoin _ lhs q on' = LeftJoinFromLateral (toFrom lhs) (q, on') toLeftJoin _ lhs q on' = LeftJoinFromLateral (toFrom lhs) (q, on')
instance instance ( ToFrom a
( ToFrom a
, ToFromT a ~ a' , ToFromT a ~ a'
, ToFrom b , ToFrom b
, ToFromT b ~ b' , ToFromT b ~ b'
, ToMaybe b' , ToMaybe b'
, mb ~ ToMaybeT b' , mb ~ ToMaybeT b'
) ) => ToLeftJoin NotLateral a b (a' :& mb) where
=>
ToLeftJoin NotLateral a b (a' :& mb)
where
toLeftJoin _ lhs rhs on' = LeftJoinFrom (toFrom lhs) (toFrom rhs, on') toLeftJoin _ lhs rhs on' = LeftJoinFrom (toFrom lhs) (toFrom rhs, on')
instance instance ( ToLeftJoin (IsLateral b) a b b'
( ToLeftJoin (IsLateral b) a b b' ) => ToFrom (LeftOuterJoin a (b, b' -> SqlExpr (Value Bool))) where
)
=>
ToFrom (LeftOuterJoin a (b, b' -> SqlExpr (Value Bool)))
where
toFrom (LeftOuterJoin lhs (rhs, on')) = toFrom (LeftOuterJoin lhs (rhs, on')) =
let toProxy :: b -> Proxy (IsLateral b) let
toProxy :: b -> Proxy (IsLateral b)
toProxy _ = Proxy toProxy _ = Proxy
in toLeftJoin (toProxy rhs) lhs rhs on' in toLeftJoin (toProxy rhs) lhs rhs on'
@ -1247,16 +1170,11 @@ from parts = do
fromSubQuery fromSubQuery
:: ::
( SqlSelect a' r ( SqlSelect a r
, SqlSelect a'' r'
, ToAlias a , ToAlias a
, a' ~ ToAliasT a , ToAliasReference a
, ToAliasReference a'
, ToAliasReferenceT a' ~ a''
) )
=> SubQueryType => SubQueryType -> SqlQuery a -> SqlQuery (a, FromClause)
-> SqlQuery a
-> SqlQuery (ToAliasReferenceT (ToAliasT a), FromClause)
fromSubQuery subqueryType subquery = do fromSubQuery subqueryType subquery = do
-- We want to update the IdentState without writing the query to side data -- We want to update the IdentState without writing the query to side data
(ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ subquery (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ subquery
@ -1293,9 +1211,9 @@ fromSubQuery subqueryType subquery = do
-- --
-- /Since: 3.4.0.0/ -- /Since: 3.4.0.0/
with :: ( ToAlias a with :: ( ToAlias a
, ToAliasReference (ToAliasT a) , ToAliasReference a
, SqlSelect (ToAliasT a) r , SqlSelect a r
) => SqlQuery a -> SqlQuery (From (ToAliasReferenceT (ToAliasT a))) ) => SqlQuery a -> SqlQuery (From a)
with query = do with query = do
(ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ query (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ query
aliasedValue <- toAlias ret aliasedValue <- toAlias ret
@ -1339,16 +1257,14 @@ with query = do
-- --
-- /Since: 3.4.0.0/ -- /Since: 3.4.0.0/
withRecursive :: ( ToAlias a withRecursive :: ( ToAlias a
, ToAliasReference (ToAliasT a) , ToAliasReference a
, SqlSelect a r , SqlSelect a r
, SqlSelect (ToAliasT a) r
, ref ~ ToAliasReferenceT (ToAliasT a)
, RecursiveCteUnion unionKind , RecursiveCteUnion unionKind
) )
=> SqlQuery a => SqlQuery a
-> unionKind -> unionKind
-> (From ref -> SqlQuery a) -> (From a -> SqlQuery a)
-> SqlQuery (From ref) -> SqlQuery (From a)
withRecursive baseCase unionKind recursiveCase = do withRecursive baseCase unionKind recursiveCase = do
(ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ baseCase (ret, sideData) <- Q $ W.censor (\_ -> mempty) $ W.listen $ unQ baseCase
aliasedValue <- toAlias ret aliasedValue <- toAlias ret
@ -1365,21 +1281,12 @@ withRecursive baseCase unionKind recursiveCase = do
Q $ W.tell mempty{sdCteClause = [clause]} Q $ W.tell mempty{sdCteClause = [clause]}
pure refFrom pure refFrom
type family ToAliasT a where {-# DEPRECATED ToAliasT "This type alias doesn't do anything. Please delete it. Will be removed in the next release." #-}
ToAliasT (SqlExpr (Value a)) = SqlExpr (Value a) type ToAliasT a = a
ToAliasT (SqlExpr (Entity a)) = SqlExpr (Entity a)
ToAliasT (SqlExpr (Maybe (Entity a))) = SqlExpr (Maybe (Entity a))
ToAliasT (a, b) = (ToAliasT a, ToAliasT b)
ToAliasT (a, b, c) = (ToAliasT a, ToAliasT b, ToAliasT c)
ToAliasT (a, b, c, d) = (ToAliasT a, ToAliasT b, ToAliasT c, ToAliasT d)
ToAliasT (a, b, c, d, e) = (ToAliasT a, ToAliasT b, ToAliasT c, ToAliasT d, ToAliasT e)
ToAliasT (a, b, c, d, e, f) = (ToAliasT a, ToAliasT b, ToAliasT c, ToAliasT d, ToAliasT e, ToAliasT f)
ToAliasT (a, b, c, d, e, f, g) = (ToAliasT a, ToAliasT b, ToAliasT c, ToAliasT d, ToAliasT e, ToAliasT f, ToAliasT g)
ToAliasT (a, b, c, d, e, f, g, h) = (ToAliasT a, ToAliasT b, ToAliasT c, ToAliasT d, ToAliasT e, ToAliasT f, ToAliasT g, ToAliasT h)
-- Tedious tuple magic -- Tedious tuple magic
class ToAlias a where class ToAlias a where
toAlias :: a -> SqlQuery (ToAliasT a) toAlias :: a -> SqlQuery a
instance ToAlias (SqlExpr (Value a)) where instance ToAlias (SqlExpr (Value a)) where
toAlias v@(EAliasedValue _ _) = pure v toAlias v@(EAliasedValue _ _) = pure v
@ -1451,22 +1358,12 @@ instance ( ToAlias a
) => ToAlias (a,b,c,d,e,f,g,h) where ) => ToAlias (a,b,c,d,e,f,g,h) where
toAlias x = to8 <$> (toAlias $ from8 x) 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 family ToAliasReferenceT a where type ToAliasReferenceT a = a
ToAliasReferenceT (SqlExpr (Value a)) = SqlExpr (Value a)
ToAliasReferenceT (SqlExpr (Entity a)) = SqlExpr (Entity a)
ToAliasReferenceT (SqlExpr (Maybe (Entity a))) = SqlExpr (Maybe (Entity a))
ToAliasReferenceT (a,b) = (ToAliasReferenceT a, ToAliasReferenceT b)
ToAliasReferenceT (a,b,c) = (ToAliasReferenceT a, ToAliasReferenceT b, ToAliasReferenceT c)
ToAliasReferenceT (a, b, c, d) = (ToAliasReferenceT a, ToAliasReferenceT b, ToAliasReferenceT c, ToAliasReferenceT d)
ToAliasReferenceT (a, b, c, d, e) = (ToAliasReferenceT a, ToAliasReferenceT b, ToAliasReferenceT c, ToAliasReferenceT d, ToAliasReferenceT e)
ToAliasReferenceT (a, b, c, d, e, f) = (ToAliasReferenceT a, ToAliasReferenceT b, ToAliasReferenceT c, ToAliasReferenceT d, ToAliasReferenceT e, ToAliasReferenceT f)
ToAliasReferenceT (a, b, c, d, e, f, g) = (ToAliasReferenceT a, ToAliasReferenceT b, ToAliasReferenceT c, ToAliasReferenceT d, ToAliasReferenceT e, ToAliasReferenceT f, ToAliasReferenceT g)
ToAliasReferenceT (a, b, c, d, e, f, g, h) = (ToAliasReferenceT a, ToAliasReferenceT b, ToAliasReferenceT c, ToAliasReferenceT d, ToAliasReferenceT e, ToAliasReferenceT f, ToAliasReferenceT g, ToAliasReferenceT h)
-- more tedious tuple magic -- more tedious tuple magic
class ToAliasReference a where class ToAliasReference a where
toAliasReference :: Ident -> a -> SqlQuery (ToAliasReferenceT a) toAliasReference :: Ident -> a -> SqlQuery a
instance ToAliasReference (SqlExpr (Value a)) where instance ToAliasReference (SqlExpr (Value a)) where
toAliasReference aliasSource (EAliasedValue aliasIdent _) = pure $ EValueReference aliasSource (\_ -> aliasIdent) toAliasReference aliasSource (EAliasedValue aliasIdent _) = pure $ EValueReference aliasSource (\_ -> aliasIdent)
@ -1482,6 +1379,7 @@ instance ToAliasReference (SqlExpr (Entity a)) where
instance ToAliasReference (SqlExpr (Maybe (Entity a))) where instance ToAliasReference (SqlExpr (Maybe (Entity a))) where
toAliasReference s (EMaybe e) = EMaybe <$> toAliasReference s e toAliasReference s (EMaybe e) = EMaybe <$> toAliasReference s e
instance (ToAliasReference a, ToAliasReference b) => ToAliasReference (a, b) where instance (ToAliasReference a, ToAliasReference b) => ToAliasReference (a, b) where
toAliasReference ident (a,b) = (,) <$> (toAliasReference ident a) <*> (toAliasReference ident b) toAliasReference ident (a,b) = (,) <$> (toAliasReference ident a) <*> (toAliasReference ident b)