Skip to content

Where can I find more examples or actual usage? #356

Answered by echatav
magthe asked this question in Q&A
Discussion options

You must be logged in to vote

Here's an example for a table setup with a default uuid primary key and a check constraint spanning more than one column.

>>> import Squeal.PostgreSQL
>>> import Squeal.PostgreSQL.UUID.OSSP
>>> :{
type Schema = Public '[
  "unit_circle" ::: 'Table (Constraints :=> Columns)]
type Columns = '[
  "id" ::: 'Def :=> 'NotNull 'PGuuid,
  "x" ::: 'NoDef :=> 'NotNull 'PGfloat8,
  "y" ::: 'NoDef :=> 'NotNull 'PGfloat8]
type Constraints = '[
  "pk_unit_circle" ::: 'PrimaryKey '["id"],
  "length_1" ::: 'Check '["x", "y"]]
:}

>>> :{
let
  definition :: Definition (Public '[]) Schema
  definition =
    createUuidOssp >>>
    createTable #unit_circle
    ( (uuid & notNullable & default_ uuidGenerateV4) `…

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by echatav
Comment options

You must be logged in to vote
3 replies
@magthe
Comment options

@magthe
Comment options

@echatav
Comment options

Comment options

You must be logged in to vote
1 reply
@echatav
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants