@@ -199,21 +199,21 @@ queryStatement q = UnsafeManipulation $ renderQuery q <> ";"
199INSERT statements
199INSERT statements
200-----------------------------------------}
200-----------------------------------------}
202−-- | Insert multiple rws.
202+-- | Insert multiple rows.
204-- When a table is created, it contains no data. The first thing to do
204-- When a table is created, it contains no data. The first thing to do
205-- before a database can be of much use is to insert data. Data is
205-- before a database can be of much use is to insert data. Data is
206−-- conceptually inserted one rw at a time. Of course you can also insert
206+-- conceptually inserted one row at a time. Of course you can also insert
207−-- more than one rw, but there is no way to insert less than one rw.
207+-- more than one row, but there is no way to insert less than one row.
208−-- Even if you know only some column values, a complete rw must be created.
208+-- Even if you know only some column values, a complete row must be created.
209insertRows
209insertRows
210 :: ( SOP.SListI columns
210 :: ( SOP.SListI columns
211 , SOP.SListI results
211 , SOP.SListI results
212 , Has tab schema ('Table table)
212 , Has tab schema ('Table table)
213 , columns ~ TableToColumns table )
213 , columns ~ TableToColumns table )
214 => Alias tab -- ^ table to insert into
214 => Alias tab -- ^ table to insert into
215− -> NP (Aliased (ColumnValue '[] params)) columns -- ^ rw to insert
215+ -> NP (Aliased (ColumnValue '[] params)) columns -- ^ row to insert
216− -> [NP (Aliased (ColumnValue '[] params)) columns] -- ^ more rws to insert
216+ -> [NP (Aliased (ColumnValue '[] params)) columns] -- ^ more rows to insert
217 -> ConflictClause columns params
217 -> ConflictClause columns params
218 -- ^ what to do in case of constraint conflict
218 -- ^ what to do in case of constraint conflict
219 -> ReturningClause columns params results -- ^ results to return
219 -> ReturningClause columns params results -- ^ results to return
@@ -235,39 +235,39 @@ insertRows tab rw rws conflict returning = UnsafeManipulation $
235 Default -> "DEFAULT"
235 Default -> "DEFAULT"
236 Set expression -> renderExpression expression
236 Set expression -> renderExpression expression
238−-- | Insert a single rw.
238+-- | Insert a single row.
240 :: ( SOP.SListI columns
240 :: ( SOP.SListI columns
241 , SOP.SListI results
241 , SOP.SListI results
242 , Has tab schema ('Table table)
242 , Has tab schema ('Table table)
243 , columns ~ TableToColumns table )
243 , columns ~ TableToColumns table )
244 => Alias tab -- ^ table to insert into
244 => Alias tab -- ^ table to insert into
245− -> NP (Aliased (ColumnValue '[] params)) columns -- ^ rw to insert
245+ -> NP (Aliased (ColumnValue '[] params)) columns -- ^ row to insert
246 -> ConflictClause columns params
246 -> ConflictClause columns params
247 -- ^ what to do in case of constraint conflict
247 -- ^ what to do in case of constraint conflict
248 -> ReturningClause columns params results -- ^ results to return
248 -> ReturningClause columns params results -- ^ results to return
249 -> Manipulation schema params results
249 -> Manipulation schema params results
250insertRow tab rw = insertRows tab rw []
250insertRow tab rw = insertRows tab rw []
252−-- | Insert multiple rws returning `Nil` and raising an error on conflicts.
252+-- | Insert multiple rows returning `Nil` and raising an error on conflicts.
253insertRows_
253insertRows_
254 :: ( SOP.SListI columns
254 :: ( SOP.SListI columns
255 , Has tab schema ('Table table)
255 , Has tab schema ('Table table)
256 , columns ~ TableToColumns table )
256 , columns ~ TableToColumns table )
257 => Alias tab -- ^ table to insert into
257 => Alias tab -- ^ table to insert into
258− -> NP (Aliased (ColumnValue '[] params)) columns -- ^ rw to insert
258+ -> NP (Aliased (ColumnValue '[] params)) columns -- ^ row to insert
259− -> [NP (Aliased (ColumnValue '[] params)) columns] -- ^ more rws to insert
259+ -> [NP (Aliased (ColumnValue '[] params)) columns] -- ^ more rows to insert
260 -> Manipulation schema params '[]
260 -> Manipulation schema params '[]
261insertRows_ tab rw rws =
261insertRows_ tab rw rws =
262 insertRows tab rw rws OnConflictDoRaise (Returning Nil)
262 insertRows tab rw rws OnConflictDoRaise (Returning Nil)
264−-- | Insert a single rw returning `Nil` and raising an error on conflicts.
264+-- | Insert a single row returning `Nil` and raising an error on conflicts.
265insertRow_
265insertRow_
266 :: ( SOP.SListI columns
266 :: ( SOP.SListI columns
267 , Has tab schema ('Table table)
267 , Has tab schema ('Table table)
268 , columns ~ TableToColumns table )
268 , columns ~ TableToColumns table )
269 => Alias tab -- ^ table to insert into
269 => Alias tab -- ^ table to insert into
270− -> NP (Aliased (ColumnValue '[] params)) columns -- ^ rw to insert
270+ -> NP (Aliased (ColumnValue '[] params)) columns -- ^ row to insert
271 -> Manipulation schema params '[]
271 -> Manipulation schema params '[]
272insertRow_ tab rw = insertRow tab rw OnConflictDoRaise (Returning Nil)
272insertRow_ tab rw = insertRow tab rw OnConflictDoRaise (Returning Nil)
@@ -300,11 +300,11 @@ insertQuery_
300insertQuery_ tab query =
300insertQuery_ tab query =
301 insertQuery tab query OnConflictDoRaise (Returning Nil)
301 insertQuery tab query OnConflictDoRaise (Returning Nil)
303−-- | `ColumnValue`s are values to insert or update in a rw
303+-- | `ColumnValue`s are values to insert or update in a row
304-- `Same` updates with the same value.
304-- `Same` updates with the same value.
305-- `Default` inserts or updates with the @DEFAULT@ value
305-- `Default` inserts or updates with the @DEFAULT@ value
306-- `Set` a value to be an `Expression`, relative to the given
306-- `Set` a value to be an `Expression`, relative to the given
307−-- rw for an update, and closed for an insert.
307+-- row for an update, and closed for an insert.
308data ColumnValue
308data ColumnValue
309 (columns :: RelationType)
309 (columns :: RelationType)
310 (params :: [NullityType])
310 (params :: [NullityType])
@@ -317,14 +317,14 @@ data ColumnValue
317 -> ColumnValue columns params (constraint :=> ty)
317 -> ColumnValue columns params (constraint :=> ty)
319-- | A `ReturningClause` computes and return value(s) based
319-- | A `ReturningClause` computes and return value(s) based
320−-- on each rw actually inserted, updated or deleted. This is primarily
320+-- on each row actually inserted, updated or deleted. This is primarily
321-- useful for obtaining values that were supplied by defaults, such as a
321-- useful for obtaining values that were supplied by defaults, such as a
322-- serial sequence number. However, any expression using the table's columns
322-- serial sequence number. However, any expression using the table's columns
323−-- is allowed. Only rws that were successfully inserted or updated or
323+-- is allowed. Only rows that were successfully inserted or updated or
324−-- deleted will be returned. For example, if a rw was locked
324+-- deleted will be returned. For example, if a row was locked
325-- but not updated because an `OnConflictDoUpdate` condition was not satisfied,
325-- but not updated because an `OnConflictDoUpdate` condition was not satisfied,
326−-- the rw will not be returned. `ReturningStar` will return all columns
326+-- the row will not be returned. `ReturningStar` will return all columns
327−-- in the rw. Use @Returning Nil@ in the common case where no return
327+-- in the row. Use @Returning Nil@ in the common case where no return
328-- values are desired.
328-- values are desired.
329data ReturningClause
329data ReturningClause
330 (columns :: ColumnsType)
330 (columns :: ColumnsType)
@@ -352,8 +352,8 @@ renderReturningClause = \case
353-- | A `ConflictClause` specifies an action to perform upon a constraint
353-- | A `ConflictClause` specifies an action to perform upon a constraint
354-- violation. `OnConflictDoRaise` will raise an error.
354-- violation. `OnConflictDoRaise` will raise an error.
355−-- `OnConflictDoNothing` simply avoids inserting a rw.
355+-- `OnConflictDoNothing` simply avoids inserting a row.
356−-- `OnConflictDoUpdate` updates the existing rw that conflicts with the rw
356+-- `OnConflictDoUpdate` updates the existing row that conflicts with the row
357-- proposed for insertion.
357-- proposed for insertion.
358data ConflictClause (columns :: ColumnsType) params where
358data ConflictClause (columns :: ColumnsType) params where
359 OnConflictDoRaise :: ConflictClause columns params
359 OnConflictDoRaise :: ConflictClause columns params
@@ -393,7 +393,7 @@ UPDATE statements
393-----------------------------------------}
393-----------------------------------------}
395-- | An `update` command changes the values of the specified columns
395-- | An `update` command changes the values of the specified columns
396−-- in all rws that satisfy the condition.
396+-- in all rows that satisfy the condition.
398 :: ( SOP.SListI columns
398 :: ( SOP.SListI columns
399 , SOP.SListI results
399 , SOP.SListI results
@@ -403,7 +403,7 @@ update
403 -> NP (Aliased (ColumnValue (ColumnsToRelation columns) params)) columns
403 -> NP (Aliased (ColumnValue (ColumnsToRelation columns) params)) columns
404 -- ^ modified values to replace old values
404 -- ^ modified values to replace old values
405 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
405 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
406− -- ^ condition under which to perform update on a rw
406+ -- ^ condition under which to perform update on a row
407 -> ReturningClause columns params results -- ^ results to return
407 -> ReturningClause columns params results -- ^ results to return
408 -> Manipulation schema params results
408 -> Manipulation schema params results
409update tab columns wh returning = UnsafeManipulation $
409update tab columns wh returning = UnsafeManipulation $
@@ -424,7 +424,7 @@ update tab columns wh returning = UnsafeManipulation $
424 Set expression `As` column -> Just $
424 Set expression `As` column -> Just $
425 renderAlias column <+> "=" <+> renderExpression expression
425 renderAlias column <+> "=" <+> renderExpression expression
427−-- | Update a rw returning `Nil`.
427+-- | Update a row returning `Nil`.
429 :: ( SOP.SListI columns
429 :: ( SOP.SListI columns
430 , Has tab schema ('Table table)
430 , Has tab schema ('Table table)
@@ -433,7 +433,7 @@ update_
433 -> NP (Aliased (ColumnValue (ColumnsToRelation columns) params)) columns
433 -> NP (Aliased (ColumnValue (ColumnsToRelation columns) params)) columns
434 -- ^ modified values to replace old values
434 -- ^ modified values to replace old values
435 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
435 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
436− -- ^ condition under which to perform update on a rw
436+ -- ^ condition under which to perform update on a row
437 -> Manipulation schema params '[]
437 -> Manipulation schema params '[]
438update_ tab columns wh = update tab columns wh (Returning Nil)
438update_ tab columns wh = update tab columns wh (Returning Nil)
@@ -441,14 +441,14 @@ update_ tab columns wh = update tab columns wh (Returning Nil)
441DELETE statements
441DELETE statements
442-----------------------------------------}
442-----------------------------------------}
444−-- | Delete rws of a table.
444+-- | Delete rows of a table.
445deleteFrom
445deleteFrom
446 :: ( SOP.SListI results
446 :: ( SOP.SListI results
447 , Has tab schema ('Table table)
447 , Has tab schema ('Table table)
448 , columns ~ TableToColumns table )
448 , columns ~ TableToColumns table )
449 => Alias tab -- ^ table to delete from
449 => Alias tab -- ^ table to delete from
450 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
450 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
451− -- ^ condition under which to delete a rw
451+ -- ^ condition under which to delete a row
452 -> ReturningClause columns params results -- ^ results to return
452 -> ReturningClause columns params results -- ^ results to return
453 -> Manipulation schema params results
453 -> Manipulation schema params results
454deleteFrom tab wh returning = UnsafeManipulation $
454deleteFrom tab wh returning = UnsafeManipulation $
@@ -456,13 +456,13 @@ deleteFrom tab wh returning = UnsafeManipulation $
456 <+> "WHERE" <+> renderExpression wh
456 <+> "WHERE" <+> renderExpression wh
457 <> renderReturningClause returning
457 <> renderReturningClause returning
459−-- | Delete rws returning `Nil`.
459+-- | Delete rows returning `Nil`.
460deleteFrom_
460deleteFrom_
461 :: ( Has tab schema ('Table table)
461 :: ( Has tab schema ('Table table)
462 , columns ~ TableToColumns table )
462 , columns ~ TableToColumns table )
463 => Alias tab -- ^ table to delete from
463 => Alias tab -- ^ table to delete from
464 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
464 -> Condition '[tab ::: ColumnsToRelation columns] 'Ungrouped params
465− -- ^ condition under which to delete a rw
465+ -- ^ condition under which to delete a row
466 -> Manipulation schema params '[]
466 -> Manipulation schema params '[]
467deleteFrom_ tab wh = deleteFrom tab wh (Returning Nil)
467deleteFrom_ tab wh = deleteFrom tab wh (Returning Nil)
@@ -480,11 +480,11 @@ WITH statements
481-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
481-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
482-- manipulation = with
482-- manipulation = with
483−-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rws :* Nil)
483+-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rows :* Nil)
484−-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rws `As` #t)))))
484+-- (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `As` #t)))))
485-- in renderManipulation manipulation
485-- in renderManipulation manipulation
487−-- "WITH \"deleted_rws\" AS (DELETE FROM \"products\" WHERE (\"date\" < ($1 :: date)) RETURNING *) INSERT INTO \"products_deleted\" SELECT * FROM \"deleted_rws\" AS \"t\";"
487+-- "WITH \"deleted_rows\" AS (DELETE FROM \"products\" WHERE (\"date\" < ($1 :: date)) RETURNING *) INSERT INTO \"products_deleted\" SELECT * FROM \"deleted_rows\" AS \"t\";"
489 :: SOP.SListI commons
489 :: SOP.SListI commons
490 => NP (Aliased (Manipulation schema params)) commons
490 => NP (Aliased (Manipulation schema params)) commons