on dev help sign in
some more doctests
3564e38Eitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+10−5
@@ -85,7 +85,7 @@ CREATE statements
85
85
86-- | `createTable` adds a table to the schema.
86-- | `createTable` adds a table to the schema.
87--
87--
88−-- >>> :set -XOverloadedLabels -XDataKinds
88+-- >>> :set -XOverloadedLabels
89-- >>> :{
89-- >>> :{
90-- renderDefinition $
90-- renderDefinition $
91-- createTable #tab (int `As` #a :* real `As` #b :* Nil) []
91-- createTable #tab (int `As` #a :* real `As` #b :* Nil) []
@@ -136,7 +136,6 @@ newtype TableConstraint
136-- It allows you to specify that the value in a certain column must satisfy
136-- It allows you to specify that the value in a certain column must satisfy
137-- a Boolean (truth-value) expression.
137-- a Boolean (truth-value) expression.
138--
138--
139−-- >>> :set -XOverloadedLabels -XDataKinds
140-- >>> :{
139-- >>> :{
141-- renderDefinition $
140-- renderDefinition $
142-- createTable #tab
141-- createTable #tab
@@ -154,7 +153,6 @@ check condition = UnsafeTableConstraint $
154-- | `unique` constraints ensure that the data contained in a column,
153-- | `unique` constraints ensure that the data contained in a column,
155-- or a group of columns, is unique among all the rows in the table.
154-- or a group of columns, is unique among all the rows in the table.
156--
155--
157−-- >>> :set -XOverloadedLabels -XDataKinds
158-- >>> :{
156-- >>> :{
159-- renderDefinition $
157-- renderDefinition $
160-- createTable #tab
158-- createTable #tab
@@ -174,7 +172,6 @@ unique columns = UnsafeTableConstraint $
174-- can be used as a unique identifier for rows in the table.
172-- can be used as a unique identifier for rows in the table.
175-- This requires that the values be both unique and not null.
173-- This requires that the values be both unique and not null.
176--
174--
177−-- >>> :set -XOverloadedLabels -XDataKinds
178-- >>> :{
175-- >>> :{
179-- renderDefinition $
176-- renderDefinition $
180-- createTable #tab
177-- createTable #tab
@@ -195,7 +192,6 @@ primaryKey columns = UnsafeTableConstraint $
195-- another table. We say this maintains the referential integrity
192-- another table. We say this maintains the referential integrity
196-- between two related tables.
193-- between two related tables.
197--
194--
198−-- >>> :set -XOverloadedLabels -XDataKinds
199-- >>> :{
195-- >>> :{
200-- let
196-- let
201-- definition :: Definition '[]
197-- definition :: Definition '[]
@@ -285,6 +281,10 @@ renderOnUpdate = \case
285DROP statements
281DROP statements
286-----------------------------------------}
282-----------------------------------------}
287
283
284+-- | `dropTable` removes a table from the schema.
285+--
286+-- >>> renderDefinition $ dropTable #muh_table
287+-- "DROP TABLE muh_table;"
288dropTable
288dropTable
289 :: KnownSymbol table
289 :: KnownSymbol table
290 => Alias table
290 => Alias table
@@ -295,6 +295,7 @@ dropTable table = UnsafeDefinition $ "DROP TABLE" <+> renderAlias table <> ";"
295ALTER statements
295ALTER statements
296-----------------------------------------}
296-----------------------------------------}
297
297
298+-- | `alterTable` changes the definition of a table from the schema.
298alterTable
299alterTable
299 :: HasTable table schema columns0
300 :: HasTable table schema columns0
300 => Alias table
301 => Alias table
@@ -306,6 +307,10 @@ alterTable table alteration = UnsafeDefinition $
306 <+> renderAlterTable alteration
307 <+> renderAlterTable alteration
307 <> ";"
308 <> ";"
308
309
310+-- | `alterTable` changes the name of a table from the schema.
311+--
312+-- >>> renderDefinition $ alterTableRename #foo #bar
313+-- "ALTER TABLE foo RENAME TO bar;"
309alterTableRename
314alterTableRename
310 :: (KnownSymbol table0, KnownSymbol table1)
315 :: (KnownSymbol table0, KnownSymbol table1)
311 => Alias table0
316 => Alias table0