on dev help sign in
with still not working
b2cd1efEitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+1−1
@@ -189,7 +189,7 @@ let
189 , "products_deleted" ::: 'Table ProductsTable
189 , "products_deleted" ::: 'Table ProductsTable
190 ]] '[ 'NotNull 'PGdate] '[]
190 ]] '[ 'NotNull 'PGdate] '[]
191 manipulation = with
191 manipulation = with
192− (deleteFrom #products (#date .< param @1) ReturningStar `as` #deleted_rows)
192+ (CommonTableExpression (deleteFrom #products (#date .< param @1) ReturningStar `as` #deleted_rows) :>> Done)
193 (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `as` #t)))))
193 (insertQuery_ #products_deleted (selectStar (from (view (#deleted_rows `as` #t)))))
194in printSQL manipulation
194in printSQL manipulation
195:}
195:}
squeal-postgresql/src/Squeal/PostgreSQL/Query.hs+27−28
@@ -349,8 +349,8 @@ let
349 '[ "c1" ::: 'NotNull 'PGtext
349 '[ "c1" ::: 'NotNull 'PGtext
350 , "c2" ::: 'NotNull 'PGtext ]
350 , "c2" ::: 'NotNull 'PGtext ]
351 query = with (
351 query = with (
352− selectStar (from (view #t1)) `as` #t2 :>>
352+ CommonTableExpression (selectStar (from (view #t1)) `as` #t2) :>>
353− selectStar (from (view #t2)) `as` #t3
353+ CommonTableExpression (selectStar (from (view #t2)) `as` #t3) :>> Done
354 ) (selectStar (from (view #t3)))
354 ) (selectStar (from (view #t3)))
355in printSQL query
355in printSQL query
356:}
356:}
@@ -1362,34 +1362,33 @@ rowGteAny = unsafeRowSubqueryExpression ">= ANY"
1362-- | A `CommonTableExpression` is an auxiliary statement in a `with` clause.
1362-- | A `CommonTableExpression` is an auxiliary statement in a `with` clause.
1363data CommonTableExpression statement
1363data CommonTableExpression statement
1364 (params :: [NullityType])
1364 (params :: [NullityType])
1365− (db :: DBType)
1365+ (db0 :: DBType)
1366− (schema0 :: SchemaType)
1366+ (db1 :: DBType) where
1367− (schema1 :: SchemaType) where
1368 CommonTableExpression
1367 CommonTableExpression
1369− :: Has "public" db schema
1368+ :: ( Has "public" db schema
1369+ , Alter "public" (alias ::: 'View cte ': schema) db ~ db1 )
1370 => Aliased (statement db params) (alias ::: cte)
1370 => Aliased (statement db params) (alias ::: cte)
1371− -> CommonTableExpression
1371+ -> CommonTableExpression statement params db db1
1372− statement params db schema (alias ::: 'View cte ': schema)
1373−instance
1372+-- instance
1374− ( KnownSymbol vw
1373+-- ( KnownSymbol vw
1375− , Has "public" db schema
1374+-- , Has "public" db schema
1376− , schema1 ~ (vw ::: 'View cte ': schema)
1375+-- , Alter "public" (vw ::: 'View cte ': schema) db ~ db1
1377− ) => Aliasable vw
1376+-- ) => Aliasable vw
1378− (statement db params cte)
1377+-- (statement db params cte)
1379− (CommonTableExpression statement params db schema schema1) where
1378+-- (CommonTableExpression statement params db db1) where
1380− statement `as` vw = CommonTableExpression (statement `as` vw)
1379+-- statement `as` vw = CommonTableExpression (statement `as` vw)
1381−instance
1380+-- instance
1382− ( KnownSymbol vw
1381+-- ( KnownSymbol vw
1383− , Has "public" db schema
1382+-- , Has "public" db schema
1384− , schema1 ~ (vw ::: 'View cte ': schema)
1383+-- , Alter "public" (vw ::: 'View cte ': schema) db ~ db1
1385− ) => Aliasable vw (statement db params cte)
1384+-- ) => Aliasable vw (statement db params cte)
1386− (AlignedList (CommonTableExpression statement params db) schema schema1) where
1385+-- (AlignedList (CommonTableExpression statement params) db db1) where
1387− statement `as` vw = single (statement `as` vw)
1386+-- statement `as` vw = single (statement `as` vw)
1388
1387
1389-- | render a `CommonTableExpression`.
1388-- | render a `CommonTableExpression`.
1390renderCommonTableExpression
1389renderCommonTableExpression
1391 :: (forall db ps row. statement db ps row -> ByteString) -- ^ render statement
1390 :: (forall db ps row. statement db ps row -> ByteString) -- ^ render statement
1392− -> CommonTableExpression statement params db0 schema0 schema1 -> ByteString
1391+ -> CommonTableExpression statement params db0 db1 -> ByteString
1393renderCommonTableExpression renderStatement
1392renderCommonTableExpression renderStatement
1394 (CommonTableExpression (statement `As` alias)) =
1393 (CommonTableExpression (statement `As` alias)) =
1395 renderAlias alias <+> "AS" <+> parenthesized (renderStatement statement)
1394 renderAlias alias <+> "AS" <+> parenthesized (renderStatement statement)
@@ -1397,8 +1396,8 @@ renderCommonTableExpression renderStatement
1397-- | render a non-empty `AlignedList` of `CommonTableExpression`s.
1396-- | render a non-empty `AlignedList` of `CommonTableExpression`s.
1398renderCommonTableExpressions
1397renderCommonTableExpressions
1399 :: (forall db ps row. statement db ps row -> ByteString) -- ^ render statement
1398 :: (forall db ps row. statement db ps row -> ByteString) -- ^ render statement
1400− -> CommonTableExpression statement params db0 schema0 schema1
1399+ -> CommonTableExpression statement params db0 db1
1401− -> AlignedList (CommonTableExpression statement params db0) schema1 schema2
1400+ -> AlignedList (CommonTableExpression statement params) db1 db2
1402 -> ByteString
1401 -> ByteString
1403renderCommonTableExpressions renderStatement cte ctes =
1402renderCommonTableExpressions renderStatement cte ctes =
1404 renderCommonTableExpression renderStatement cte <> case ctes of
1403 renderCommonTableExpression renderStatement cte <> case ctes of
@@ -1412,9 +1411,9 @@ renderCommonTableExpressions renderStatement cte ctes =
1412class With statement where
1411class With statement where
1413 with
1412 with
1414 :: Has "public" db0 schema0
1413 :: Has "public" db0 schema0
1415− => AlignedList (CommonTableExpression statement params db0) schema0 schema1
1414+ => AlignedList (CommonTableExpression statement params) db0 db1
1416 -- ^ common table expressions
1415 -- ^ common table expressions
1417− -> statement (Alter "public" schema1 db0) params row
1416+ -> statement db1 params row
1418 -- ^ larger query
1417 -- ^ larger query
1419 -> statement db0 params row
1418 -> statement db0 params row
1420instance With Query where
1419instance With Query where