@@ -11,14 +11,17 @@ Squeal queries.
11{-# LANGUAGE
11{-# LANGUAGE
12 DeriveGeneric
12 DeriveGeneric
13 , FlexibleContexts
13 , FlexibleContexts
15 , GeneralizedNewtypeDeriving
16 , GeneralizedNewtypeDeriving
16 , LambdaCase
17 , LambdaCase
18+ , MultiParamTypeClasses
17 , OverloadedStrings
19 , OverloadedStrings
18 , StandaloneDeriving
20 , StandaloneDeriving
19 , TypeFamilies
21 , TypeFamilies
20 , TypeInType
22 , TypeInType
21 , TypeOperators
23 , TypeOperators
24+ , UndecidableInstances
24module Squeal.PostgreSQL.Query
27module Squeal.PostgreSQL.Query
@@ -188,7 +191,7 @@ let
189 select (sum_ #col2 `as` #sum :* #col1)
192 select (sum_ #col2 `as` #sum :* #col1)
190 ( from (table (#tab `as` #table1))
193 ( from (table (#tab `as` #table1))
191− & group (By #col1 :* Nil)
194+ & group (#table1 ! #col1)
192 & having (#col1 + sum_ #col2 .> 1) )
195 & having (#col1 + sum_ #col2 .> 1) )
193in printSQL query
196in printSQL query
@@ -795,6 +798,16 @@ deriving instance Show (By relations by)
795deriving instance Eq (By relations by)
798deriving instance Eq (By relations by)
796deriving instance Ord (By relations by)
799deriving instance Ord (By relations by)
801+instance (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col))
802+ => IsLabel col (By rels by) where fromLabel = By fromLabel
803+instance (HasUnique rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
804+ => IsLabel col (NP (By rels) bys) where fromLabel = By fromLabel :* Nil
805+instance (Has rel rels cols, Has col cols ty, by ~ '(rel, col))
806+ => IsQualified rel col (By rels by) where (!) = curry By2
807+instance (Has rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
808+ => IsQualified rel col (NP (By rels) bys) where
809+ rel ! col = By2 (rel, col) :* Nil
798-- | Renders a `By`.
811-- | Renders a `By`.
799renderBy :: By relations by -> ByteString
812renderBy :: By relations by -> ByteString
800renderBy = \case
813renderBy = \case