on dev help sign in
release notes views

release notes views

commit89173fa8dd3603b306da28412cac0aae12f07233 authorEitan Chatav <eitan.chatav@gmail.com> dateMon 25 Jun 2018, 09:45 (8 years ago) parentc79b77d
1 file changed+86−4
RELEASE NOTES.md+86−4
RELEASE NOTES.md+86−4
@@ -2,10 +2,92 @@
22
33### Version 0.3.0.0 - June 23, 2018
44
5−**Changes**
6−- **Views** - Create, drop and query views
7−- **Enums, Composites** - Create, drop and marshal enumerated and composite types
8−- **Bugfixes**
5+Version 0.3 of Squeal adds views as well as composite and enumerated types to Squeal.
6+To support these features, a new kind `SchemumType` was added.
7+
8+```Haskell
9+data SchemumType
10+ = Table TableType
11+ | View RelationType
12+ | Typedef PGType
13+```
14+
15+As a consequence, you will have to update your schema definitions like so:
16+
17+```Haskell
18+-- Squeal 0.2
19+type Schema =
20+ '[ "users" :::
21+ '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
22+ '[ "id" ::: 'Def :=> 'NotNull 'PGint4
23+ , "name" ::: 'NoDef :=> 'NotNull 'PGtext
24+ ]
25+ ]
26+
27+-- Squeal 0.3
28+type Schema =
29+ '[ "users" ::: 'Table (
30+ '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
31+ '[ "id" ::: 'Def :=> 'NotNull 'PGint4
32+ , "name" ::: 'NoDef :=> 'NotNull 'PGtext
33+ ])
34+ ]
35+```
36+
37+**Views**
38+
39+You can now create, drop, and query views.
40+
41+```Haskell
42+>>> :{
43+type ABC =
44+ ('[] :: TableConstraints) :=>
45+ '[ "a" ::: 'NoDef :=> 'Null 'PGint4
46+ , "b" ::: 'NoDef :=> 'Null 'PGint4
47+ , "c" ::: 'NoDef :=> 'Null 'PGint4
48+ ]
49+type BC =
50+ '[ "b" ::: 'Null 'PGint4
51+ , "c" ::: 'Null 'PGint4
52+ ]
53+:}
54+
55+>>> :{
56+let
57+ definition :: Definition
58+ '[ "abc" ::: 'Table ABC ]
59+ '[ "abc" ::: 'Table ABC
60+ , "bc" ::: 'View BC
61+ ]
62+ definition =
63+ createView #bc (select (#b :* #c :* Nil) (from (table #abc)))
64+in printSQL definition
65+:}
66+CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";
67+
68+>>> :{
69+let
70+ definition :: Definition
71+ '[ "abc" ::: 'Table ABC
72+ , "bc" ::: 'View BC
73+ ]
74+ '[ "abc" ::: 'Table ABC ]
75+ definition = dropView #bc
76+in printSQL definition
77+:}
78+DROP VIEW "bc";
79+
80+>>> :{
81+let
82+ query :: Query
83+ '[ "abc" ::: 'Table ABC
84+ , "bc" ::: 'View BC
85+ ] '[] BC
86+ query = selectStar (from (view #bc))
87+in printSQL query
88+:}
89+SELECT * FROM "bc" AS "bc"
90+```
991
1092### Version 0.2.1 - April 7, 2018
1193