on dev help sign in
create type safety
0f3aa2fEitan Chatav
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+1−1
@@ -485,7 +485,7 @@ WITH statements
485-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table 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 (view (#deleted_rows `As` #t)))))
489-- in renderManipulation manipulation
489-- in renderManipulation manipulation
490-- :}
490-- :}
491-- "WITH \"deleted_rows\" AS (DELETE FROM \"products\" WHERE (\"date\" < ($1 :: date)) RETURNING *) INSERT INTO \"products_deleted\" SELECT * FROM \"deleted_rows\" AS \"t\";"
491-- "WITH \"deleted_rows\" AS (DELETE FROM \"products\" WHERE (\"date\" < ($1 :: date)) RETURNING *) INSERT INTO \"products_deleted\" SELECT * FROM \"deleted_rows\" AS \"t\";"
squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−1
@@ -545,6 +545,10 @@ type family Join xs ys where
545-- `Squeal.PostgreSQL.Definition.addColumn`.
545-- `Squeal.PostgreSQL.Definition.addColumn`.
546type family Create alias x xs where
546type family Create alias x xs where
547 Create alias x '[] = '[alias ::: x]
547 Create alias x '[] = '[alias ::: x]
548+ Create alias x (alias ::: y ': xs) = TypeError
549+ ('Text "Create: alias "
550+ ':<>: 'ShowType alias
551+ ':<>: 'Text "already in use")
548 Create alias y (x ': xs) = x ': Create alias y xs
552 Create alias y (x ': xs) = x ': Create alias y xs
549
553
550-- | @Drop alias xs@ removes the type associated with @alias@ in @xs@
554-- | @Drop alias xs@ removes the type associated with @alias@ in @xs@
@@ -631,4 +635,4 @@ type family With
631 :: SchemaType where
635 :: SchemaType where
632 With '[] schema = schema
636 With '[] schema = schema
633 With (alias ::: rel ': rels) schema =
637 With (alias ::: rel ': rels) schema =
634− alias ::: 'Table ('[] :=> RelationToColumns rel) ': With rels schema
638+ alias ::: 'View rel ': With rels schema