{-# LANGUAGE
AllowAmbiguousTypes
, ConstraintKinds
, DeriveAnyClass
, DeriveGeneric
, DerivingStrategies
, FlexibleContexts
, FlexibleInstances
, GADTs
, LambdaCase
, MultiParamTypeClasses
, OverloadedLabels
, OverloadedStrings
, RankNTypes
, ScopedTypeVariables
, TypeApplications
, TypeInType
, TypeOperators
, UndecidableSuperClasses
#-}
module Squeal.PostgreSQL.Definition.Constraint
(
TableConstraintExpression (..)
, check
, unique
, primaryKey
, foreignKey
, ForeignKeyed
, OnDeleteClause (..)
, OnUpdateClause (..)
, ReferentialAction (..)
) where
import Control.DeepSeq
import Data.ByteString
import GHC.TypeLits
import qualified Generics.SOP as SOP
import qualified GHC.Generics as GHC
import Squeal.PostgreSQL.Type.Alias
import Squeal.PostgreSQL.Expression.Logic
import Squeal.PostgreSQL.Type.List
import Squeal.PostgreSQL.Render
import Squeal.PostgreSQL.Type.Schema
newtype TableConstraintExpression
(sch :: Symbol)
(tab :: Symbol)
(db :: SchemasType)
(constraint :: TableConstraint)
= UnsafeTableConstraintExpression
{ TableConstraintExpression sch tab db constraint -> ByteString
renderTableConstraintExpression :: ByteString }
deriving ((forall x.
TableConstraintExpression sch tab db constraint
-> Rep (TableConstraintExpression sch tab db constraint) x)
-> (forall x.
Rep (TableConstraintExpression sch tab db constraint) x
-> TableConstraintExpression sch tab db constraint)
-> Generic (TableConstraintExpression sch tab db constraint)
forall x.
Rep (TableConstraintExpression sch tab db constraint) x
-> TableConstraintExpression sch tab db constraint
forall x.
TableConstraintExpression sch tab db constraint
-> Rep (TableConstraintExpression sch tab db constraint) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint) x.
Rep (TableConstraintExpression sch tab db constraint) x
-> TableConstraintExpression sch tab db constraint
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint) x.
TableConstraintExpression sch tab db constraint
-> Rep (TableConstraintExpression sch tab db constraint) x
$cto :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint) x.
Rep (TableConstraintExpression sch tab db constraint) x
-> TableConstraintExpression sch tab db constraint
$cfrom :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint) x.
TableConstraintExpression sch tab db constraint
-> Rep (TableConstraintExpression sch tab db constraint) x
GHC.Generic,Int -> TableConstraintExpression sch tab db constraint -> ShowS
[TableConstraintExpression sch tab db constraint] -> ShowS
TableConstraintExpression sch tab db constraint -> String
(Int -> TableConstraintExpression sch tab db constraint -> ShowS)
-> (TableConstraintExpression sch tab db constraint -> String)
-> ([TableConstraintExpression sch tab db constraint] -> ShowS)
-> Show (TableConstraintExpression sch tab db constraint)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
Int -> TableConstraintExpression sch tab db constraint -> ShowS
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
[TableConstraintExpression sch tab db constraint] -> ShowS
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint -> String
showList :: [TableConstraintExpression sch tab db constraint] -> ShowS
$cshowList :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
[TableConstraintExpression sch tab db constraint] -> ShowS
show :: TableConstraintExpression sch tab db constraint -> String
$cshow :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint -> String
showsPrec :: Int -> TableConstraintExpression sch tab db constraint -> ShowS
$cshowsPrec :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
Int -> TableConstraintExpression sch tab db constraint -> ShowS
Show,TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
(TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool)
-> Eq (TableConstraintExpression sch tab db constraint)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
/= :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
$c/= :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
== :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
$c== :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
Eq,Eq (TableConstraintExpression sch tab db constraint)
Eq (TableConstraintExpression sch tab db constraint)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Ordering)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint)
-> (TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint)
-> Ord (TableConstraintExpression sch tab db constraint)
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Ordering
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
Eq (TableConstraintExpression sch tab db constraint)
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Ordering
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
min :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
$cmin :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
max :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
$cmax :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint
>= :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
$c>= :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
> :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
$c> :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
<= :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
$c<= :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
< :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
$c< :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Bool
compare :: TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Ordering
$ccompare :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint
-> TableConstraintExpression sch tab db constraint -> Ordering
$cp1Ord :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
Eq (TableConstraintExpression sch tab db constraint)
Ord,TableConstraintExpression sch tab db constraint -> ()
(TableConstraintExpression sch tab db constraint -> ())
-> NFData (TableConstraintExpression sch tab db constraint)
forall a. (a -> ()) -> NFData a
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint -> ()
rnf :: TableConstraintExpression sch tab db constraint -> ()
$crnf :: forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint -> ()
NFData)
instance RenderSQL
(TableConstraintExpression sch tab db constraint) where
renderSQL :: TableConstraintExpression sch tab db constraint -> ByteString
renderSQL = TableConstraintExpression sch tab db constraint -> ByteString
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
TableConstraintExpression sch tab db constraint -> ByteString
renderTableConstraintExpression
check
:: ( Has sch db schema
, Has tab schema ('Table table)
, HasAll aliases (TableToRow table) subcolumns )
=> NP Alias aliases
-> (forall t. Condition 'Ungrouped '[] '[] db '[] '[t ::: subcolumns])
-> TableConstraintExpression sch tab db ('Check aliases)
check :: NP Alias aliases
-> (forall (t :: Symbol).
Condition 'Ungrouped '[] '[] db '[] '[t ::: subcolumns])
-> TableConstraintExpression sch tab db ('Check aliases)
check NP Alias aliases
_cols forall (t :: Symbol).
Condition 'Ungrouped '[] '[] db '[] '[t ::: subcolumns]
condition = ByteString -> TableConstraintExpression sch tab db ('Check aliases)
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
ByteString -> TableConstraintExpression sch tab db constraint
UnsafeTableConstraintExpression (ByteString
-> TableConstraintExpression sch tab db ('Check aliases))
-> ByteString
-> TableConstraintExpression sch tab db ('Check aliases)
forall a b. (a -> b) -> a -> b
$
ByteString
"CHECK" ByteString -> ByteString -> ByteString
<+> ByteString -> ByteString
parenthesized (Condition 'Ungrouped '[] '[] db '[] '[Any ::: subcolumns]
-> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL Condition 'Ungrouped '[] '[] db '[] '[Any ::: subcolumns]
forall (t :: Symbol).
Condition 'Ungrouped '[] '[] db '[] '[t ::: subcolumns]
condition)
unique
:: ( Has sch db schema
, Has tab schema ('Table table)
, HasAll aliases (TableToRow table) subcolumns )
=> NP Alias aliases
-> TableConstraintExpression sch tab db ('Unique aliases)
unique :: NP Alias aliases
-> TableConstraintExpression sch tab db ('Unique aliases)
unique NP Alias aliases
columns = ByteString
-> TableConstraintExpression sch tab db ('Unique aliases)
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
ByteString -> TableConstraintExpression sch tab db constraint
UnsafeTableConstraintExpression (ByteString
-> TableConstraintExpression sch tab db ('Unique aliases))
-> ByteString
-> TableConstraintExpression sch tab db ('Unique aliases)
forall a b. (a -> b) -> a -> b
$
ByteString
"UNIQUE" ByteString -> ByteString -> ByteString
<+> ByteString -> ByteString
parenthesized (NP Alias aliases -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL NP Alias aliases
columns)
primaryKey
:: ( Has sch db schema
, Has tab schema ('Table table)
, HasAll aliases (TableToColumns table) subcolumns
, AllNotNull subcolumns )
=> NP Alias aliases
-> TableConstraintExpression sch tab db ('PrimaryKey aliases)
primaryKey :: NP Alias aliases
-> TableConstraintExpression sch tab db ('PrimaryKey aliases)
primaryKey NP Alias aliases
columns = ByteString
-> TableConstraintExpression sch tab db ('PrimaryKey aliases)
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
ByteString -> TableConstraintExpression sch tab db constraint
UnsafeTableConstraintExpression (ByteString
-> TableConstraintExpression sch tab db ('PrimaryKey aliases))
-> ByteString
-> TableConstraintExpression sch tab db ('PrimaryKey aliases)
forall a b. (a -> b) -> a -> b
$
ByteString
"PRIMARY KEY" ByteString -> ByteString -> ByteString
<+> ByteString -> ByteString
parenthesized (NP Alias aliases -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL NP Alias aliases
columns)
foreignKey
:: (ForeignKeyed db
sch0 sch1
schema0 schema1
child parent
table reftable
columns refcolumns
constraints cols
reftys tys )
=> NP Alias columns
-> QualifiedAlias sch0 parent
-> NP Alias refcolumns
-> OnDeleteClause
-> OnUpdateClause
-> TableConstraintExpression sch1 child db
('ForeignKey columns sch0 parent refcolumns)
foreignKey :: NP Alias columns
-> QualifiedAlias sch0 parent
-> NP Alias refcolumns
-> OnDeleteClause
-> OnUpdateClause
-> TableConstraintExpression
sch1 child db ('ForeignKey columns sch0 parent refcolumns)
foreignKey NP Alias columns
keys QualifiedAlias sch0 parent
parent NP Alias refcolumns
refs OnDeleteClause
ondel OnUpdateClause
onupd = ByteString
-> TableConstraintExpression
sch1 child db ('ForeignKey columns sch0 parent refcolumns)
forall (sch :: Symbol) (tab :: Symbol) (db :: SchemasType)
(constraint :: TableConstraint).
ByteString -> TableConstraintExpression sch tab db constraint
UnsafeTableConstraintExpression (ByteString
-> TableConstraintExpression
sch1 child db ('ForeignKey columns sch0 parent refcolumns))
-> ByteString
-> TableConstraintExpression
sch1 child db ('ForeignKey columns sch0 parent refcolumns)
forall a b. (a -> b) -> a -> b
$
ByteString
"FOREIGN KEY" ByteString -> ByteString -> ByteString
<+> ByteString -> ByteString
parenthesized (NP Alias columns -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL NP Alias columns
keys)
ByteString -> ByteString -> ByteString
<+> ByteString
"REFERENCES" ByteString -> ByteString -> ByteString
<+> QualifiedAlias sch0 parent -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL QualifiedAlias sch0 parent
parent
ByteString -> ByteString -> ByteString
<+> ByteString -> ByteString
parenthesized (NP Alias refcolumns -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL NP Alias refcolumns
refs)
ByteString -> ByteString -> ByteString
<+> OnDeleteClause -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL OnDeleteClause
ondel
ByteString -> ByteString -> ByteString
<+> OnUpdateClause -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL OnUpdateClause
onupd
type ForeignKeyed db
sch0 sch1
schema0 schema1
child parent
table reftable
columns refcolumns
constraints cols
reftys tys =
( Has sch0 db schema0
, Has sch1 db schema1
, Has parent schema0 ('Table reftable)
, Has child schema1 ('Table table)
, HasAll columns (TableToColumns table) tys
, reftable ~ (constraints :=> cols)
, HasAll refcolumns cols reftys
, SOP.AllZip SamePGType tys reftys
, Uniquely refcolumns constraints )
newtype OnDeleteClause = OnDelete ReferentialAction
deriving ((forall x. OnDeleteClause -> Rep OnDeleteClause x)
-> (forall x. Rep OnDeleteClause x -> OnDeleteClause)
-> Generic OnDeleteClause
forall x. Rep OnDeleteClause x -> OnDeleteClause
forall x. OnDeleteClause -> Rep OnDeleteClause x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnDeleteClause x -> OnDeleteClause
$cfrom :: forall x. OnDeleteClause -> Rep OnDeleteClause x
GHC.Generic,Int -> OnDeleteClause -> ShowS
[OnDeleteClause] -> ShowS
OnDeleteClause -> String
(Int -> OnDeleteClause -> ShowS)
-> (OnDeleteClause -> String)
-> ([OnDeleteClause] -> ShowS)
-> Show OnDeleteClause
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnDeleteClause] -> ShowS
$cshowList :: [OnDeleteClause] -> ShowS
show :: OnDeleteClause -> String
$cshow :: OnDeleteClause -> String
showsPrec :: Int -> OnDeleteClause -> ShowS
$cshowsPrec :: Int -> OnDeleteClause -> ShowS
Show,OnDeleteClause -> OnDeleteClause -> Bool
(OnDeleteClause -> OnDeleteClause -> Bool)
-> (OnDeleteClause -> OnDeleteClause -> Bool) -> Eq OnDeleteClause
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnDeleteClause -> OnDeleteClause -> Bool
$c/= :: OnDeleteClause -> OnDeleteClause -> Bool
== :: OnDeleteClause -> OnDeleteClause -> Bool
$c== :: OnDeleteClause -> OnDeleteClause -> Bool
Eq,Eq OnDeleteClause
Eq OnDeleteClause
-> (OnDeleteClause -> OnDeleteClause -> Ordering)
-> (OnDeleteClause -> OnDeleteClause -> Bool)
-> (OnDeleteClause -> OnDeleteClause -> Bool)
-> (OnDeleteClause -> OnDeleteClause -> Bool)
-> (OnDeleteClause -> OnDeleteClause -> Bool)
-> (OnDeleteClause -> OnDeleteClause -> OnDeleteClause)
-> (OnDeleteClause -> OnDeleteClause -> OnDeleteClause)
-> Ord OnDeleteClause
OnDeleteClause -> OnDeleteClause -> Bool
OnDeleteClause -> OnDeleteClause -> Ordering
OnDeleteClause -> OnDeleteClause -> OnDeleteClause
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OnDeleteClause -> OnDeleteClause -> OnDeleteClause
$cmin :: OnDeleteClause -> OnDeleteClause -> OnDeleteClause
max :: OnDeleteClause -> OnDeleteClause -> OnDeleteClause
$cmax :: OnDeleteClause -> OnDeleteClause -> OnDeleteClause
>= :: OnDeleteClause -> OnDeleteClause -> Bool
$c>= :: OnDeleteClause -> OnDeleteClause -> Bool
> :: OnDeleteClause -> OnDeleteClause -> Bool
$c> :: OnDeleteClause -> OnDeleteClause -> Bool
<= :: OnDeleteClause -> OnDeleteClause -> Bool
$c<= :: OnDeleteClause -> OnDeleteClause -> Bool
< :: OnDeleteClause -> OnDeleteClause -> Bool
$c< :: OnDeleteClause -> OnDeleteClause -> Bool
compare :: OnDeleteClause -> OnDeleteClause -> Ordering
$ccompare :: OnDeleteClause -> OnDeleteClause -> Ordering
$cp1Ord :: Eq OnDeleteClause
Ord)
instance NFData OnDeleteClause
instance RenderSQL OnDeleteClause where
renderSQL :: OnDeleteClause -> ByteString
renderSQL (OnDelete ReferentialAction
action) = ByteString
"ON DELETE" ByteString -> ByteString -> ByteString
<+> ReferentialAction -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL ReferentialAction
action
newtype OnUpdateClause = OnUpdate ReferentialAction
deriving ((forall x. OnUpdateClause -> Rep OnUpdateClause x)
-> (forall x. Rep OnUpdateClause x -> OnUpdateClause)
-> Generic OnUpdateClause
forall x. Rep OnUpdateClause x -> OnUpdateClause
forall x. OnUpdateClause -> Rep OnUpdateClause x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OnUpdateClause x -> OnUpdateClause
$cfrom :: forall x. OnUpdateClause -> Rep OnUpdateClause x
GHC.Generic,Int -> OnUpdateClause -> ShowS
[OnUpdateClause] -> ShowS
OnUpdateClause -> String
(Int -> OnUpdateClause -> ShowS)
-> (OnUpdateClause -> String)
-> ([OnUpdateClause] -> ShowS)
-> Show OnUpdateClause
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OnUpdateClause] -> ShowS
$cshowList :: [OnUpdateClause] -> ShowS
show :: OnUpdateClause -> String
$cshow :: OnUpdateClause -> String
showsPrec :: Int -> OnUpdateClause -> ShowS
$cshowsPrec :: Int -> OnUpdateClause -> ShowS
Show,OnUpdateClause -> OnUpdateClause -> Bool
(OnUpdateClause -> OnUpdateClause -> Bool)
-> (OnUpdateClause -> OnUpdateClause -> Bool) -> Eq OnUpdateClause
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OnUpdateClause -> OnUpdateClause -> Bool
$c/= :: OnUpdateClause -> OnUpdateClause -> Bool
== :: OnUpdateClause -> OnUpdateClause -> Bool
$c== :: OnUpdateClause -> OnUpdateClause -> Bool
Eq,Eq OnUpdateClause
Eq OnUpdateClause
-> (OnUpdateClause -> OnUpdateClause -> Ordering)
-> (OnUpdateClause -> OnUpdateClause -> Bool)
-> (OnUpdateClause -> OnUpdateClause -> Bool)
-> (OnUpdateClause -> OnUpdateClause -> Bool)
-> (OnUpdateClause -> OnUpdateClause -> Bool)
-> (OnUpdateClause -> OnUpdateClause -> OnUpdateClause)
-> (OnUpdateClause -> OnUpdateClause -> OnUpdateClause)
-> Ord OnUpdateClause
OnUpdateClause -> OnUpdateClause -> Bool
OnUpdateClause -> OnUpdateClause -> Ordering
OnUpdateClause -> OnUpdateClause -> OnUpdateClause
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OnUpdateClause -> OnUpdateClause -> OnUpdateClause
$cmin :: OnUpdateClause -> OnUpdateClause -> OnUpdateClause
max :: OnUpdateClause -> OnUpdateClause -> OnUpdateClause
$cmax :: OnUpdateClause -> OnUpdateClause -> OnUpdateClause
>= :: OnUpdateClause -> OnUpdateClause -> Bool
$c>= :: OnUpdateClause -> OnUpdateClause -> Bool
> :: OnUpdateClause -> OnUpdateClause -> Bool
$c> :: OnUpdateClause -> OnUpdateClause -> Bool
<= :: OnUpdateClause -> OnUpdateClause -> Bool
$c<= :: OnUpdateClause -> OnUpdateClause -> Bool
< :: OnUpdateClause -> OnUpdateClause -> Bool
$c< :: OnUpdateClause -> OnUpdateClause -> Bool
compare :: OnUpdateClause -> OnUpdateClause -> Ordering
$ccompare :: OnUpdateClause -> OnUpdateClause -> Ordering
$cp1Ord :: Eq OnUpdateClause
Ord)
instance NFData OnUpdateClause
instance RenderSQL OnUpdateClause where
renderSQL :: OnUpdateClause -> ByteString
renderSQL (OnUpdate ReferentialAction
action) = ByteString
"ON UPDATE" ByteString -> ByteString -> ByteString
<+> ReferentialAction -> ByteString
forall sql. RenderSQL sql => sql -> ByteString
renderSQL ReferentialAction
action
data ReferentialAction
= NoAction
| Restrict
| Cascade
| SetNull
| SetDefault
deriving ((forall x. ReferentialAction -> Rep ReferentialAction x)
-> (forall x. Rep ReferentialAction x -> ReferentialAction)
-> Generic ReferentialAction
forall x. Rep ReferentialAction x -> ReferentialAction
forall x. ReferentialAction -> Rep ReferentialAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReferentialAction x -> ReferentialAction
$cfrom :: forall x. ReferentialAction -> Rep ReferentialAction x
GHC.Generic,Int -> ReferentialAction -> ShowS
[ReferentialAction] -> ShowS
ReferentialAction -> String
(Int -> ReferentialAction -> ShowS)
-> (ReferentialAction -> String)
-> ([ReferentialAction] -> ShowS)
-> Show ReferentialAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReferentialAction] -> ShowS
$cshowList :: [ReferentialAction] -> ShowS
show :: ReferentialAction -> String
$cshow :: ReferentialAction -> String
showsPrec :: Int -> ReferentialAction -> ShowS
$cshowsPrec :: Int -> ReferentialAction -> ShowS
Show,ReferentialAction -> ReferentialAction -> Bool
(ReferentialAction -> ReferentialAction -> Bool)
-> (ReferentialAction -> ReferentialAction -> Bool)
-> Eq ReferentialAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReferentialAction -> ReferentialAction -> Bool
$c/= :: ReferentialAction -> ReferentialAction -> Bool
== :: ReferentialAction -> ReferentialAction -> Bool
$c== :: ReferentialAction -> ReferentialAction -> Bool
Eq,Eq ReferentialAction
Eq ReferentialAction
-> (ReferentialAction -> ReferentialAction -> Ordering)
-> (ReferentialAction -> ReferentialAction -> Bool)
-> (ReferentialAction -> ReferentialAction -> Bool)
-> (ReferentialAction -> ReferentialAction -> Bool)
-> (ReferentialAction -> ReferentialAction -> Bool)
-> (ReferentialAction -> ReferentialAction -> ReferentialAction)
-> (ReferentialAction -> ReferentialAction -> ReferentialAction)
-> Ord ReferentialAction
ReferentialAction -> ReferentialAction -> Bool
ReferentialAction -> ReferentialAction -> Ordering
ReferentialAction -> ReferentialAction -> ReferentialAction
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ReferentialAction -> ReferentialAction -> ReferentialAction
$cmin :: ReferentialAction -> ReferentialAction -> ReferentialAction
max :: ReferentialAction -> ReferentialAction -> ReferentialAction
$cmax :: ReferentialAction -> ReferentialAction -> ReferentialAction
>= :: ReferentialAction -> ReferentialAction -> Bool
$c>= :: ReferentialAction -> ReferentialAction -> Bool
> :: ReferentialAction -> ReferentialAction -> Bool
$c> :: ReferentialAction -> ReferentialAction -> Bool
<= :: ReferentialAction -> ReferentialAction -> Bool
$c<= :: ReferentialAction -> ReferentialAction -> Bool
< :: ReferentialAction -> ReferentialAction -> Bool
$c< :: ReferentialAction -> ReferentialAction -> Bool
compare :: ReferentialAction -> ReferentialAction -> Ordering
$ccompare :: ReferentialAction -> ReferentialAction -> Ordering
$cp1Ord :: Eq ReferentialAction
Ord)
instance NFData ReferentialAction
instance RenderSQL ReferentialAction where
renderSQL :: ReferentialAction -> ByteString
renderSQL = \case
ReferentialAction
NoAction -> ByteString
"NO ACTION"
ReferentialAction
Restrict -> ByteString
"RESTRICT"
ReferentialAction
Cascade -> ByteString
"CASCADE"
ReferentialAction
SetNull -> ByteString
"SET NULL"
ReferentialAction
SetDefault -> ByteString
"SET DEFAULT"