on dev help sign in
create type safety
commit0f3aa2f7841d54bd5d8990a1df0cbf220cb0f8fe authorEitan Chatav <eitan.chatav@gmail.com> dateWed 11 Apr 2018, 19:23 (9 years ago) parent5677306
2 files changed+6−2
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+1−1 squeal-postgresql/src/Squeal/PostgreSQL/Schema.hs+5−1
squeal-postgresql/src/Squeal/PostgreSQL/Manipulation.hs+1−1
@@ -485,7 +485,7 @@ WITH statements
485485-- manipulation :: Manipulation '["products" ::: 'Table ProductsTable, "products_deleted" ::: 'Table ProductsTable] '[ 'NotNull 'PGdate] '[]
486486-- manipulation = with
487487-- (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)))))
489489-- in renderManipulation manipulation
490490-- :}
491491-- "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
545545-- `Squeal.PostgreSQL.Definition.addColumn`.
546546type family Create alias x xs where
547547 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")
548552 Create alias y (x ': xs) = x ': Create alias y xs
549553
550554-- | @Drop alias xs@ removes the type associated with @alias@ in @xs@
@@ -631,4 +635,4 @@ type family With
631635 :: SchemaType where
632636 With '[] schema = schema
633637 With (alias ::: rel ': rels) schema =
634− alias ::: 'Table ('[] :=> RelationToColumns rel) ': With rels schema
638+ alias ::: 'View rel ': With rels schema