on dev help sign in
fixing tests
fbd7a31Eitan Chatav
squeal-postgresql/exe/Example.hs+4−4
@@ -25,20 +25,20 @@ import qualified Generics.SOP as SOP
25import qualified GHC.Generics as GHC
25import qualified GHC.Generics as GHC
26
26
27type Schema =
27type Schema =
28− '[ "users" :::
28+ '[ "users" ::: 'Table (
29 '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
29 '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
30 '[ "id" ::: 'Def :=> 'NotNull 'PGint4
30 '[ "id" ::: 'Def :=> 'NotNull 'PGint4
31 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
31 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
32 , "vec" ::: 'NoDef :=> 'NotNull ('PGvararray 'PGint2)
32 , "vec" ::: 'NoDef :=> 'NotNull ('PGvararray 'PGint2)
33− ]
33+ ])
34− , "emails" :::
34+ , "emails" ::: 'Table (
35 '[ "pk_emails" ::: 'PrimaryKey '["id"]
35 '[ "pk_emails" ::: 'PrimaryKey '["id"]
36 , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
36 , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
37 ] :=>
37 ] :=>
38 '[ "id" ::: 'Def :=> 'NotNull 'PGint4
38 '[ "id" ::: 'Def :=> 'NotNull 'PGint4
39 , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
39 , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
40 , "email" ::: 'NoDef :=> 'Null 'PGtext
40 , "email" ::: 'NoDef :=> 'Null 'PGtext
41− ]
41+ ])
42 ]
42 ]
43
43
44setup :: Definition '[] Schema
44setup :: Definition '[] Schema
squeal-postgresql/src/Squeal/PostgreSQL.hs+4−4
@@ -31,19 +31,19 @@
31--
31--
32-- >>> :{
32-- >>> :{
33-- type Schema =
33-- type Schema =
34−-- '[ "users" :::
34+-- '[ "users" ::: 'Table (
35-- '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
35-- '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
36-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
36-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
37-- , "name" ::: 'NoDef :=> 'NotNull 'PGtext
37-- , "name" ::: 'NoDef :=> 'NotNull 'PGtext
38−-- ]
38+-- ])
39−-- , "emails" :::
39+-- , "emails" ::: 'Table (
40-- '[ "pk_emails" ::: 'PrimaryKey '["id"]
40-- '[ "pk_emails" ::: 'PrimaryKey '["id"]
41-- , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
41-- , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
42-- ] :=>
42-- ] :=>
43-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
43-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
44-- , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
44-- , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
45-- , "email" ::: 'NoDef :=> 'Null 'PGtext
45-- , "email" ::: 'NoDef :=> 'Null 'PGtext
46−-- ]
46+-- ])
47-- ]
47-- ]
48-- :}
48-- :}
49--
49--
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+20−14
@@ -135,7 +135,7 @@ createTable tab columns constraints = UnsafeDefinition $
135--
135--
136-- >>> :set -XOverloadedLabels -XTypeApplications
136-- >>> :set -XOverloadedLabels -XTypeApplications
137-- >>> type Table = '[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGfloat4]
137-- >>> type Table = '[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGfloat4]
138−-- >>> type Schema = '["tab" ::: Table]
138+-- >>> type Schema = '["tab" ::: 'Table Table]
139-- >>> :{
139-- >>> :{
140-- renderDefinition
140-- renderDefinition
141-- (createTableIfNotExists #tab (int `As` #a :* real `As` #b :* Nil) Nil :: Definition Schema Schema)
141-- (createTableIfNotExists #tab (int `As` #a :* real `As` #b :* Nil) Nil :: Definition Schema Schema)
@@ -210,10 +210,10 @@ newtype TableConstraintExpression
210--
210--
211-- >>> :{
211-- >>> :{
212-- type Schema = '[
212-- type Schema = '[
213−-- "tab" ::: '[ "inequality" ::: 'Check '["a","b"]] :=> '[
213+-- "tab" ::: 'Table ('[ "inequality" ::: 'Check '["a","b"]] :=> '[
214-- "a" ::: 'NoDef :=> 'NotNull 'PGint4,
214-- "a" ::: 'NoDef :=> 'NotNull 'PGint4,
215-- "b" ::: 'NoDef :=> 'NotNull 'PGint4
215-- "b" ::: 'NoDef :=> 'NotNull 'PGint4
216−-- ]]
216+-- ])]
217-- :}
217-- :}
218--
218--
219-- >>> :{
219-- >>> :{
@@ -241,10 +241,10 @@ check _cols condition = UnsafeTableConstraintExpression $
241--
241--
242-- >>> :{
242-- >>> :{
243-- type Schema = '[
243-- type Schema = '[
244−-- "tab" ::: '[ "uq_a_b" ::: 'Unique '["a","b"]] :=> '[
244+-- "tab" ::: 'Table( '[ "uq_a_b" ::: 'Unique '["a","b"]] :=> '[
245-- "a" ::: 'NoDef :=> 'Null 'PGint4,
245-- "a" ::: 'NoDef :=> 'Null 'PGint4,
246-- "b" ::: 'NoDef :=> 'Null 'PGint4
246-- "b" ::: 'NoDef :=> 'Null 'PGint4
247−-- ]]
247+-- ])]
248-- :}
248-- :}
249--
249--
250-- >>> :{
250-- >>> :{
@@ -272,10 +272,10 @@ unique columns = UnsafeTableConstraintExpression $
272--
272--
273-- >>> :{
273-- >>> :{
274-- type Schema = '[
274-- type Schema = '[
275−-- "tab" ::: '[ "pk_id" ::: 'PrimaryKey '["id"]] :=> '[
275+-- "tab" ::: 'Table ('[ "pk_id" ::: 'PrimaryKey '["id"]] :=> '[
276-- "id" ::: 'Def :=> 'NotNull 'PGint4,
276-- "id" ::: 'Def :=> 'NotNull 'PGint4,
277-- "name" ::: 'NoDef :=> 'NotNull 'PGtext
277-- "name" ::: 'NoDef :=> 'NotNull 'PGtext
278−-- ]]
278+-- ])]
279-- :}
279-- :}
280--
280--
281-- >>> :{
281-- >>> :{
@@ -305,19 +305,19 @@ primaryKey columns = UnsafeTableConstraintExpression $
305--
305--
306-- >>> :{
306-- >>> :{
307-- type Schema =
307-- type Schema =
308−-- '[ "users" :::
308+-- '[ "users" ::: 'Table (
309-- '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
309-- '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
310-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
310-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
311-- , "name" ::: 'NoDef :=> 'NotNull 'PGtext
311-- , "name" ::: 'NoDef :=> 'NotNull 'PGtext
312−-- ]
312+-- ])
313−-- , "emails" :::
313+-- , "emails" ::: 'Table (
314-- '[ "pk_emails" ::: 'PrimaryKey '["id"]
314-- '[ "pk_emails" ::: 'PrimaryKey '["id"]
315-- , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
315-- , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
316-- ] :=>
316-- ] :=>
317-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
317-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
318-- , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
318-- , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
319-- , "email" ::: 'NoDef :=> 'Null 'PGtext
319-- , "email" ::: 'NoDef :=> 'Null 'PGtext
320−-- ]
320+-- ])
321-- ]
321-- ]
322-- :}
322-- :}
323--
323--
@@ -344,14 +344,14 @@ primaryKey columns = UnsafeTableConstraintExpression $
344--
344--
345-- >>> :{
345-- >>> :{
346-- type Schema =
346-- type Schema =
347−-- '[ "employees" :::
347+-- '[ "employees" ::: 'Table (
348-- '[ "employees_pk" ::: 'PrimaryKey '["id"]
348-- '[ "employees_pk" ::: 'PrimaryKey '["id"]
349-- , "employees_employer_fk" ::: 'ForeignKey '["employer_id"] "employees" '["id"]
349-- , "employees_employer_fk" ::: 'ForeignKey '["employer_id"] "employees" '["id"]
350-- ] :=>
350-- ] :=>
351-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
351-- '[ "id" ::: 'Def :=> 'NotNull 'PGint4
352-- , "name" ::: 'NoDef :=> 'NotNull 'PGtext
352-- , "name" ::: 'NoDef :=> 'NotNull 'PGtext
353-- , "employer_id" ::: 'NoDef :=> 'Null 'PGint4
353-- , "employer_id" ::: 'NoDef :=> 'Null 'PGint4
354−-- ]
354+-- ])
355-- ]
355-- ]
356-- :}
356-- :}
357--
357--
@@ -454,7 +454,13 @@ DROP statements
454
454
455-- | `dropTable` removes a table from the schema.
455-- | `dropTable` removes a table from the schema.
456--
456--
457+-- >>> :{
458+-- let
459+-- definition :: Definition '["muh_table" ::: 'Table t] '[]
457−-- >>> renderDefinition $ dropTable #muh_table
460+-- definition = dropTable #muh_table
461+-- :}
462+--
463+-- >>> renderDefinition definition
458-- "DROP TABLE \"muh_table\";"
464-- "DROP TABLE \"muh_table\";"
459dropTable
465dropTable
460 :: Has table schema ('Table t)
466 :: Has table schema ('Table t)
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+17−17
@@ -73,9 +73,9 @@ simple insert:
73>>> :{
73>>> :{
74let
74let
75 manipulation :: Manipulation
75 manipulation :: Manipulation
76− '[ "tab" ::: '[] :=>
76+ '[ "tab" ::: 'Table ('[] :=>
77 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
77 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
78− , "col2" ::: 'Def :=> 'NotNull 'PGint4 ]] '[] '[]
78+ , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[] '[]
79 manipulation =
79 manipulation =
80 insertRow_ #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
80 insertRow_ #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
81in renderManipulation manipulation
81in renderManipulation manipulation
@@ -87,9 +87,9 @@ parameterized insert:
87>>> :{
87>>> :{
88let
88let
89 manipulation :: Manipulation
89 manipulation :: Manipulation
90− '[ "tab" ::: '[] :=>
90+ '[ "tab" ::: 'Table ('[] :=>
91 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
91 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
92− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]]
92+ , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])]
93 '[ 'NotNull 'PGint4, 'NotNull 'PGint4 ] '[]
93 '[ 'NotNull 'PGint4, 'NotNull 'PGint4 ] '[]
94 manipulation =
94 manipulation =
95 insertRow_ #tab
95 insertRow_ #tab
@@ -103,9 +103,9 @@ returning insert:
103>>> :{
103>>> :{
104let
104let
105 manipulation :: Manipulation
105 manipulation :: Manipulation
106− '[ "tab" ::: '[] :=>
106+ '[ "tab" ::: 'Table ('[] :=>
107 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
107 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
108− , "col2" ::: 'Def :=> 'NotNull 'PGint4 ]] '[]
108+ , "col2" ::: 'Def :=> 'NotNull 'PGint4 ])] '[]
109 '["fromOnly" ::: 'NotNull 'PGint4]
109 '["fromOnly" ::: 'NotNull 'PGint4]
110 manipulation =
110 manipulation =
111 insertRow #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
111 insertRow #tab (Set 2 `As` #col1 :* Default `As` #col2 :* Nil)
@@ -119,9 +119,9 @@ upsert:
119>>> :{
119>>> :{
120let
120let
121 manipulation :: Manipulation
121 manipulation :: Manipulation
122− '[ "tab" ::: '[] :=>
122+ '[ "tab" ::: 'Table ('[] :=>
123 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
123 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
124− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]]
124+ , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])]
125 '[] '[ "sum" ::: 'NotNull 'PGint4]
125 '[] '[ "sum" ::: 'NotNull 'PGint4]
126 manipulation =
126 manipulation =
127 insertRows #tab
127 insertRows #tab
@@ -140,14 +140,14 @@ query insert:
140>>> :{
140>>> :{
141let
141let
142 manipulation :: Manipulation
142 manipulation :: Manipulation
143− '[ "tab" ::: '[] :=>
143+ '[ "tab" ::: 'Table ('[] :=>
144 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
144 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
145 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4
145 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4
146− ]
146+ ])
147− , "other_tab" ::: '[] :=>
147+ , "other_tab" ::: 'Table ('[] :=>
148 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
148 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
149 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4
149 , "col2" ::: 'NoDef :=> 'NotNull 'PGint4
150− ]
150+ ])
151 ] '[] '[]
151 ] '[] '[]
152 manipulation =
152 manipulation =
153 insertQuery_ #tab
153 insertQuery_ #tab
@@ -161,9 +161,9 @@ update:
161>>> :{
161>>> :{
162let
162let
163 manipulation :: Manipulation
163 manipulation :: Manipulation
164− '[ "tab" ::: '[] :=>
164+ '[ "tab" ::: 'Table ('[] :=>
165 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
165 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
166− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]] '[] '[]
166+ , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])] '[] '[]
167 manipulation =
167 manipulation =
168 update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
168 update_ #tab (Set 2 `As` #col1 :* Same `As` #col2 :* Nil)
169 (#col1 ./= #col2)
169 (#col1 ./= #col2)
@@ -176,9 +176,9 @@ delete:
176>>> :{
176>>> :{
177let
177let
178 manipulation :: Manipulation
178 manipulation :: Manipulation
179− '[ "tab" ::: '[] :=>
179+ '[ "tab" ::: 'Table ('[] :=>
180 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
180 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
181− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]] '[]
181+ , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])] '[]
182 '[ "col1" ::: 'NotNull 'PGint4
182 '[ "col1" ::: 'NotNull 'PGint4
183 , "col2" ::: 'NotNull 'PGint4 ]
183 , "col2" ::: 'NotNull 'PGint4 ]
184 manipulation = deleteFrom #tab (#col1 .== #col2) ReturningStar
184 manipulation = deleteFrom #tab (#col1 .== #col2) ReturningStar
@@ -482,7 +482,7 @@ WITH statements
482--
482--
483-- >>> :{
483-- >>> :{
484-- let
484-- let
485−-- manipulation :: Manipulation '["products" ::: ProductsTable, "products_deleted" ::: ProductsTable] '[ 'NotNull 'PGdate] '[]
485+-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
486-- manipulation = with
486-- manipulation = with
487-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rows :* Nil)
487-- (deleteFrom #products (#date .< param @1) ReturningStar `As` #deleted_rows :* Nil)
488-- (insertQuery_ #products_deleted (selectStar (from (table (#deleted_rows `As` #t)))))
488-- (insertQuery_ #products_deleted (selectStar (from (table (#deleted_rows `As` #t)))))
squeal-postgresql/src/Squeal/PostgreSQL/Migration.hs+17−17
@@ -31,7 +31,7 @@ type EmailsTable =
31
31
32>>> :{
32>>> :{
33let
33let
34− makeUsers :: Migration IO '[] '["users" ::: UsersTable]
34+ makeUsers :: Migration IO '[] '["users" ::: 'Table UsersTable]
35 makeUsers = Migration
35 makeUsers = Migration
36 { name = "make users table"
36 { name = "make users table"
37 , up = void . define $
37 , up = void . define $
@@ -45,8 +45,8 @@ let
45
45
46>>> :{
46>>> :{
47let
47let
48− makeEmails :: Migration IO '["users" ::: UsersTable]
48+ makeEmails :: Migration IO '["users" ::: 'Table UsersTable]
49− '["users" ::: UsersTable, "emails" ::: EmailsTable]
49+ '["users" ::: 'Table UsersTable, "emails" ::: 'Table EmailsTable]
50 makeEmails = Migration
50 makeEmails = Migration
51 { name = "make emails table"
51 { name = "make emails table"
52 , up = void . define $
52 , up = void . define $
@@ -68,7 +68,7 @@ Now that we have a couple migrations we can chain them together.
68>>> :{
68>>> :{
69let
69let
70 numMigrations
70 numMigrations
71− :: Has "schema_migrations" schema MigrationsTable
71+ :: Has "schema_migrations" (TablesOf schema) MigrationsTable
72 => PQ schema schema IO ()
72 => PQ schema schema IO ()
73 numMigrations = do
73 numMigrations = do
74 result <- runQuery (selectStar (from (table (#schema_migrations `As` #m))))
74 result <- runQuery (selectStar (from (table (#schema_migrations `As` #m))))
@@ -175,8 +175,8 @@ migrateUp migration =
175 :: MonadBaseControl IO io
175 :: MonadBaseControl IO io
176 => AlignedList (Migration io) schema0 schema1
176 => AlignedList (Migration io) schema0 schema1
177 -> PQ
177 -> PQ
178− ("schema_migrations" ::: MigrationsTable ': schema0)
178+ ("schema_migrations" ::: 'Table MigrationsTable ': schema0)
179− ("schema_migrations" ::: MigrationsTable ': schema1)
179+ ("schema_migrations" ::: 'Table MigrationsTable ': schema1)
180 io ()
180 io ()
181 upMigrations = \case
181 upMigrations = \case
182 Done -> return ()
182 Done -> return ()
@@ -185,8 +185,8 @@ migrateUp migration =
185 upMigration
185 upMigration
186 :: MonadBase IO io
186 :: MonadBase IO io
187 => Migration io schema0 schema1 -> PQ
187 => Migration io schema0 schema1 -> PQ
188− ("schema_migrations" ::: MigrationsTable ': schema0)
188+ ("schema_migrations" ::: 'Table MigrationsTable ': schema0)
189− ("schema_migrations" ::: MigrationsTable ': schema1)
189+ ("schema_migrations" ::: 'Table MigrationsTable ': schema1)
190 io ()
190 io ()
191 upMigration step =
191 upMigration step =
192 queryExecuted step
192 queryExecuted step
@@ -202,8 +202,8 @@ migrateUp migration =
202 queryExecuted
202 queryExecuted
203 :: MonadBase IO io
203 :: MonadBase IO io
204 => Migration io schema0 schema1 -> PQ
204 => Migration io schema0 schema1 -> PQ
205− ("schema_migrations" ::: MigrationsTable ': schema0)
205+ ("schema_migrations" ::: 'Table MigrationsTable ': schema0)
206− ("schema_migrations" ::: MigrationsTable ': schema0)
206+ ("schema_migrations" ::: 'Table MigrationsTable ': schema0)
207 io Row
207 io Row
208 queryExecuted step = do
208 queryExecuted step = do
209 result <- runQueryParams selectMigration (Only (name step))
209 result <- runQueryParams selectMigration (Only (name step))
@@ -230,8 +230,8 @@ migrateDown migrations =
230 downMigrations
230 downMigrations
231 :: MonadBaseControl IO io
231 :: MonadBaseControl IO io
232 => AlignedList (Migration io) schema0 schema1 -> PQ
232 => AlignedList (Migration io) schema0 schema1 -> PQ
233− ("schema_migrations" ::: MigrationsTable ': schema1)
233+ ("schema_migrations" ::: 'Table MigrationsTable ': schema1)
234− ("schema_migrations" ::: MigrationsTable ': schema0)
234+ ("schema_migrations" ::: 'Table MigrationsTable ': schema0)
235 io ()
235 io ()
236 downMigrations = \case
236 downMigrations = \case
237 Done -> return ()
237 Done -> return ()
@@ -240,8 +240,8 @@ migrateDown migrations =
240 downMigration
240 downMigration
241 :: MonadBase IO io
241 :: MonadBase IO io
242 => Migration io schema0 schema1 -> PQ
242 => Migration io schema0 schema1 -> PQ
243− ("schema_migrations" ::: MigrationsTable ': schema1)
243+ ("schema_migrations" ::: 'Table MigrationsTable ': schema1)
244− ("schema_migrations" ::: MigrationsTable ': schema0)
244+ ("schema_migrations" ::: 'Table MigrationsTable ': schema0)
245 io ()
245 io ()
246 downMigration step =
246 downMigration step =
247 queryExecuted step
247 queryExecuted step
@@ -257,8 +257,8 @@ migrateDown migrations =
257 queryExecuted
257 queryExecuted
258 :: MonadBase IO io
258 :: MonadBase IO io
259 => Migration io schema0 schema1 -> PQ
259 => Migration io schema0 schema1 -> PQ
260− ("schema_migrations" ::: MigrationsTable ': schema1)
260+ ("schema_migrations" ::: 'Table MigrationsTable ': schema1)
261− ("schema_migrations" ::: MigrationsTable ': schema1)
261+ ("schema_migrations" ::: 'Table MigrationsTable ': schema1)
262 io Row
262 io Row
263 queryExecuted step = do
263 queryExecuted step = do
264 result <- runQueryParams selectMigration (Only (name step))
264 result <- runQueryParams selectMigration (Only (name step))
@@ -309,7 +309,7 @@ deleteMigration = deleteFrom_ #schema_migrations (#name .== param @1)
309-- | Selects a `Migration` from the `MigrationsTable`, returning
309-- | Selects a `Migration` from the `MigrationsTable`, returning
310-- the time at which it was executed.
310-- the time at which it was executed.
311selectMigration
311selectMigration
312− :: Has "schema_migrations" schema MigrationsTable
312+ :: Has "schema_migrations" (TablesOf schema) MigrationsTable
313 => Query schema '[ 'NotNull 'PGtext ]
313 => Query schema '[ 'NotNull 'PGtext ]
314 '[ "executed_at" ::: 'NotNull 'PGtimestamptz ]
314 '[ "executed_at" ::: 'NotNull 'PGtimestamptz ]
315selectMigration = select
315selectMigration = select
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+17−17
@@ -101,7 +101,7 @@ simple query:
101>>> :{
101>>> :{
102let
102let
103 query :: Query
103 query :: Query
104− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4]]
104+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
105 '[]
105 '[]
106 '["col" ::: 'Null 'PGint4]
106 '["col" ::: 'Null 'PGint4]
107 query = selectStar (from (table (#tab `As` #t)))
107 query = selectStar (from (table (#tab `As` #t)))
@@ -114,9 +114,9 @@ restricted query:
114>>> :{
114>>> :{
115let
115let
116 query :: Query
116 query :: Query
117− '[ "tab" ::: '[] :=>
117+ '[ "tab" ::: 'Table ('[] :=>
118 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
118 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
119− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]]
119+ , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])]
120 '[]
120 '[]
121 '[ "sum" ::: 'NotNull 'PGint4
121 '[ "sum" ::: 'NotNull 'PGint4
122 , "col1" ::: 'NotNull 'PGint4 ]
122 , "col1" ::: 'NotNull 'PGint4 ]
@@ -135,7 +135,7 @@ subquery:
135>>> :{
135>>> :{
136let
136let
137 query :: Query
137 query :: Query
138− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4]]
138+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
139 '[]
139 '[]
140 '["col" ::: 'Null 'PGint4]
140 '["col" ::: 'Null 'PGint4]
141 query =
141 query =
@@ -150,7 +150,7 @@ limits and offsets:
150>>> :{
150>>> :{
151let
151let
152 query :: Query
152 query :: Query
153− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4]]
153+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
154 '[]
154 '[]
155 '["col" ::: 'Null 'PGint4]
155 '["col" ::: 'Null 'PGint4]
156 query = selectStar
156 query = selectStar
@@ -164,7 +164,7 @@ parameterized query:
164>>> :{
164>>> :{
165let
165let
166 query :: Query
166 query :: Query
167− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGfloat8]]
167+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGfloat8])]
168 '[ 'NotNull 'PGfloat8]
168 '[ 'NotNull 'PGfloat8]
169 '["col" ::: 'NotNull 'PGfloat8]
169 '["col" ::: 'NotNull 'PGfloat8]
170 query = selectStar
170 query = selectStar
@@ -178,9 +178,9 @@ aggregation query:
178>>> :{
178>>> :{
179let
179let
180 query :: Query
180 query :: Query
181− '[ "tab" ::: '[] :=>
181+ '[ "tab" ::: 'Table ('[] :=>
182 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
182 '[ "col1" ::: 'NoDef :=> 'NotNull 'PGint4
183− , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ]]
183+ , "col2" ::: 'NoDef :=> 'NotNull 'PGint4 ])]
184 '[]
184 '[]
185 '[ "sum" ::: 'NotNull 'PGint4
185 '[ "sum" ::: 'NotNull 'PGint4
186 , "col1" ::: 'NotNull 'PGint4 ]
186 , "col1" ::: 'NotNull 'PGint4 ]
@@ -198,7 +198,7 @@ sorted query:
198>>> :{
198>>> :{
199let
199let
200 query :: Query
200 query :: Query
201− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4]]
201+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
202 '[]
202 '[]
203 '["col" ::: 'Null 'PGint4]
203 '["col" ::: 'Null 'PGint4]
204 query = selectStar
204 query = selectStar
@@ -213,7 +213,7 @@ joins:
213>>> :{
213>>> :{
214let
214let
215 query :: Query
215 query :: Query
216− '[ "orders" :::
216+ '[ "orders" ::: 'Table (
217 '["pk_orders" ::: PrimaryKey '["id"]
217 '["pk_orders" ::: PrimaryKey '["id"]
218 ,"fk_customers" ::: ForeignKey '["customer_id"] "customers" '["id"]
218 ,"fk_customers" ::: ForeignKey '["customer_id"] "customers" '["id"]
219 ,"fk_shippers" ::: ForeignKey '["shipper_id"] "shippers" '["id"]] :=>
219 ,"fk_shippers" ::: ForeignKey '["shipper_id"] "shippers" '["id"]] :=>
@@ -221,17 +221,17 @@ let
221 , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4
221 , "price" ::: 'NoDef :=> 'NotNull 'PGfloat4
222 , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
222 , "customer_id" ::: 'NoDef :=> 'NotNull 'PGint4
223 , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4
223 , "shipper_id" ::: 'NoDef :=> 'NotNull 'PGint4
224− ]
224+ ])
225− , "customers" :::
225+ , "customers" ::: 'Table (
226 '["pk_customers" ::: PrimaryKey '["id"]] :=>
226 '["pk_customers" ::: PrimaryKey '["id"]] :=>
227 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
227 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
228 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
228 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
229− ]
229+ ])
230− , "shippers" :::
230+ , "shippers" ::: 'Table (
231 '["pk_shippers" ::: PrimaryKey '["id"]] :=>
231 '["pk_shippers" ::: PrimaryKey '["id"]] :=>
232 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
232 '[ "id" ::: 'NoDef :=> 'NotNull 'PGint4
233 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
233 , "name" ::: 'NoDef :=> 'NotNull 'PGtext
234− ]
234+ ])
235 ]
235 ]
236 '[]
236 '[]
237 '[ "order_price" ::: 'NotNull 'PGfloat4
237 '[ "order_price" ::: 'NotNull 'PGfloat4
@@ -256,7 +256,7 @@ self-join:
256>>> :{
256>>> :{
257let
257let
258 query :: Query
258 query :: Query
259− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4]]
259+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
260 '[]
260 '[]
261 '["col" ::: 'Null 'PGint4]
261 '["col" ::: 'Null 'PGint4]
262 query = selectDotStar #t1
262 query = selectDotStar #t1
@@ -270,7 +270,7 @@ set operations:
270>>> :{
270>>> :{
271let
271let
272 query :: Query
272 query :: Query
273− '["tab" ::: '[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4]]
273+ '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]
274 '[]
274 '[]
275 '["col" ::: 'Null 'PGint4]
275 '["col" ::: 'Null 'PGint4]
276 query =
276 query =