on dev help sign in
call relation table
commit3fe22f69e0adcb3f37690c80b23837a95d645238 authorEitan Chatav <eitan.chatav@gmail.com> dateFri 31 Aug 2018, 18:43 (8 years ago) parent8bac7f4
3 files changed+51−51
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+32−32 squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+11−11 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+8−8
squeal-postgresql/src/Squeal/PostgreSQL/Expression.hs+32−32
@@ -271,79 +271,79 @@ param
271271 => Expression schema from grouping params ty -- ^ param
272272param = parameter @n pgtype
273273
274−instance (HasUnique relation from columns, Has column columns ty)
274+instance (HasUnique table from columns, Has column columns ty)
275275 => IsLabel column (Expression schema from 'Ungrouped params ty) where
276276 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
277−instance (HasUnique relation from columns, Has column columns ty)
277+instance (HasUnique table from columns, Has column columns ty)
278278 => IsLabel column
279279 (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
280280 fromLabel = fromLabel @column `As` Alias @column
281−instance (HasUnique relation from columns, Has column columns ty)
281+instance (HasUnique table from columns, Has column columns ty)
282282 => IsLabel column
283283 (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
284284 fromLabel = fromLabel @column :* Nil
285285
286−instance (Has relation from columns, Has column columns ty)
287− => IsQualified relation column (Expression schema from 'Ungrouped params ty) where
288− relation ! column = UnsafeExpression $
289− renderAlias relation <> "." <> renderAlias column
290−instance (Has relation from columns, Has column columns ty)
291− => IsQualified relation column
286+instance (Has table from columns, Has column columns ty)
287+ => IsQualified table column (Expression schema from 'Ungrouped params ty) where
288+ table ! column = UnsafeExpression $
289+ renderAlias table <> "." <> renderAlias column
290+instance (Has table from columns, Has column columns ty)
291+ => IsQualified table column
292292 (Aliased (Expression schema from 'Ungrouped params) (column ::: ty)) where
293− relation ! column = relation ! column `As` column
294−instance (Has relation from columns, Has column columns ty)
295− => IsQualified relation column
293+ table ! column = table ! column `As` column
294+instance (Has table from columns, Has column columns ty)
295+ => IsQualified table column
296296 (NP (Aliased (Expression schema from 'Ungrouped params)) '[column ::: ty]) where
297− relation ! column = relation ! column :* Nil
297+ table ! column = table ! column :* Nil
298298
299299instance
300− ( HasUnique relation from columns
300+ ( HasUnique table from columns
301301 , Has column columns ty
302− , GroupedBy relation column bys
302+ , GroupedBy table column bys
303303 ) => IsLabel column
304304 (Expression schema from ('Grouped bys) params ty) where
305305 fromLabel = UnsafeExpression $ renderAlias (Alias @column)
306306instance
307− ( HasUnique relation from columns
307+ ( HasUnique table from columns
308308 , Has column columns ty
309− , GroupedBy relation column bys
309+ , GroupedBy table column bys
310310 ) => IsLabel column
311311 ( Aliased (Expression schema from ('Grouped bys) params)
312312 (column ::: ty) ) where
313313 fromLabel = fromLabel @column `As` Alias @column
314314instance
315− ( HasUnique relation from columns
315+ ( HasUnique table from columns
316316 , Has column columns ty
317− , GroupedBy relation column bys
317+ , GroupedBy table column bys
318318 ) => IsLabel column
319319 ( NP (Aliased (Expression schema from ('Grouped bys) params))
320320 '[column ::: ty] ) where
321321 fromLabel = fromLabel @column :* Nil
322322
323323instance
324− ( Has relation from columns
324+ ( Has table from columns
325325 , Has column columns ty
326− , GroupedBy relation column bys
327− ) => IsQualified relation column
326+ , GroupedBy table column bys
327+ ) => IsQualified table column
328328 (Expression schema from ('Grouped bys) params ty) where
329− relation ! column = UnsafeExpression $
330− renderAlias relation <> "." <> renderAlias column
329+ table ! column = UnsafeExpression $
330+ renderAlias table <> "." <> renderAlias column
331331instance
332− ( Has relation from columns
332+ ( Has table from columns
333333 , Has column columns ty
334− , GroupedBy relation column bys
335− ) => IsQualified relation column
334+ , GroupedBy table column bys
335+ ) => IsQualified table column
336336 (Aliased (Expression schema from ('Grouped bys) params)
337337 (column ::: ty)) where
338− relation ! column = relation ! column `As` column
338+ table ! column = table ! column `As` column
339339instance
340− ( Has relation from columns
340+ ( Has table from columns
341341 , Has column columns ty
342− , GroupedBy relation column bys
343− ) => IsQualified relation column
342+ , GroupedBy table column bys
343+ ) => IsQualified table column
344344 ( NP (Aliased (Expression schema from ('Grouped bys) params))
345345 '[column ::: ty]) where
346− relation ! column = relation ! column :* Nil
346+ table ! column = table ! column :* Nil
347347
348348-- | analagous to `Nothing`
349349--
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+11−11
@@ -461,7 +461,7 @@ selectDistinct list rels = UnsafeQuery $
461461-- | The simplest kind of query is `selectStar` which emits all columns
462462-- that the table expression produces.
463463selectStar
464− :: HasUnique relation from columns
464+ :: HasUnique table from columns
465465 => TableExpression schema params from 'Ungrouped
466466 -- ^ intermediate virtual table
467467 -> Query schema params columns
@@ -470,7 +470,7 @@ selectStar rels = UnsafeQuery $ "SELECT" <+> "*" <+> renderTableExpression rels
470470-- | A `selectDistinctStar` emits all columns that the table expression
471471-- produces and eliminates duplicate rows.
472472selectDistinctStar
473− :: HasUnique relation from columns
473+ :: HasUnique table from columns
474474 => TableExpression schema params from 'Ungrouped
475475 -- ^ intermediate virtual table
476476 -> Query schema params columns
@@ -480,8 +480,8 @@ selectDistinctStar rels = UnsafeQuery $
480480-- | When working with multiple tables, it can also be useful to ask
481481-- for all the columns of a particular table, using `selectDotStar`.
482482selectDotStar
483− :: Has relation from columns
484− => Alias relation
483+ :: Has table from columns
484+ => Alias table
485485 -- ^ particular virtual subtable
486486 -> TableExpression schema params from 'Ungrouped
487487 -- ^ intermediate virtual table
@@ -492,8 +492,8 @@ selectDotStar rel tab = UnsafeQuery $
492492-- | A `selectDistinctDotStar` asks for all the columns of a particular table,
493493-- and eliminates duplicate rows.
494494selectDistinctDotStar
495− :: Has relation from columns
496− => Alias relation
495+ :: Has table from columns
496+ => Alias table
497497 -- ^ particular virtual table
498498 -> TableExpression schema params from 'Ungrouped
499499 -- ^ intermediate virtual table
@@ -1012,14 +1012,14 @@ data By
10121012 (from :: FromType)
10131013 (by :: (Symbol,Symbol)) where
10141014 By1
1015− :: (HasUnique relation from columns, Has column columns ty)
1015+ :: (HasUnique table from columns, Has column columns ty)
10161016 => Alias column
1017− -> By from '(relation, column)
1017+ -> By from '(table, column)
10181018 By2
1019− :: (Has relation from columns, Has column columns ty)
1020− => Alias relation
1019+ :: (Has table from columns, Has column columns ty)
1020+ => Alias table
10211021 -> Alias column
1022− -> By from '(relation, column)
1022+ -> By from '(table, column)
10231023deriving instance Show (By from by)
10241024deriving instance Eq (By from by)
10251025deriving instance Ord (By from by)
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+8−8
@@ -337,7 +337,7 @@ type family ColumnsToRow (columns :: ColumnsType) :: RowType where
337337type family TableToColumns (table :: TableType) :: ColumnsType where
338338 TableToColumns (constraints :=> columns) = columns
339339
340−-- | Convert a table to a relation.
340+-- | Convert a table to a row type.
341341type family TableToRow (table :: TableType) :: RowType where
342342 TableToRow tab = ColumnsToRow (TableToColumns tab)
343343
@@ -352,15 +352,15 @@ data Grouping
352352a member of the auxiliary namespace created by @GROUP BY@ clauses and thus,
353353may be called in an output `Squeal.PostgreSQL.Expression.Expression` without aggregating.
354354-}
355−class (KnownSymbol relation, KnownSymbol column)
356− => GroupedBy relation column bys where
357−instance {-# OVERLAPPING #-} (KnownSymbol relation, KnownSymbol column)
358− => GroupedBy relation column ('(table,column) ': bys)
355+class (KnownSymbol table, KnownSymbol column)
356+ => GroupedBy table column bys where
357+instance {-# OVERLAPPING #-} (KnownSymbol table, KnownSymbol column)
358+ => GroupedBy table column ('(table,column) ': bys)
359359instance {-# OVERLAPPABLE #-}
360− ( KnownSymbol relation
360+ ( KnownSymbol table
361361 , KnownSymbol column
362− , GroupedBy relation column bys
363− ) => GroupedBy relation column (tabcol ': bys)
362+ , GroupedBy table column bys
363+ ) => GroupedBy table column (tabcol ': bys)
364364
365365-- | `Alias`es are proxies for a type level string or `Symbol`
366366-- and have an `IsLabel` instance so that with @-XOverloadedLabels@