@@ -50,7 +50,7 @@ module Squeal.PostgreSQL.Query
50 , renderTableExpression
50 , renderTableExpression
@@ -66,7 +66,7 @@ module Squeal.PostgreSQL.Query
66 , rightOuterJoin
66 , rightOuterJoin
67 , fullOuterJoin
67 , fullOuterJoin
68 -- * Grouping
68 -- * Grouping
69− , By (By, By2)
69+ , By (By1, By2)
70 , renderBy
70 , renderBy
71 , GroupByClause (NoGroups, Group)
71 , GroupByClause (NoGroups, Group)
72 , renderGroupByClause
72 , renderGroupByClause
@@ -191,7 +191,7 @@ let
192 select (sum_ #col2 `as` #sum :* #col1)
192 select (sum_ #col2 `as` #sum :* #col1)
193 ( from (table (#tab `as` #table1))
193 ( from (table (#tab `as` #table1))
194− & group (#table1 ! #col1)
194+ & groupBy #col1
195 & having (#col1 + sum_ #col2 .> 1) )
195 & having (#col1 + sum_ #col2 .> 1) )
196in printSQL query
196in printSQL query
@@ -604,15 +604,15 @@ where_
604 -> TableExpression schema params relations grouping
604 -> TableExpression schema params relations grouping
605where_ wh rels = rels {whereClause = wh : whereClause rels}
605where_ wh rels = rels {whereClause = wh : whereClause rels}
607−-- | A `group` is a transformation of `TableExpression`s which switches
607+-- | A `groupBy` is a transformation of `TableExpression`s which switches
608-- its `Grouping` from `Ungrouped` to `Grouped`. Use @group Nil@ to perform
608-- its `Grouping` from `Ungrouped` to `Grouped`. Use @group Nil@ to perform
609-- a "grand total" aggregation query.
609-- a "grand total" aggregation query.
611 :: SListI bys
611 :: SListI bys
612 => NP (By relations) bys -- ^ grouped columns
612 => NP (By relations) bys -- ^ grouped columns
613 -> TableExpression schema params relations 'Ungrouped
613 -> TableExpression schema params relations 'Ungrouped
614 -> TableExpression schema params relations ('Grouped bys)
614 -> TableExpression schema params relations ('Grouped bys)
615−group bys rels = TableExpression
615+groupBy bys rels = TableExpression
616 { fromClause = fromClause rels
616 { fromClause = fromClause rels
617 , whereClause = whereClause rels
617 , whereClause = whereClause rels
618 , groupByClause = Group bys
618 , groupByClause = Group bys
@@ -786,33 +786,34 @@ Grouping
787 (relations :: RelationsType)
787 (relations :: RelationsType)
788 (by :: (Symbol,Symbol)) where
788 (by :: (Symbol,Symbol)) where
790 :: (HasUnique relation relations columns, Has column columns ty)
790 :: (HasUnique relation relations columns, Has column columns ty)
791 => Alias column
791 => Alias column
792 -> By relations '(relation, column)
792 -> By relations '(relation, column)
794 :: (Has relation relations columns, Has column columns ty)
794 :: (Has relation relations columns, Has column columns ty)
795− => (Alias relation, Alias column)
795+ => Alias relation
796 -> By relations '(relation, column)
797 -> By relations '(relation, column)
797deriving instance Show (By relations by)
798deriving instance Show (By relations by)
798deriving instance Eq (By relations by)
799deriving instance Eq (By relations by)
799deriving instance Ord (By relations by)
800deriving instance Ord (By relations by)
801instance (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col))
802instance (HasUnique rel rels cols, Has col cols ty, by ~ '(rel, col))
802− => IsLabel col (By rels by) where fromLabel = By fromLabel
803+ => IsLabel col (By rels by) where fromLabel = By1 fromLabel
803instance (HasUnique rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
804instance (HasUnique rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
804− => IsLabel col (NP (By rels) bys) where fromLabel = By fromLabel :* Nil
805+ => IsLabel col (NP (By rels) bys) where fromLabel = By1 fromLabel :* Nil
805instance (Has rel rels cols, Has col cols ty, by ~ '(rel, col))
806instance (Has rel rels cols, Has col cols ty, by ~ '(rel, col))
806− => IsQualified rel col (By rels by) where (!) = curry By2
807+ => IsQualified rel col (By rels by) where (!) = By2
807instance (Has rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
808instance (Has rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
808 => IsQualified rel col (NP (By rels) bys) where
809 => IsQualified rel col (NP (By rels) bys) where
809− rel ! col = By2 (rel, col) :* Nil
810+ rel ! col = By2 rel col :* Nil
811-- | Renders a `By`.
812-- | Renders a `By`.
812renderBy :: By relations by -> ByteString
813renderBy :: By relations by -> ByteString
813renderBy = \case
814renderBy = \case
814− By column -> renderAlias column
815+ By1 column -> renderAlias column
815− By2 (rel, column) -> renderAlias rel <> "." <> renderAlias column
816+ By2 rel column -> renderAlias rel <> "." <> renderAlias column
817-- | A `GroupByClause` indicates the `Grouping` of a `TableExpression`.
818-- | A `GroupByClause` indicates the `Grouping` of a `TableExpression`.
818-- A `NoGroups` indicates `Ungrouped` while a `Group` indicates `Grouped`.
819-- A `NoGroups` indicates `Ungrouped` while a `Group` indicates `Grouped`.