on dev help sign in
doctest for create view
commitb95400d8028138576423ad596b7376f97ca732ef authorEitan Chatav <eitan.chatav@gmail.com> dateTue 10 Apr 2018, 11:18 (9 years ago) parentd01eae4
1 file changed+12
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+12
squeal-postgresql/src/Squeal/PostgreSQL/Definition.hs+12
@@ -742,6 +742,18 @@ dropNotNull = UnsafeAlterColumn $ "DROP NOT NULL"
742742alterType :: TypeExpression ty -> AlterColumn ty0 ty
743743alterType ty = UnsafeAlterColumn $ "TYPE" <+> renderTypeExpression ty
744744
745+-- | create a view...
746+-- >>> :{
747+-- let
748+-- definition :: Definition
749+-- '[ "abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]
750+-- '[ "abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
751+-- , "bc" ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]
752+-- definition =
753+-- createView #bc (select (#b `As` #b :* #c `As` #c :* Nil) (from (table (#abc `As` #abc))))
754+-- in renderDefinition definition
755+-- :}
756+-- "CREATE VIEW \"bc\" AS SELECT \"b\" AS \"b\", \"c\" AS \"c\" FROM \"abc\" AS \"abc\";"
745757createView
746758 :: KnownSymbol view
747759 => Alias view -- ^ the name of the table to add