on dev help sign in
some more docs for defs
commitab0b36d7ee72612d762fd1fa05e28112af7bd30d authorEitan Chatav <eitan.chatav@gmail.com> dateWed 23 Aug 2017, 10:52 (9 years ago) parent1a0159c
1 file changed+16−16
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+16−16
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+16−16
@@ -158,6 +158,7 @@ newtype TableConstraint
158158-- "CREATE TABLE tab (a int NOT NULL, b int NOT NULL, CHECK ((a > b)));"
159159check
160160 :: Condition '[table ::: columns] 'Ungrouped '[]
161+ -- ^ condition to check
161162 -> TableConstraint schema columns
162163check condition = UnsafeTableConstraint $
163164 "CHECK" <+> parenthesized (renderExpression condition)
@@ -176,6 +177,7 @@ check condition = UnsafeTableConstraint $
176177unique
177178 :: SListI subcolumns
178179 => NP (Column columns) subcolumns
180+ -- ^ unique column or group of columns
179181 -> TableConstraint schema columns
180182unique columns = UnsafeTableConstraint $
181183 "UNIQUE" <+> parenthesized (renderCommaSeparated renderColumn columns)
@@ -307,7 +309,7 @@ DROP statements
307309-- "DROP TABLE muh_table;"
308310dropTable
309311 :: KnownSymbol table
310− => Alias table
312+ => Alias table -- ^ table to remove
311313 -> Definition schema (Drop table schema)
312314dropTable table = UnsafeDefinition $ "DROP TABLE" <+> renderAlias table <> ";"
313315
@@ -333,8 +335,8 @@ alterTable table alteration = UnsafeDefinition $
333335-- "ALTER TABLE foo RENAME TO bar;"
334336alterTableRename
335337 :: (KnownSymbol table0, KnownSymbol table1)
336− => Alias table0
337− -> Alias table1
338+ => Alias table0 -- ^ table to rename
339+ -> Alias table1 -- ^ what to rename it
338340 -> Definition schema (Rename table0 table1 schema)
339341alterTableRename table0 table1 = UnsafeDefinition $
340342 "ALTER TABLE" <+> renderAlias table0
@@ -353,8 +355,8 @@ alterTableRename table0 table1 = UnsafeDefinition $
353355-- "ALTER TABLE tab ADD CHECK ((col > 0));"
354356alterTableAddConstraint
355357 :: HasTable table schema columns
356− => Alias table
357− -> TableConstraint schema columns
358+ => Alias table -- ^ table to constrain
359+ -> TableConstraint schema columns -- ^ what constraint to add
358360 -> Definition schema schema
359361alterTableAddConstraint table constraint = UnsafeDefinition $
360362 "ALTER TABLE" <+> renderAlias table
@@ -407,8 +409,8 @@ addColumnDefault column ty = UnsafeAlterColumns $
407409-- "ALTER TABLE tab ADD COLUMN col2 text;"
408410addColumnNull
409411 :: KnownSymbol column
410− => Alias column
411− -> TypeExpression ('Required ('Null ty))
412+ => Alias column -- ^ column to add
413+ -> TypeExpression ('Required ('Null ty)) -- ^ type of the new column
412414 -> AlterColumns columns (Create column ('Required ('Null ty)) columns)
413415addColumnNull column ty = UnsafeAlterColumns $
414416 "ADD COLUMN" <+> renderAlias column <+> renderTypeExpression ty
@@ -431,7 +433,7 @@ addColumnNull column ty = UnsafeAlterColumns $
431433-- "ALTER TABLE tab DROP COLUMN col2;"
432434dropColumn
433435 :: KnownSymbol column
434− => Alias column
436+ => Alias column -- ^ column to remove
435437 -> AlterColumns columns (Drop column columns)
436438dropColumn column = UnsafeAlterColumns $
437439 "DROP COLUMN" <+> renderAlias column
@@ -452,7 +454,7 @@ dropColumn column = UnsafeAlterColumns $
452454-- "ALTER TABLE tab DROP COLUMN col2 CASCADE;"
453455dropColumnCascade
454456 :: KnownSymbol column
455− => Alias column
457+ => Alias column -- ^ column to remove
456458 -> AlterColumns columns (Drop column columns)
457459dropColumnCascade column = UnsafeAlterColumns $
458460 "DROP COLUMN" <+> renderAlias column <+> "CASCADE"
@@ -479,8 +481,8 @@ renameColumn column0 column1 = UnsafeAlterColumns $
479481-- | An `alterColumn` alters a single column.
480482alterColumn
481483 :: (KnownSymbol column, HasColumn column columns ty0)
482− => Alias column
483− -> AlterColumn ty0 ty1
484+ => Alias column -- ^ column to alter
485+ -> AlterColumn ty0 ty1 -- ^ alteration to perform
484486 -> AlterColumns columns (Alter column columns ty1)
485487alterColumn column alteration = UnsafeAlterColumns $
486488 "ALTER COLUMN" <+> renderAlias column <+> renderAlterColumn alteration
@@ -504,7 +506,7 @@ newtype AlterColumn (ty0 :: ColumnType) (ty1 :: ColumnType) =
504506-- :}
505507-- "ALTER TABLE tab ALTER COLUMN col SET DEFAULT 5;"
506508setDefault
507− :: Expression '[] 'Ungrouped '[] ('Required ty)
509+ :: Expression '[] 'Ungrouped '[] ('Required ty) -- ^ default value to set
508510 -> AlterColumn (optionality ty) ('Optional ty)
509511setDefault expression = UnsafeAlterColumn $
510512 "SET DEFAULT" <+> renderExpression expression
@@ -536,8 +538,7 @@ dropDefault = UnsafeAlterColumn $ "DROP DEFAULT"
536538-- in renderDefinition definition
537539-- :}
538540-- "ALTER TABLE tab ALTER COLUMN col SET NOT NULL;"
539−setNotNull
540− :: AlterColumn (optionality ('Null ty)) (optionality ('NotNull ty))
541+setNotNull :: AlterColumn (optionality ('Null ty)) (optionality ('NotNull ty))
541542setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
542543
543544-- | A `dropNotNull` drops a @NOT NULL@ constraint from a column.
@@ -551,8 +552,7 @@ setNotNull = UnsafeAlterColumn $ "SET NOT NULL"
551552-- in renderDefinition definition
552553-- :}
553554-- "ALTER TABLE tab ALTER COLUMN col DROP NOT NULL;"
554−dropNotNull
555− :: AlterColumn (optionality ('NotNull ty)) (optionality ('Null ty))
555+dropNotNull :: AlterColumn (optionality ('NotNull ty)) (optionality ('Null ty))
556556dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
557557
558558-- | An `alterType` converts a column to a different data type.