Conversation
Attempt to resolve #27 * introduce new typeclass `HasAll` which proves a subfield relation * remove `Column` datatype! * remove `ForeignKeyed` constraint synonym * change the kind of `Alter` type family to be more consistent * add `SamePGType` constraint * Change the kind of `TableConstraintExpression`
* check primary keys are all not null * check foreign keys reference all not null and either primary keys or unique columns
types * Add `PGenum` and `PGcomposite` types * Add `Typedef` schemum * `createTypeEnum` statements * Split `ColumnTypeExpression` from `TypeExpression`
* label - enum construction * row - composite construction * composite access * enum encoding
just like aliases but instead of `Label`, `PGLabel` see #27 discussion
createTypeEnumFromHaskell
release notes views
enum type notes
one line
more enum notes
code block
more enum notes
composite type notes
some more composite notes
more composite notes
additional changes notes
June 27
This was referenced Jun 26, 2018
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version 0.3 of Squeal adds views as well as composite and enumerated types to Squeal.
To support these features, a new kind
SchemumTypewas added.As a consequence, you will have to update your schema definitions like so:
Views
You can now create, drop, and query views.
Enumerated Types
PostgreSQL has a powerful type system. It even allows for user defined types.
For instance, you can define enumerated types which are data types that comprise
a static, ordered set of values. They are equivalent to Haskell algebraic data
types whose constructors are nullary. An example of an enum type might be the days of the week,
or a set of status values for a piece of data.
Enumerated types are created using the
createTypeEnumcommand, for example:Enumerated types can also be generated from a Haskell algbraic data type with nullary constructors, for example:
You can express values of an enum type using
label, which is an overloaded methodof the
IsPGlabeltypeclass.Composite Types
In addition to enum types, you can define composite types.
A composite type represents the structure of a row or record;
it is essentially just a list of field names and their data types.
createTypeCompositecreates a composite type. The composite type isspecified by a list of attribute names and data types.
Composite types are almost equivalent to Haskell record types.
However, because of the potential presence of
NULLall the record fields must be
Maybes of basic types.Composite types can be generated from a Haskell record type, for example:
A row constructor is an expression that builds a row value
(also called a composite value) using values for its member fields.
You can also use
(&)to apply a field label to a composite value.Both composite and enum types can be automatically encoded from and decoded to their equivalent Haskell types.
And they can be dropped.
Additional Changes
Squeal 0.3 also introduces a typeclass
HasAllsimilar toHasbut for a list of aliases.This makes it possible to clean up some unfortunately messy Squeal 0.2 definitions.
Squeal 0.3 also adds
IsLabelinstances forAliasedexpressions and tables as well asheterogeneous lists, allowing for some more economy of code.
The above changes required major and minor changes to Squeal DSL functions.
Please consult the documentation.