@@ -213,21 +213,21 @@ joins:
214 query :: Query
214 query :: Query
215 '[ "orders" :::
215 '[ "orders" :::
216− '["pk" ::: PrimaryKey '["id"]
216+ '["pk_orders" ::: PrimaryKey '["id"]
217− ,"fk_customer" ::: ForeignKey '["customer_id"] "customers" '["id"]
217+ ,"fk_customers" ::: ForeignKey '["customer_id"] "customers" '["id"]
218− ,"fk_shipper" ::: ForeignKey '["shipper_id"] "shippers" '["id"]] :=>
218+ ,"fk_shippers" ::: ForeignKey '["shipper_id"] "shippers" '["id"]] :=>
219 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
219 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
220 , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4
220 , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4
221 , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
221 , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
222 , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4
222 , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4
224 , "customers" :::
224 , "customers" :::
225− '["pk" ::: PrimaryKey '["id"]] :=>
225+ '["pk_customers" ::: PrimaryKey '["id"]] :=>
226 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
226 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
227 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
227 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
229 , "shippers" :::
229 , "shippers" :::
230− '["pk" ::: PrimaryKey '["id"]] :=>
230+ '["pk_shippers" ::: PrimaryKey '["id"]] :=>
231 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
231 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
232 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
232 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
@@ -412,7 +412,7 @@ selectDistinctStar rels = UnsafeQuery $
412selectDotStar
412selectDotStar
413 :: Has relation relations columns
413 :: Has relation relations columns
414 => Alias relation
414 => Alias relation
415− -- ^ particular virtual Table
415+ -- ^ particular virtual subtable
416 -> TableExpression schema params relations 'Ungrouped
416 -> TableExpression schema params relations 'Ungrouped
417 -- ^ intermediate virtual table
417 -- ^ intermediate virtual table
418 -> Query schema params columns
418 -> Query schema params columns
@@ -424,7 +424,7 @@ selectDotStar rel relations = UnsafeQuery $
424selectDistinctDotStar
424selectDistinctDotStar
425 :: Has relation relations columns
425 :: Has relation relations columns
426 => Alias relation
426 => Alias relation
427− -- ^ particular virtual Table
427+ -- ^ particular virtual table
428 -> TableExpression schema params relations 'Ungrouped
428 -> TableExpression schema params relations 'Ungrouped
429 -- ^ intermediate virtual table
429 -- ^ intermediate virtual table
430 -> Query schema params columns
430 -> Query schema params columns
@@ -612,9 +612,9 @@ subquery
612 -> FromClause schema params '[table]
612 -> FromClause schema params '[table]
613subquery = UnsafeFromClause . renderAliasedAs (parenthesized . renderQuery)
613subquery = UnsafeFromClause . renderAliasedAs (parenthesized . renderQuery)
615−{- | @t1 & crossJoin t2@. For every possible combination of rows from
615+{- | @left & crossJoin right@. For every possible combination of rows from
616− @t1@ and @t2@ (i.e., a Cartesian product), the joined table will contain
616+ @left@ and @right@ (i.e., a Cartesian product), the joined table will contain
617− a row consisting of all columns in @t1@ followed by all columns in @t2@.
617+ a row consisting of all columns in @left@ followed by all columns in @right@.
618 If the tables have @n@ and @m@ rows respectively, the joined table will
618 If the tables have @n@ and @m@ rows respectively, the joined table will
619 have @n * m@ rows.
619 have @n * m@ rows.
@@ -627,15 +627,14 @@ crossJoin
627crossJoin right left = UnsafeFromClause $
627crossJoin right left = UnsafeFromClause $
628 renderFromClause left <+> "CROSS JOIN" <+> renderFromClause right
628 renderFromClause left <+> "CROSS JOIN" <+> renderFromClause right
630−{- | @t1 & InnerJoin t2 on@. For each row @r1@ of @t1@, the joined
630+{- | @left & innerJoin right on@. The joined table is filtered by
631− table has a row for each row in @t2@ that satisfies the @on@ condition
631+the @on@ condition.
635 :: FromClause schema params right
634 :: FromClause schema params right
636 -- ^ right
635 -- ^ right
637 -> Condition (Join left right) 'Ungrouped params
636 -> Condition (Join left right) 'Ungrouped params
638− -- ^ @ON@ condition
637+ -- ^ @on@ condition
639 -> FromClause schema params left
638 -> FromClause schema params left
640 -- ^ left
639 -- ^ left
641 -> FromClause schema params (Join left right)
640 -> FromClause schema params (Join left right)
@@ -643,16 +642,16 @@ innerJoin right on left = UnsafeFromClause $
643 renderFromClause left <+> "INNER JOIN" <+> renderFromClause right
642 renderFromClause left <+> "INNER JOIN" <+> renderFromClause right
644 <+> "ON" <+> renderExpression on
643 <+> "ON" <+> renderExpression on
646−{- | @t1 & LeftOuterJoin t2 on@. First, an inner join is performed.
645+{- | @left & leftOuterJoin right on@. First, an inner join is performed.
647− Then, for each row in @t1@ that does not satisfy the @on@ condition with
646+ Then, for each row in @left@ that does not satisfy the @on@ condition with
648− any row in @t2@, a joined row is added with null values in columns of @t2@.
647+ any row in @right@, a joined row is added with null values in columns of @right@.
649− Thus, the joined table always has at least one row for each row in @t1@.
648+ Thus, the joined table always has at least one row for each row in @left@.
651leftOuterJoin
650leftOuterJoin
652 :: FromClause schema params right
651 :: FromClause schema params right
653 -- ^ right
652 -- ^ right
654 -> Condition (Join left right) 'Ungrouped params
653 -> Condition (Join left right) 'Ungrouped params
655− -- ^ @ON@ condition
654+ -- ^ @on@ condition
656 -> FromClause schema params left
655 -> FromClause schema params left
657 -- ^ left
656 -- ^ left
658 -> FromClause schema params (Join left (NullifyRelations right))
657 -> FromClause schema params (Join left (NullifyRelations right))
@@ -660,17 +659,17 @@ leftOuterJoin right on left = UnsafeFromClause $
660 renderFromClause left <+> "LEFT OUTER JOIN" <+> renderFromClause right
659 renderFromClause left <+> "LEFT OUTER JOIN" <+> renderFromClause right
661 <+> "ON" <+> renderExpression on
660 <+> "ON" <+> renderExpression on
663−{- | @t1 & RightOuterJoin t2 on@. First, an inner join is performed.
662+{- | @left & rightOuterJoin right on@. First, an inner join is performed.
664− Then, for each row in @t2@ that does not satisfy the @on@ condition with
663+ Then, for each row in @right@ that does not satisfy the @on@ condition with
665− any row in @t1@, a joined row is added with null values in columns of @t1@.
664+ any row in @left@, a joined row is added with null values in columns of @left@.
666 This is the converse of a left join: the result table will always
665 This is the converse of a left join: the result table will always
667− have a row for each row in @t2@.
666+ have a row for each row in @right@.
669rightOuterJoin
668rightOuterJoin
670 :: FromClause schema params right
669 :: FromClause schema params right
671 -- ^ right
670 -- ^ right
672 -> Condition (Join left right) 'Ungrouped params
671 -> Condition (Join left right) 'Ungrouped params
673− -- ^ @ON@ condition
672+ -- ^ @on@ condition
674 -> FromClause schema params left
673 -> FromClause schema params left
675 -- ^ left
674 -- ^ left
676 -> FromClause schema params (Join (NullifyRelations left) right)
675 -> FromClause schema params (Join (NullifyRelations left) right)
@@ -678,18 +677,18 @@ rightOuterJoin right on left = UnsafeFromClause $
678 renderFromClause left <+> "RIGHT OUTER JOIN" <+> renderFromClause right
677 renderFromClause left <+> "RIGHT OUTER JOIN" <+> renderFromClause right
679 <+> "ON" <+> renderExpression on
678 <+> "ON" <+> renderExpression on
681−{- | @t1 & FullOuterJoin t2 on@. First, an inner join is performed.
680+{- | @left & fullOuterJoin right on@. First, an inner join is performed.
682− Then, for each row in @t1@ that does not satisfy the @on@ condition with
681+ Then, for each row in @left@ that does not satisfy the @on@ condition with
683− any row in @t2@, a joined row is added with null values in columns of @t2@.
682+ any row in @right@, a joined row is added with null values in columns of @right@.
684− Also, for each row of @t2@ that does not satisfy the join condition
683+ Also, for each row of @right@ that does not satisfy the join condition
685− with any row in @t1@, a joined row with null values in the columns of @t1@
684+ with any row in @left@, a joined row with null values in the columns of @left@
686 is added.
685 is added.
688fullOuterJoin
687fullOuterJoin
689 :: FromClause schema params right
688 :: FromClause schema params right
690 -- ^ right
689 -- ^ right
691 -> Condition (Join left right) 'Ungrouped params
690 -> Condition (Join left right) 'Ungrouped params
692− -- ^ @ON@ condition
691+ -- ^ @on@ condition
693 -> FromClause schema params left
692 -> FromClause schema params left
694 -- ^ left
693 -- ^ left
695 -> FromClause schema params
694 -> FromClause schema params
@@ -732,7 +731,8 @@ renderBy = \case
732-- A `NoGroups` indicates `Ungrouped` while a `Group` indicates `Grouped`.
731-- A `NoGroups` indicates `Ungrouped` while a `Group` indicates `Grouped`.
733-- @NoGroups@ is distinguised from @Group Nil@ since no aggregation can be
732-- @NoGroups@ is distinguised from @Group Nil@ since no aggregation can be
734-- done on @NoGroups@ while all output `Expression`s must be aggregated
733-- done on @NoGroups@ while all output `Expression`s must be aggregated
735−-- in @Group Nil@.
734+-- in @Group Nil@. In general, all output `Expression`s in the
735+-- complement of @bys@ must be aggregated in @Group bys@.
736data GroupByClause relations grouping where
736data GroupByClause relations grouping where
737 NoGroups :: GroupByClause relations 'Ungrouped
737 NoGroups :: GroupByClause relations 'Ungrouped