on dev help sign in
name changes for group and by
commit370076224a5b947259669d364c6be3e2ee466c3a authorEitan Chatav <eitan.chatav@gmail.com> dateMon 2 Jul 2018, 16:49 (8 years ago) parent6216d16
1 file changed+15−14
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+15−14
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+15−14
@@ -50,7 +50,7 @@ module Squeal.PostgreSQL.Query
5050 , renderTableExpression
5151 , from
5252 , where_
53− , group
53+ , groupBy
5454 , having
5555 , orderBy
5656 , limit
@@ -66,7 +66,7 @@ module Squeal.PostgreSQL.Query
6666 , rightOuterJoin
6767 , fullOuterJoin
6868 -- * Grouping
69− , By (By, By2)
69+ , By (By1, By2)
7070 , renderBy
7171 , GroupByClause (NoGroups, Group)
7272 , renderGroupByClause
@@ -191,7 +191,7 @@ let
191191 query =
192192 select (sum_ #col2 `as` #sum :* #col1)
193193 ( from (table (#tab `as` #table1))
194− & group (#table1 ! #col1)
194+ & groupBy #col1
195195 & having (#col1 + sum_ #col2 .> 1) )
196196in printSQL query
197197:}
@@ -604,15 +604,15 @@ where_
604604 -> TableExpression schema params relations grouping
605605where_ wh rels = rels {whereClause = wh : whereClause rels}
606606
607−-- | A `group` is a transformation of `TableExpression`s which switches
607+-- | A `groupBy` is a transformation of `TableExpression`s which switches
608608-- its `Grouping` from `Ungrouped` to `Grouped`. Use @group Nil@ to perform
609609-- a "grand total" aggregation query.
610−group
610+groupBy
611611 :: SListI bys
612612 => NP (By relations) bys -- ^ grouped columns
613613 -> TableExpression schema params relations 'Ungrouped
614614 -> TableExpression schema params relations ('Grouped bys)
615−group bys rels = TableExpression
615+groupBy bys rels = TableExpression
616616 { fromClause = fromClause rels
617617 , whereClause = whereClause rels
618618 , groupByClause = Group bys
@@ -786,33 +786,34 @@ Grouping
786786data By
787787 (relations :: RelationsType)
788788 (by :: (Symbol,Symbol)) where
789− By
789+ By1
790790 :: (HasUnique relation relations columns, Has column columns ty)
791791 => Alias column
792792 -> By relations '(relation, column)
793793 By2
794794 :: (Has relation relations columns, Has column columns ty)
795− => (Alias relation, Alias column)
795+ => Alias relation
796+ -> Alias column
796797 -> By relations '(relation, column)
797798deriving instance Show (By relations by)
798799deriving instance Eq (By relations by)
799800deriving instance Ord (By relations by)
800801
801802instance (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
803804instance (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
805806instance (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
807808instance (Has rel rels cols, Has col cols ty, bys ~ '[ '(rel, col)])
808809 => IsQualified rel col (NP (By rels) bys) where
809− rel ! col = By2 (rel, col) :* Nil
810+ rel ! col = By2 rel col :* Nil
810811
811812-- | Renders a `By`.
812813renderBy :: By relations by -> ByteString
813814renderBy = \case
814− By column -> renderAlias column
815− By2 (rel, column) -> renderAlias rel <> "." <> renderAlias column
815+ By1 column -> renderAlias column
816+ By2 rel column -> renderAlias rel <> "." <> renderAlias column
816817
817818-- | A `GroupByClause` indicates the `Grouping` of a `TableExpression`.
818819-- A `NoGroups` indicates `Ungrouped` while a `Group` indicates `Grouped`.