squeal-postgresql-0.5.2.0: Squeal PostgreSQL Library

Copyright(c) Eitan Chatav 2017
Maintainereitan@morphism.tech
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

Squeal.PostgreSQL.Definition

Contents

Description

Squeal data definition language.

Synopsis

Definition

newtype Definition (schemas0 :: SchemasType) (schemas1 :: SchemasType) Source #

A Definition is a statement that changes the schemas of the database, like a createTable, dropTable, or alterTable command. Definitions may be composed using the >>> operator.

Instances
Migratory Definition Source # 
Instance details

Defined in Squeal.PostgreSQL.Migration

Methods

migrateUp :: AlignedList (Migration Definition) schemas0 schemas1 -> PQ schemas0 schemas1 IO () Source #

migrateDown :: AlignedList (Migration Definition) schemas0 schemas1 -> PQ schemas1 schemas0 IO () Source #

Category Definition Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

id :: Definition a a #

(.) :: Definition b c -> Definition a b -> Definition a c #

Eq (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

(/=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

Ord (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Ordering #

(<) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

(<=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

(>) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

(>=) :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Bool #

max :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Definition schemas0 schemas1 #

min :: Definition schemas0 schemas1 -> Definition schemas0 schemas1 -> Definition schemas0 schemas1 #

Show (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> Definition schemas0 schemas1 -> ShowS #

show :: Definition schemas0 schemas1 -> String #

showList :: [Definition schemas0 schemas1] -> ShowS #

Generic (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (Definition schemas0 schemas1) :: Type -> Type #

Methods

from :: Definition schemas0 schemas1 -> Rep (Definition schemas0 schemas1) x #

to :: Rep (Definition schemas0 schemas1) x -> Definition schemas0 schemas1 #

NFData (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: Definition schemas0 schemas1 -> () #

RenderSQL (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: Definition schemas0 schemas1 -> ByteString Source #

type Rep (Definition schemas0 schemas1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (Definition schemas0 schemas1) = D1 (MetaData "Definition" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeDefinition" PrefixI True) (S1 (MetaSel (Just "renderDefinition") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

(>>>) :: Category cat => cat a b -> cat b c -> cat a c infixr 1 #

Left-to-right composition

manipDefinition Source #

Arguments

:: Manipulation '[] schemas '[] '[]

no input or output

-> Definition schemas schemas 

A Manipulation without input or output can be run as a statement along with other Definitions, by embedding it using manipDefinition.

Tables

Create

createSchema :: KnownSymbol sch => Alias sch -> Definition schemas (Create sch '[] schemas) Source #

createSchema enters a new schema into the current database. The schema name must be distinct from the name of any existing schema in the current database.

A schema is essentially a namespace: it contains named objects (tables, data types, functions, and operators) whose names can duplicate those of other objects existing in other schemas. Named objects are accessed by QualifiedAliases with the schema name as a prefix.

createSchemaIfNotExists :: (KnownSymbol sch, Has sch schemas schema) => Alias sch -> Definition schemas schemas Source #

Idempotent version of createSchema.

createTable Source #

Arguments

:: (KnownSymbol sch, KnownSymbol tab, columns ~ (col ': cols), SListI columns, SListI constraints, Has sch schemas0 schema0, schemas1 ~ Alter sch (Create tab (Table (constraints :=> columns)) schema0) schemas0) 
=> QualifiedAlias sch tab

the name of the table to add

-> NP (Aliased (ColumnTypeExpression schemas0)) columns

the names and datatype of each column

-> NP (Aliased (TableConstraintExpression sch tab schemas1)) constraints

constraints that must hold for the table

-> Definition schemas0 schemas1 

createTable adds a table to the schema.

>>> :set -XOverloadedLabels
>>> :{
type Table = '[] :=>
  '[ "a" ::: 'NoDef :=> 'Null 'PGint4
   , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public '["tab" ::: 'Table Table])
  setup = createTable #tab
    (nullable int `as` #a :* nullable real `as` #b) Nil
in printSQL setup
:}
CREATE TABLE "tab" ("a" int NULL, "b" real NULL);

createTableIfNotExists Source #

Arguments

:: (Has sch schemas schema, Has tab schema (Table (constraints :=> columns)), SListI columns, SListI constraints) 
=> QualifiedAlias sch tab

the name of the table to add

-> NP (Aliased (ColumnTypeExpression schemas)) columns

the names and datatype of each column

-> NP (Aliased (TableConstraintExpression sch tab schemas)) constraints

constraints that must hold for the table

-> Definition schemas schemas 

createTableIfNotExists creates a table if it doesn't exist, but does not add it to the schema. Instead, the schema already has the table so if the table did not yet exist, the schema was wrong. createTableIfNotExists fixes this. Interestingly, this property makes it an idempotent in the Category of Definitions.

>>> :set -XOverloadedLabels -XTypeApplications
>>> :{
type Table = '[] :=>
  '[ "a" ::: 'NoDef :=> 'Null 'PGint4
   , "b" ::: 'NoDef :=> 'Null 'PGfloat4 ]
:}
>>> type Schemas = Public '["tab" ::: 'Table Table]
>>> :{
let
  setup :: Definition Schemas Schemas
  setup = createTableIfNotExists #tab
    (nullable int `as` #a :* nullable real `as` #b) Nil
in printSQL setup
:}
CREATE TABLE IF NOT EXISTS "tab" ("a" int NULL, "b" real NULL);

createView Source #

Arguments

:: (KnownSymbol sch, KnownSymbol vw, Has sch schemas schema) 
=> QualifiedAlias sch vw

the name of the view to add

-> Query '[] '[] schemas '[] view

query

-> Definition schemas (Alter sch (Create vw (View view) schema) schemas) 

Create a view. >>> type ABC = '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4] >>> type BC = '["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4] >>> :{ let definition :: Definition '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC)]] '[ "public" ::: '["abc" ::: 'Table ('[] :=> ABC), "bc" ::: 'View BC]] definition = createView b :* abc))) in printSQL definition :} CREATE VIEW "bc" AS SELECT "b" AS "b", "c" AS "c" FROM "abc" AS "abc";

createTypeEnum Source #

Arguments

:: (KnownSymbol enum, Has sch schemas schema, All KnownSymbol labels) 
=> QualifiedAlias sch enum

name of the user defined enumerated type

-> NP PGlabel labels

labels of the enumerated type

-> Definition schemas (Alter sch (Create enum (Typedef (PGenum labels)) schema) schemas) 

Enumerated types are created using the createTypeEnum command, for example

>>> printSQL $ (createTypeEnum #mood (label @"sad" :* label @"ok" :* label @"happy") :: Definition (Public '[]) '["public" ::: '["mood" ::: 'Typedef ('PGenum '["sad","ok","happy"])]])
CREATE TYPE "mood" AS ENUM ('sad', 'ok', 'happy');

createTypeEnumFrom Source #

Arguments

:: (Generic hask, All KnownSymbol (LabelsPG hask), KnownSymbol enum, Has sch schemas schema) 
=> QualifiedAlias sch enum

name of the user defined enumerated type

-> Definition schemas (Alter sch (Create enum (Typedef (PG (Enumerated hask))) schema) schemas) 

Enumerated types can also be generated from a Haskell type, for example

>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
>>> instance SOP.Generic Schwarma
>>> instance SOP.HasDatatypeInfo Schwarma
>>> :{
let
  createSchwarma :: Definition (Public '[]) '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]]
  createSchwarma = createTypeEnumFrom @Schwarma #schwarma
in
  printSQL createSchwarma
:}
CREATE TYPE "schwarma" AS ENUM ('Beef', 'Lamb', 'Chicken');

createTypeComposite Source #

Arguments

:: (KnownSymbol ty, Has sch schemas schema, SListI fields) 
=> QualifiedAlias sch ty

name of the user defined composite type

-> NP (Aliased (TypeExpression schemas)) fields

list of attribute names and data types

-> Definition schemas (Alter sch (Create ty (Typedef (PGcomposite fields)) schema) schemas) 

createTypeComposite creates a composite type. The composite type is specified by a list of attribute names and data types.

>>> :{
type PGcomplex = 'PGcomposite
  '[ "real"      ::: 'NotNull 'PGfloat8
   , "imaginary" ::: 'NotNull 'PGfloat8 ]
:}
>>> :{
let
  setup :: Definition (Public '[]) '["public" ::: '["complex" ::: 'Typedef PGcomplex]]
  setup = createTypeComposite #complex
    (float8 `as` #real :* float8 `as` #imaginary)
in printSQL setup
:}
CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);

createTypeCompositeFrom Source #

Arguments

:: (All (FieldTyped schemas) (RowPG hask), KnownSymbol ty, Has sch schemas schema) 
=> QualifiedAlias sch ty

name of the user defined composite type

-> Definition schemas (Alter sch (Create ty (Typedef (PG (Composite hask))) schema) schemas) 

Composite types can also be generated from a Haskell type, for example

>>> data Complex = Complex {real :: Double, imaginary :: Double} deriving GHC.Generic
>>> instance SOP.Generic Complex
>>> instance SOP.HasDatatypeInfo Complex
>>> type Schema = '["complex" ::: 'Typedef (PG (Composite Complex))]
>>> :{
let
  createComplex :: Definition (Public '[]) (Public Schema)
  createComplex = createTypeCompositeFrom @Complex #complex
in
  printSQL createComplex
:}
CREATE TYPE "complex" AS ("real" float8, "imaginary" float8);

class FieldTyped schemas ty where Source #

Lift PGTyped to a field

Methods

fieldtype :: Aliased (TypeExpression schemas) ty Source #

Instances
(KnownSymbol alias, PGTyped schemas ty) => FieldTyped schemas (alias ::: ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

fieldtype :: Aliased (TypeExpression schemas) (alias ::: ty) Source #

createDomain :: (Has sch schemas schema, KnownSymbol dom) => QualifiedAlias sch dom -> (forall nullity. TypeExpression schemas (nullity ty)) -> (forall tab. Condition '[] '[] Ungrouped schemas '[] '[tab ::: '["value" ::: Null ty]]) -> Definition schemas (Alter sch (Create alias (Typedef ty) schema) schemas) Source #

createDomain creates a new domain. A domain is essentially a data type with constraints (restrictions on the allowed set of values).

Domains are useful for abstracting common constraints on fields into a single location for maintenance. For example, several tables might contain email address columns, all requiring the same check constraint to verify the address syntax. Define a domain rather than setting up each table's constraint individually.

>>> :{
let
  createPositive :: Definition (Public '[]) (Public '["positive" ::: 'Typedef 'PGfloat4])
  createPositive = createDomain #positive real (#value .> 0 .&& (#value & isNotNull))
in printSQL createPositive
:}
CREATE DOMAIN "positive" AS real CHECK ((("value" > 0) AND "value" IS NOT NULL));

newtype TableConstraintExpression (sch :: Symbol) (tab :: Symbol) (schemas :: SchemasType) (constraint :: TableConstraint) Source #

Data types are a way to limit the kind of data that can be stored in a table. For many applications, however, the constraint they provide is too coarse. For example, a column containing a product price should probably only accept positive values. But there is no standard data type that accepts only positive numbers. Another issue is that you might want to constrain column data with respect to other columns or rows. For example, in a table containing product information, there should be only one row for each product number. TableConstraints give you as much control over the data in your tables as you wish. If a user attempts to store data in a column that would violate a constraint, an error is raised. This applies even if the value came from the default value definition.

Instances
Eq (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool #

(/=) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool #

Ord (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Ordering #

(<) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool #

(<=) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool #

(>) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool #

(>=) :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> Bool #

max :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint #

min :: TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint -> TableConstraintExpression sch tab schemas constraint #

Show (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> TableConstraintExpression sch tab schemas constraint -> ShowS #

show :: TableConstraintExpression sch tab schemas constraint -> String #

showList :: [TableConstraintExpression sch tab schemas constraint] -> ShowS #

Generic (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (TableConstraintExpression sch tab schemas constraint) :: Type -> Type #

Methods

from :: TableConstraintExpression sch tab schemas constraint -> Rep (TableConstraintExpression sch tab schemas constraint) x #

to :: Rep (TableConstraintExpression sch tab schemas constraint) x -> TableConstraintExpression sch tab schemas constraint #

NFData (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: TableConstraintExpression sch tab schemas constraint -> () #

RenderSQL (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

renderSQL :: TableConstraintExpression sch tab schemas constraint -> ByteString Source #

type Rep (TableConstraintExpression sch tab schemas constraint) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (TableConstraintExpression sch tab schemas constraint) = D1 (MetaData "TableConstraintExpression" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeTableConstraintExpression" PrefixI True) (S1 (MetaSel (Just "renderTableConstraintExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

check Source #

Arguments

:: (Has sch schemas schema, Has tab schema (Table table), HasAll aliases (TableToRow table) subcolumns) 
=> NP Alias aliases

specify the subcolumns which are getting checked

-> (forall t. Condition '[] '[] Ungrouped schemas '[] '[t ::: subcolumns])

a closed Condition on those subcolumns

-> TableConstraintExpression sch tab schemas (Check aliases) 

A check constraint is the most generic TableConstraint type. It allows you to specify that the value in a certain column must satisfy a Boolean (truth-value) expression.

>>> :{
type Schema = '[
  "tab" ::: 'Table ('[ "inequality" ::: 'Check '["a","b"]] :=> '[
    "a" ::: 'NoDef :=> 'NotNull 'PGint4,
    "b" ::: 'NoDef :=> 'NotNull 'PGint4
  ])]
:}
>>> :{
let
  definition :: Definition (Public '[]) (Public Schema)
  definition = createTable #tab
    ( (int & notNullable) `as` #a :*
      (int & notNullable) `as` #b )
    ( check (#a :* #b) (#a .> #b) `as` #inequality )
:}
>>> printSQL definition
CREATE TABLE "tab" ("a" int NOT NULL, "b" int NOT NULL, CONSTRAINT "inequality" CHECK (("a" > "b")));

unique Source #

Arguments

:: (Has sch schemas schema, Has tab schema (Table table), HasAll aliases (TableToRow table) subcolumns) 
=> NP Alias aliases

specify subcolumns which together are unique for each row

-> TableConstraintExpression sch tab schemas (Unique aliases) 

A unique constraint ensure that the data contained in a column, or a group of columns, is unique among all the rows in the table.

>>> :{
type Schema = '[
  "tab" ::: 'Table( '[ "uq_a_b" ::: 'Unique '["a","b"]] :=> '[
    "a" ::: 'NoDef :=> 'Null 'PGint4,
    "b" ::: 'NoDef :=> 'Null 'PGint4
  ])]
:}
>>> :{
let
  definition :: Definition (Public '[]) (Public Schema)
  definition = createTable #tab
    ( (int & nullable) `as` #a :*
      (int & nullable) `as` #b )
    ( unique (#a :* #b) `as` #uq_a_b )
:}
>>> printSQL definition
CREATE TABLE "tab" ("a" int NULL, "b" int NULL, CONSTRAINT "uq_a_b" UNIQUE ("a", "b"));

primaryKey Source #

Arguments

:: (Has sch schemas schema, Has tab schema (Table table), HasAll aliases (TableToColumns table) subcolumns, AllNotNull subcolumns) 
=> NP Alias aliases

specify the subcolumns which together form a primary key.

-> TableConstraintExpression sch tab schemas (PrimaryKey aliases) 

A primaryKey constraint indicates that a column, or group of columns, can be used as a unique identifier for rows in the table. This requires that the values be both unique and not null.

>>> :{
type Schema = '[
  "tab" ::: 'Table ('[ "pk_id" ::: 'PrimaryKey '["id"]] :=> '[
    "id" ::: 'Def :=> 'NotNull 'PGint4,
    "name" ::: 'NoDef :=> 'NotNull 'PGtext
  ])]
:}
>>> :{
let
  definition :: Definition (Public '[]) (Public Schema)
  definition = createTable #tab
    ( serial `as` #id :*
      (text & notNullable) `as` #name )
    ( primaryKey #id `as` #pk_id )
:}
>>> printSQL definition
CREATE TABLE "tab" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_id" PRIMARY KEY ("id"));

foreignKey Source #

Arguments

:: ForeignKeyed schemas sch schema child parent table reftable columns refcolumns constraints cols reftys tys 
=> NP Alias columns

column or columns in the table

-> Alias parent

reference table

-> NP Alias refcolumns

reference column or columns in the reference table

-> OnDeleteClause

what to do when reference is deleted

-> OnUpdateClause

what to do when reference is updated

-> TableConstraintExpression sch child schemas (ForeignKey columns parent refcolumns) 

A foreignKey specifies that the values in a column (or a group of columns) must match the values appearing in some row of another table. We say this maintains the referential integrity between two related tables.

>>> :{
type Schema =
  '[ "users" ::: 'Table (
       '[ "pk_users" ::: 'PrimaryKey '["id"] ] :=>
       '[ "id" ::: 'Def :=> 'NotNull 'PGint4
        , "name" ::: 'NoDef :=> 'NotNull 'PGtext
        ])
   , "emails" ::: 'Table (
       '[  "pk_emails" ::: 'PrimaryKey '["id"]
        , "fk_user_id" ::: 'ForeignKey '["user_id"] "users" '["id"]
        ] :=>
       '[ "id" ::: 'Def :=> 'NotNull 'PGint4
        , "user_id" ::: 'NoDef :=> 'NotNull 'PGint4
        , "email" ::: 'NoDef :=> 'Null 'PGtext
        ])
   ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public Schema)
  setup =
   createTable #users
     ( serial `as` #id :*
       (text & notNullable) `as` #name )
     ( primaryKey #id `as` #pk_users ) >>>
   createTable #emails
     ( serial `as` #id :*
       (int & notNullable) `as` #user_id :*
       (text & nullable) `as` #email )
     ( primaryKey #id `as` #pk_emails :*
       foreignKey #user_id #users #id
         OnDeleteCascade OnUpdateCascade `as` #fk_user_id )
in printSQL setup
:}
CREATE TABLE "users" ("id" serial, "name" text NOT NULL, CONSTRAINT "pk_users" PRIMARY KEY ("id"));
CREATE TABLE "emails" ("id" serial, "user_id" int NOT NULL, "email" text NULL, CONSTRAINT "pk_emails" PRIMARY KEY ("id"), CONSTRAINT "fk_user_id" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE CASCADE ON UPDATE CASCADE);

A foreignKey can even be a table self-reference.

>>> :{
type Schema =
  '[ "employees" ::: 'Table (
       '[ "employees_pk"          ::: 'PrimaryKey '["id"]
        , "employees_employer_fk" ::: 'ForeignKey '["employer_id"] "employees" '["id"]
        ] :=>
       '[ "id"          :::   'Def :=> 'NotNull 'PGint4
        , "name"        ::: 'NoDef :=> 'NotNull 'PGtext
        , "employer_id" ::: 'NoDef :=>    'Null 'PGint4
        ])
   ]
:}
>>> :{
let
  setup :: Definition (Public '[]) (Public Schema)
  setup =
   createTable #employees
     ( serial `as` #id :*
       (text & notNullable) `as` #name :*
       (integer & nullable) `as` #employer_id )
     ( primaryKey #id `as` #employees_pk :*
       foreignKey #employer_id #employees #id
         OnDeleteCascade OnUpdateCascade `as` #employees_employer_fk )
in printSQL setup
:}
CREATE TABLE "employees" ("id" serial, "name" text NOT NULL, "employer_id" integer NULL, CONSTRAINT "employees_pk" PRIMARY KEY ("id"), CONSTRAINT "employees_employer_fk" FOREIGN KEY ("employer_id") REFERENCES "employees" ("id") ON DELETE CASCADE ON UPDATE CASCADE);

type ForeignKeyed schemas sch schema child parent table reftable columns refcolumns constraints cols reftys tys = (Has sch schemas schema, Has child schema (Table table), Has parent schema (Table reftable), HasAll columns (TableToColumns table) tys, reftable ~ (constraints :=> cols), HasAll refcolumns cols reftys, AllZip SamePGType tys reftys, Uniquely refcolumns constraints) Source #

A constraint synonym between types involved in a foreign key constraint.

data OnDeleteClause Source #

OnDeleteClause indicates what to do with rows that reference a deleted row.

Constructors

OnDeleteNoAction

if any referencing rows still exist when the constraint is checked, an error is raised

OnDeleteRestrict

prevents deletion of a referenced row

OnDeleteCascade

specifies that when a referenced row is deleted, row(s) referencing it should be automatically deleted as well

Instances
Eq OnDeleteClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Ord OnDeleteClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Show OnDeleteClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Generic OnDeleteClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep OnDeleteClause :: Type -> Type #

NFData OnDeleteClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: OnDeleteClause -> () #

RenderSQL OnDeleteClause Source #

Render OnDeleteClause.

Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnDeleteClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnDeleteClause = D1 (MetaData "OnDeleteClause" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "OnDeleteNoAction" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "OnDeleteRestrict" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "OnDeleteCascade" PrefixI False) (U1 :: Type -> Type)))

data OnUpdateClause Source #

Analagous to OnDeleteClause there is also OnUpdateClause which is invoked when a referenced column is changed (updated).

Constructors

OnUpdateNoAction

if any referencing rows has not changed when the constraint is checked, an error is raised

OnUpdateRestrict

prevents update of a referenced row

OnUpdateCascade

the updated values of the referenced column(s) should be copied into the referencing row(s)

Instances
Eq OnUpdateClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Ord OnUpdateClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Show OnUpdateClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Generic OnUpdateClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep OnUpdateClause :: Type -> Type #

NFData OnUpdateClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: OnUpdateClause -> () #

RenderSQL OnUpdateClause Source #

Render OnUpdateClause.

Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnUpdateClause Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep OnUpdateClause = D1 (MetaData "OnUpdateClause" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" False) (C1 (MetaCons "OnUpdateNoAction" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "OnUpdateRestrict" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "OnUpdateCascade" PrefixI False) (U1 :: Type -> Type)))

Drop

dropSchema :: Has sch schemas schema => Alias sch -> Definition schemas (Drop sch schemas) Source #

>>> :{
let
  definition :: Definition '["muh_schema" ::: schema, "public" ::: public] '["public" ::: public]
  definition = dropSchema #muh_schema
:}
>>> printSQL definition
DROP SCHEMA "muh_schema";

dropTable Source #

Arguments

:: (Has sch schemas schema, Has tab schema (Table table)) 
=> QualifiedAlias sch tab

table to remove

-> Definition schemas (Alter sch (Drop tab schema) schemas) 

dropTable removes a table from the schema.

>>> :{
let
  definition :: Definition '["public" ::: '["muh_table" ::: 'Table t]] (Public '[])
  definition = dropTable #muh_table
:}
>>> printSQL definition
DROP TABLE "muh_table";

dropView Source #

Arguments

:: (Has sch schemas schema, Has vw schema (View view)) 
=> QualifiedAlias sch vw

view to remove

-> Definition schemas (Alter sch (Drop vw schema) schemas) 

Drop a view.

>>> :{
let
  definition :: Definition
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])
     , "bc"  ::: 'View ('["b" ::: 'Null 'PGint4, "c" ::: 'Null 'PGint4])]]
    '[ "public" ::: '["abc" ::: 'Table ('[] :=> '["a" ::: 'NoDef :=> 'Null 'PGint4, "b" ::: 'NoDef :=> 'Null 'PGint4, "c" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = dropView #bc
in printSQL definition
:}
DROP VIEW "bc";

dropType Source #

Arguments

:: (Has sch schemas schema, Has td schema (Typedef ty)) 
=> QualifiedAlias sch td

name of the user defined type

-> Definition schemas (Alter sch (Drop td schema) schemas) 

Drop a type.

>>> data Schwarma = Beef | Lamb | Chicken deriving GHC.Generic
>>> instance SOP.Generic Schwarma
>>> instance SOP.HasDatatypeInfo Schwarma
>>> printSQL (dropType #schwarma :: Definition '["public" ::: '["schwarma" ::: 'Typedef (PG (Enumerated Schwarma))]] (Public '[]))
DROP TYPE "schwarma";

Alter

alterTable Source #

Arguments

:: (Has sch schemas schema, Has tab schema (Table table0)) 
=> QualifiedAlias sch tab

table to alter

-> AlterTable sch tab schemas table1

alteration to perform

-> Definition schemas (Alter sch (Alter tab (Table table1) schema) schemas) 

alterTable changes the definition of a table from the schema.

alterTableRename Source #

Arguments

:: (KnownSymbol table0, KnownSymbol table1) 
=> Alias table0

table to rename

-> Alias table1

what to rename it

-> Definition schema (Rename table0 table1 schema) 

alterTableRename changes the name of a table from the schema.

>>> printSQL $ alterTableRename #foo #bar
ALTER TABLE "foo" RENAME TO "bar";

newtype AlterTable (sch :: Symbol) (tab :: Symbol) (schemas :: SchemasType) (table :: TableType) Source #

An AlterTable describes the alteration to perform on the columns of a table.

Instances
Eq (AlterTable sch tab schemas table) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool #

(/=) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool #

Ord (AlterTable sch tab schemas table) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Ordering #

(<) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool #

(<=) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool #

(>) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool #

(>=) :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> Bool #

max :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> AlterTable sch tab schemas table #

min :: AlterTable sch tab schemas table -> AlterTable sch tab schemas table -> AlterTable sch tab schemas table #

Show (AlterTable sch tab schemas table) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> AlterTable sch tab schemas table -> ShowS #

show :: AlterTable sch tab schemas table -> String #

showList :: [AlterTable sch tab schemas table] -> ShowS #

Generic (AlterTable sch tab schemas table) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (AlterTable sch tab schemas table) :: Type -> Type #

Methods

from :: AlterTable sch tab schemas table -> Rep (AlterTable sch tab schemas table) x #

to :: Rep (AlterTable sch tab schemas table) x -> AlterTable sch tab schemas table #

NFData (AlterTable sch tab schemas table) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: AlterTable sch tab schemas table -> () #

type Rep (AlterTable sch tab schemas table) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (AlterTable sch tab schemas table) = D1 (MetaData "AlterTable" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeAlterTable" PrefixI True) (S1 (MetaSel (Just "renderAlterTable") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

addConstraint Source #

Arguments

:: (KnownSymbol alias, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (Create alias constraint constraints :=> columns)) 
=> Alias alias 
-> TableConstraintExpression sch tab schemas constraint

constraint to add

-> AlterTable sch tab schemas table1 

An addConstraint adds a table constraint.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('["positive" ::: 'Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
  definition = alterTable #tab (addConstraint #positive (check #col (#col .> 0)))
in printSQL definition
:}
ALTER TABLE "tab" ADD CONSTRAINT "positive" CHECK (("col" > 0));

dropConstraint Source #

Arguments

:: (KnownSymbol constraint, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (Drop constraint constraints :=> columns)) 
=> Alias constraint

constraint to drop

-> AlterTable sch tab schemas table1 

A dropConstraint drops a table constraint.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('["positive" ::: Check '["col"]] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
  definition = alterTable #tab (dropConstraint #positive)
in printSQL definition
:}
ALTER TABLE "tab" DROP CONSTRAINT "positive";

class AddColumn ty where Source #

An AddColumn is either NULL or has DEFAULT.

Minimal complete definition

Nothing

Methods

addColumn Source #

Arguments

:: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) 
=> Alias column

column to add

-> ColumnTypeExpression schemas ty

type of the new column

-> AlterTable sch tab schemas (constraints :=> Create column ty columns) 

addColumn adds a new column, initially filled with whatever default value is given or with NULL.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=>
       '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
        , "col2" ::: 'Def :=> 'Null 'PGtext ])]]
  definition = alterTable #tab (addColumn #col2 (text & nullable & default_ "foo"))
in printSQL definition
:}
ALTER TABLE "tab" ADD COLUMN "col2" text NULL DEFAULT E'foo';
>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=>
       '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
        , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]]
  definition = alterTable #tab (addColumn #col2 (text & nullable))
in printSQL definition
:}
ALTER TABLE "tab" ADD COLUMN "col2" text NULL;
Instances
AddColumn (Def :=> ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (Def :=> ty) -> AlterTable sch tab schemas (constraints :=> Create column (Def :=> ty) columns) Source #

AddColumn (NoDef :=> Null ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

addColumn :: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns)) => Alias column -> ColumnTypeExpression schemas (NoDef :=> Null ty) -> AlterTable sch tab schemas (constraints :=> Create column (NoDef :=> Null ty) columns) Source #

dropColumn Source #

Arguments

:: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (constraints :=> Drop column columns)) 
=> Alias column

column to remove

-> AlterTable sch tab schemas table1 

A dropColumn removes a column. Whatever data was in the column disappears. Table constraints involving the column are dropped, too. However, if the column is referenced by a foreign key constraint of another table, PostgreSQL will not silently drop that constraint.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=>
       '[ "col1" ::: 'NoDef :=> 'Null 'PGint4
        , "col2" ::: 'NoDef :=> 'Null 'PGtext ])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col1" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (dropColumn #col2)
in printSQL definition
:}
ALTER TABLE "tab" DROP COLUMN "col2";

renameColumn Source #

Arguments

:: (KnownSymbol column0, KnownSymbol column1, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), table1 ~ (constraints :=> Rename column0 column1 columns)) 
=> Alias column0

column to rename

-> Alias column1

what to rename the column

-> AlterTable sch tab schemas table1 

A renameColumn renames a column.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["foo" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["bar" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (renameColumn #foo #bar)
in printSQL definition
:}
ALTER TABLE "tab" RENAME COLUMN "foo" TO "bar";

alterColumn Source #

Arguments

:: (KnownSymbol column, Has sch schemas schema, Has tab schema (Table table0), table0 ~ (constraints :=> columns), Has column columns ty0, table1 ~ (constraints :=> Alter column ty1 columns)) 
=> Alias column

column to alter

-> AlterColumn schemas ty0 ty1

alteration to perform

-> AlterTable sch tab schemas table1 

An alterColumn alters a single column.

newtype AlterColumn (schemas :: SchemasType) (ty0 :: ColumnType) (ty1 :: ColumnType) Source #

An AlterColumn describes the alteration to perform on a single column.

Instances
Eq (AlterColumn schemas ty0 ty1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool #

(/=) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool #

Ord (AlterColumn schemas ty0 ty1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Ordering #

(<) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool #

(<=) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool #

(>) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool #

(>=) :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> Bool #

max :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 #

min :: AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 -> AlterColumn schemas ty0 ty1 #

Show (AlterColumn schemas ty0 ty1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> AlterColumn schemas ty0 ty1 -> ShowS #

show :: AlterColumn schemas ty0 ty1 -> String #

showList :: [AlterColumn schemas ty0 ty1] -> ShowS #

Generic (AlterColumn schemas ty0 ty1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (AlterColumn schemas ty0 ty1) :: Type -> Type #

Methods

from :: AlterColumn schemas ty0 ty1 -> Rep (AlterColumn schemas ty0 ty1) x #

to :: Rep (AlterColumn schemas ty0 ty1) x -> AlterColumn schemas ty0 ty1 #

NFData (AlterColumn schemas ty0 ty1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: AlterColumn schemas ty0 ty1 -> () #

type Rep (AlterColumn schemas ty0 ty1) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (AlterColumn schemas ty0 ty1) = D1 (MetaData "AlterColumn" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeAlterColumn" PrefixI True) (S1 (MetaSel (Just "renderAlterColumn") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

setDefault Source #

Arguments

:: Expression '[] '[] Ungrouped schemas '[] '[] ty

default value to set

-> AlterColumn schemas (constraint :=> ty) (Def :=> ty) 

A setDefault sets a new default for a column. Note that this doesn't affect any existing rows in the table, it just changes the default for future insert and update commands.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]]
  definition = alterTable #tab (alterColumn #col (setDefault 5))
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" SET DEFAULT 5;

dropDefault :: AlterColumn schemas (Def :=> ty) (NoDef :=> ty) Source #

A dropDefault removes any default value for a column.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'Def :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (alterColumn #col dropDefault)
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" DROP DEFAULT;

setNotNull :: AlterColumn schemas (constraint :=> Null ty) (constraint :=> NotNull ty) Source #

A setNotNull adds a NOT NULL constraint to a column. The constraint will be checked immediately, so the table data must satisfy the constraint before it can be added.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
  definition = alterTable #tab (alterColumn #col setNotNull)
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" SET NOT NULL;

dropNotNull :: AlterColumn schemas (constraint :=> NotNull ty) (constraint :=> Null ty) Source #

A dropNotNull drops a NOT NULL constraint from a column.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'Null 'PGint4])]]
  definition = alterTable #tab (alterColumn #col dropNotNull)
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" DROP NOT NULL;

alterType :: ColumnTypeExpression schemas ty -> AlterColumn schemas ty0 ty Source #

An alterType converts a column to a different data type. This will succeed only if each existing entry in the column can be converted to the new type by an implicit cast.

>>> :{
let
  definition :: Definition
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGint4])]]
    '["public" ::: '["tab" ::: 'Table ('[] :=> '["col" ::: 'NoDef :=> 'NotNull 'PGnumeric])]]
  definition =
    alterTable #tab (alterColumn #col (alterType (numeric & notNullable)))
in printSQL definition
:}
ALTER TABLE "tab" ALTER COLUMN "col" TYPE numeric NOT NULL;

Columns

newtype ColumnTypeExpression (schemas :: SchemasType) (ty :: ColumnType) Source #

ColumnTypeExpressions are used in createTable commands.

Instances
Eq (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

(==) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(/=) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

Ord (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

compare :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Ordering #

(<) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(<=) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(>) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

(>=) :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> Bool #

max :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty #

min :: ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty -> ColumnTypeExpression schemas ty #

Show (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

showsPrec :: Int -> ColumnTypeExpression schemas ty -> ShowS #

show :: ColumnTypeExpression schemas ty -> String #

showList :: [ColumnTypeExpression schemas ty] -> ShowS #

Generic (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Associated Types

type Rep (ColumnTypeExpression schemas ty) :: Type -> Type #

Methods

from :: ColumnTypeExpression schemas ty -> Rep (ColumnTypeExpression schemas ty) x #

to :: Rep (ColumnTypeExpression schemas ty) x -> ColumnTypeExpression schemas ty #

NFData (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

Methods

rnf :: ColumnTypeExpression schemas ty -> () #

RenderSQL (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (ColumnTypeExpression schemas ty) Source # 
Instance details

Defined in Squeal.PostgreSQL.Definition

type Rep (ColumnTypeExpression schemas ty) = D1 (MetaData "ColumnTypeExpression" "Squeal.PostgreSQL.Definition" "squeal-postgresql-0.5.2.0-4fAomBtpMjd6mRwLthA4w2" True) (C1 (MetaCons "UnsafeColumnTypeExpression" PrefixI True) (S1 (MetaSel (Just "renderColumnTypeExpression") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

nullable :: TypeExpression schemas (nullity ty) -> ColumnTypeExpression schemas (NoDef :=> Null ty) Source #

used in createTable commands as a column constraint to note that NULL may be present in a column

notNullable :: TypeExpression schemas (nullity ty) -> ColumnTypeExpression schemas (NoDef :=> NotNull ty) Source #

used in createTable commands as a column constraint to ensure NULL is not present in a column

default_ :: Expression '[] '[] Ungrouped schemas '[] '[] ty -> ColumnTypeExpression schemas (NoDef :=> ty) -> ColumnTypeExpression schemas (Def :=> ty) Source #

used in createTable commands as a column constraint to give a default

serial2 :: ColumnTypeExpression schemas (Def :=> NotNull PGint2) Source #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint2

smallserial :: ColumnTypeExpression schemas (Def :=> NotNull PGint2) Source #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint2

serial4 :: ColumnTypeExpression schemas (Def :=> NotNull PGint4) Source #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint4

serial :: ColumnTypeExpression schemas (Def :=> NotNull PGint4) Source #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint4

serial8 :: ColumnTypeExpression schemas (Def :=> NotNull PGint8) Source #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint8

bigserial :: ColumnTypeExpression schemas (Def :=> NotNull PGint8) Source #

not a true type, but merely a notational convenience for creating unique identifier columns with type PGint8