{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE CPP #-}
module Database.Beam.Migrate.SQL.Builder where
import Database.Beam.Backend.SQL
import Database.Beam.Backend.SQL.Builder
import Database.Beam.Migrate.SQL
import Database.Beam.Migrate.Serialization
import Control.Applicative
import Data.ByteString.Builder (Builder, byteString, toLazyByteString)
import qualified Data.ByteString.Lazy.Char8 as BCL
#if !MIN_VERSION_base(4, 11, 0)
import Data.Semigroup
#endif
data SqlSyntaxBuilderCreateTableOptions
= SqlSyntaxBuilderCreateTableOptions
SqlSyntaxBuilder
SqlSyntaxBuilder
deriving SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool
(SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool)
-> (SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool)
-> Eq SqlSyntaxBuilderCreateTableOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool
$c/= :: SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool
== :: SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool
$c== :: SqlSyntaxBuilderCreateTableOptions
-> SqlSyntaxBuilderCreateTableOptions -> Bool
Eq
instance IsSql92DdlCommandSyntax SqlSyntaxBuilder where
type Sql92DdlCommandCreateTableSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92DdlCommandDropTableSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92DdlCommandAlterTableSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
createTableCmd :: Sql92DdlCommandCreateTableSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
createTableCmd = Sql92DdlCommandCreateTableSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
forall a. a -> a
id
alterTableCmd :: Sql92DdlCommandAlterTableSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
alterTableCmd = Sql92DdlCommandAlterTableSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
forall a. a -> a
id
dropTableCmd :: Sql92DdlCommandDropTableSyntax SqlSyntaxBuilder -> SqlSyntaxBuilder
dropTableCmd = Sql92DdlCommandDropTableSyntax SqlSyntaxBuilder -> SqlSyntaxBuilder
forall a. a -> a
id
instance IsSql92DropTableSyntax SqlSyntaxBuilder where
type Sql92DropTableTableNameSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
dropTableSyntax :: Sql92DropTableTableNameSyntax SqlSyntaxBuilder -> SqlSyntaxBuilder
dropTableSyntax Sql92DropTableTableNameSyntax SqlSyntaxBuilder
tblNm =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"DROP TABLE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql Sql92DropTableTableNameSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
tblNm
instance IsSql92AlterTableSyntax SqlSyntaxBuilder where
type Sql92AlterTableTableNameSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92AlterTableAlterTableActionSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
alterTableSyntax :: Sql92AlterTableTableNameSyntax SqlSyntaxBuilder
-> Sql92AlterTableAlterTableActionSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
alterTableSyntax Sql92AlterTableTableNameSyntax SqlSyntaxBuilder
tblNm Sql92AlterTableAlterTableActionSyntax SqlSyntaxBuilder
action =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"ALTER TABLE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql Sql92AlterTableTableNameSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
tblNm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql Sql92AlterTableAlterTableActionSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
action
instance IsSql92AlterTableActionSyntax SqlSyntaxBuilder where
type Sql92AlterTableAlterColumnActionSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92AlterTableColumnSchemaSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
alterColumnSyntax :: Text
-> Sql92AlterTableAlterColumnActionSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
alterColumnSyntax Text
colNm Sql92AlterTableAlterColumnActionSyntax SqlSyntaxBuilder
action =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"ALTER COLUMN " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
colNm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql Sql92AlterTableAlterColumnActionSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
action
addColumnSyntax :: Text
-> Sql92AlterTableColumnSchemaSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
addColumnSyntax Text
colNm Sql92AlterTableColumnSchemaSyntax SqlSyntaxBuilder
colSchema =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"ADD COLUMN " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
colNm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql Sql92AlterTableColumnSchemaSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
colSchema
dropColumnSyntax :: Text -> SqlSyntaxBuilder
dropColumnSyntax Text
colNm =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"DROP COLUMN " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
colNm
renameColumnToSyntax :: Text -> Text -> SqlSyntaxBuilder
renameColumnToSyntax Text
oldNm Text
newNm =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"RENAME COLUMN " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
oldNm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
" TO " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
newNm
renameTableToSyntax :: Text -> SqlSyntaxBuilder
renameTableToSyntax Text
newNm =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"RENAME TO " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
newNm
instance IsSql92AlterColumnActionSyntax SqlSyntaxBuilder where
setNotNullSyntax :: SqlSyntaxBuilder
setNotNullSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (ByteString -> Builder
byteString ByteString
"SET NOT NULL")
setNullSyntax :: SqlSyntaxBuilder
setNullSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (ByteString -> Builder
byteString ByteString
"DROP NOT NULL")
instance IsSql92CreateTableSyntax SqlSyntaxBuilder where
type Sql92CreateTableTableNameSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92CreateTableColumnSchemaSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92CreateTableTableConstraintSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92CreateTableOptionsSyntax SqlSyntaxBuilder = SqlSyntaxBuilderCreateTableOptions
createTableSyntax :: Maybe (Sql92CreateTableOptionsSyntax SqlSyntaxBuilder)
-> Sql92CreateTableTableNameSyntax SqlSyntaxBuilder
-> [(Text, Sql92CreateTableColumnSchemaSyntax SqlSyntaxBuilder)]
-> [Sql92CreateTableTableConstraintSyntax SqlSyntaxBuilder]
-> SqlSyntaxBuilder
createTableSyntax Maybe (Sql92CreateTableOptionsSyntax SqlSyntaxBuilder)
tableOptions Sql92CreateTableTableNameSyntax SqlSyntaxBuilder
tblName [(Text, Sql92CreateTableColumnSchemaSyntax SqlSyntaxBuilder)]
fieldSchemas [Sql92CreateTableTableConstraintSyntax SqlSyntaxBuilder]
constraints =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"CREATE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlSyntaxBuilder -> Builder)
-> Maybe SqlSyntaxBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\SqlSyntaxBuilder
b -> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
b Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" ") Maybe SqlSyntaxBuilder
beforeOptions Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
ByteString -> Builder
byteString ByteString
" TABLE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
SqlSyntaxBuilder -> Builder
buildSql Sql92CreateTableTableNameSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
tblName Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
ByteString -> Builder
byteString ByteString
"(" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder -> [Builder] -> Builder
buildSepBy (ByteString -> Builder
byteString ByteString
", ")
(((Text, SqlSyntaxBuilder) -> Builder)
-> [(Text, SqlSyntaxBuilder)] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map (\(Text
nm, SqlSyntaxBuilder
schema) -> Text -> Builder
quoteSql Text
nm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
schema) [(Text, Sql92CreateTableColumnSchemaSyntax SqlSyntaxBuilder)]
[(Text, SqlSyntaxBuilder)]
fieldSchemas [Builder] -> [Builder] -> [Builder]
forall a. Semigroup a => a -> a -> a
<>
(SqlSyntaxBuilder -> Builder) -> [SqlSyntaxBuilder] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map SqlSyntaxBuilder -> Builder
buildSql [Sql92CreateTableTableConstraintSyntax SqlSyntaxBuilder]
[SqlSyntaxBuilder]
constraints) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
ByteString -> Builder
byteString ByteString
")" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlSyntaxBuilder -> Builder)
-> Maybe SqlSyntaxBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\SqlSyntaxBuilder
a -> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
a Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" ") Maybe SqlSyntaxBuilder
afterOptions
where
(Maybe SqlSyntaxBuilder
beforeOptions, Maybe SqlSyntaxBuilder
afterOptions) =
case Maybe (Sql92CreateTableOptionsSyntax SqlSyntaxBuilder)
tableOptions of
Just (SqlSyntaxBuilderCreateTableOptions SqlSyntaxBuilder
b SqlSyntaxBuilder
a) -> (SqlSyntaxBuilder -> Maybe SqlSyntaxBuilder
forall a. a -> Maybe a
Just SqlSyntaxBuilder
b, SqlSyntaxBuilder -> Maybe SqlSyntaxBuilder
forall a. a -> Maybe a
Just SqlSyntaxBuilder
a)
Maybe (Sql92CreateTableOptionsSyntax SqlSyntaxBuilder)
Nothing -> (Maybe SqlSyntaxBuilder
forall a. Maybe a
Nothing, Maybe SqlSyntaxBuilder
forall a. Maybe a
Nothing)
instance IsSql92TableConstraintSyntax SqlSyntaxBuilder where
primaryKeyConstraintSyntax :: [Text] -> SqlSyntaxBuilder
primaryKeyConstraintSyntax [Text]
fs =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
ByteString -> Builder
byteString ByteString
"PRIMARY KEY(" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder -> [Builder] -> Builder
buildSepBy (ByteString -> Builder
byteString ByteString
", ") ((Text -> Builder) -> [Text] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Builder
quoteSql [Text]
fs) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
")"
data ConstraintAttributeTiming = InitiallyDeferred | InitiallyImmediate
deriving (Int -> ConstraintAttributeTiming -> ShowS
[ConstraintAttributeTiming] -> ShowS
ConstraintAttributeTiming -> String
(Int -> ConstraintAttributeTiming -> ShowS)
-> (ConstraintAttributeTiming -> String)
-> ([ConstraintAttributeTiming] -> ShowS)
-> Show ConstraintAttributeTiming
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConstraintAttributeTiming] -> ShowS
$cshowList :: [ConstraintAttributeTiming] -> ShowS
show :: ConstraintAttributeTiming -> String
$cshow :: ConstraintAttributeTiming -> String
showsPrec :: Int -> ConstraintAttributeTiming -> ShowS
$cshowsPrec :: Int -> ConstraintAttributeTiming -> ShowS
Show, ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
(ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool)
-> (ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool)
-> Eq ConstraintAttributeTiming
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
$c/= :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
== :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
$c== :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
Eq, Eq ConstraintAttributeTiming
Eq ConstraintAttributeTiming
-> (ConstraintAttributeTiming
-> ConstraintAttributeTiming -> Ordering)
-> (ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool)
-> (ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool)
-> (ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool)
-> (ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool)
-> (ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming)
-> (ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming)
-> Ord ConstraintAttributeTiming
ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
ConstraintAttributeTiming -> ConstraintAttributeTiming -> Ordering
ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming
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 :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming
$cmin :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming
max :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming
$cmax :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> ConstraintAttributeTiming
>= :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
$c>= :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
> :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
$c> :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
<= :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
$c<= :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
< :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
$c< :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Bool
compare :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Ordering
$ccompare :: ConstraintAttributeTiming -> ConstraintAttributeTiming -> Ordering
Ord, Int -> ConstraintAttributeTiming
ConstraintAttributeTiming -> Int
ConstraintAttributeTiming -> [ConstraintAttributeTiming]
ConstraintAttributeTiming -> ConstraintAttributeTiming
ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming]
ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> [ConstraintAttributeTiming]
(ConstraintAttributeTiming -> ConstraintAttributeTiming)
-> (ConstraintAttributeTiming -> ConstraintAttributeTiming)
-> (Int -> ConstraintAttributeTiming)
-> (ConstraintAttributeTiming -> Int)
-> (ConstraintAttributeTiming -> [ConstraintAttributeTiming])
-> (ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming])
-> (ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming])
-> (ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> [ConstraintAttributeTiming])
-> Enum ConstraintAttributeTiming
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> [ConstraintAttributeTiming]
$cenumFromThenTo :: ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> ConstraintAttributeTiming
-> [ConstraintAttributeTiming]
enumFromTo :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming]
$cenumFromTo :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming]
enumFromThen :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming]
$cenumFromThen :: ConstraintAttributeTiming
-> ConstraintAttributeTiming -> [ConstraintAttributeTiming]
enumFrom :: ConstraintAttributeTiming -> [ConstraintAttributeTiming]
$cenumFrom :: ConstraintAttributeTiming -> [ConstraintAttributeTiming]
fromEnum :: ConstraintAttributeTiming -> Int
$cfromEnum :: ConstraintAttributeTiming -> Int
toEnum :: Int -> ConstraintAttributeTiming
$ctoEnum :: Int -> ConstraintAttributeTiming
pred :: ConstraintAttributeTiming -> ConstraintAttributeTiming
$cpred :: ConstraintAttributeTiming -> ConstraintAttributeTiming
succ :: ConstraintAttributeTiming -> ConstraintAttributeTiming
$csucc :: ConstraintAttributeTiming -> ConstraintAttributeTiming
Enum, ConstraintAttributeTiming
ConstraintAttributeTiming
-> ConstraintAttributeTiming -> Bounded ConstraintAttributeTiming
forall a. a -> a -> Bounded a
maxBound :: ConstraintAttributeTiming
$cmaxBound :: ConstraintAttributeTiming
minBound :: ConstraintAttributeTiming
$cminBound :: ConstraintAttributeTiming
Bounded)
data SqlConstraintAttributesBuilder
= SqlConstraintAttributesBuilder
{ SqlConstraintAttributesBuilder -> Maybe ConstraintAttributeTiming
_sqlConstraintAttributeTiming :: Maybe ConstraintAttributeTiming
, SqlConstraintAttributesBuilder -> Maybe Bool
_sqlConstraintAttributeDeferrable :: Maybe Bool }
deriving (Int -> SqlConstraintAttributesBuilder -> ShowS
[SqlConstraintAttributesBuilder] -> ShowS
SqlConstraintAttributesBuilder -> String
(Int -> SqlConstraintAttributesBuilder -> ShowS)
-> (SqlConstraintAttributesBuilder -> String)
-> ([SqlConstraintAttributesBuilder] -> ShowS)
-> Show SqlConstraintAttributesBuilder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SqlConstraintAttributesBuilder] -> ShowS
$cshowList :: [SqlConstraintAttributesBuilder] -> ShowS
show :: SqlConstraintAttributesBuilder -> String
$cshow :: SqlConstraintAttributesBuilder -> String
showsPrec :: Int -> SqlConstraintAttributesBuilder -> ShowS
$cshowsPrec :: Int -> SqlConstraintAttributesBuilder -> ShowS
Show, SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool
(SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool)
-> (SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool)
-> Eq SqlConstraintAttributesBuilder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool
$c/= :: SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool
== :: SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool
$c== :: SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> Bool
Eq)
instance Semigroup SqlConstraintAttributesBuilder where
<> :: SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> SqlConstraintAttributesBuilder
(<>) = SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> SqlConstraintAttributesBuilder
forall a. Monoid a => a -> a -> a
mappend
instance Monoid SqlConstraintAttributesBuilder where
mempty :: SqlConstraintAttributesBuilder
mempty = Maybe ConstraintAttributeTiming
-> Maybe Bool -> SqlConstraintAttributesBuilder
SqlConstraintAttributesBuilder Maybe ConstraintAttributeTiming
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing
mappend :: SqlConstraintAttributesBuilder
-> SqlConstraintAttributesBuilder -> SqlConstraintAttributesBuilder
mappend SqlConstraintAttributesBuilder
a SqlConstraintAttributesBuilder
b =
Maybe ConstraintAttributeTiming
-> Maybe Bool -> SqlConstraintAttributesBuilder
SqlConstraintAttributesBuilder
(SqlConstraintAttributesBuilder -> Maybe ConstraintAttributeTiming
_sqlConstraintAttributeTiming SqlConstraintAttributesBuilder
b Maybe ConstraintAttributeTiming
-> Maybe ConstraintAttributeTiming
-> Maybe ConstraintAttributeTiming
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SqlConstraintAttributesBuilder -> Maybe ConstraintAttributeTiming
_sqlConstraintAttributeTiming SqlConstraintAttributesBuilder
a)
(SqlConstraintAttributesBuilder -> Maybe Bool
_sqlConstraintAttributeDeferrable SqlConstraintAttributesBuilder
b Maybe Bool -> Maybe Bool -> Maybe Bool
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SqlConstraintAttributesBuilder -> Maybe Bool
_sqlConstraintAttributeDeferrable SqlConstraintAttributesBuilder
a)
fromSqlConstraintAttributes :: SqlConstraintAttributesBuilder -> Builder
fromSqlConstraintAttributes :: SqlConstraintAttributesBuilder -> Builder
fromSqlConstraintAttributes (SqlConstraintAttributesBuilder Maybe ConstraintAttributeTiming
timing Maybe Bool
deferrable) =
Builder
-> (ConstraintAttributeTiming -> Builder)
-> Maybe ConstraintAttributeTiming
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty ConstraintAttributeTiming -> Builder
timingBuilder Maybe ConstraintAttributeTiming
timing Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder -> (Bool -> Builder) -> Maybe Bool -> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty Bool -> Builder
deferrableBuilder Maybe Bool
deferrable
where timingBuilder :: ConstraintAttributeTiming -> Builder
timingBuilder ConstraintAttributeTiming
InitiallyDeferred = ByteString -> Builder
byteString ByteString
"INITIALLY DEFERRED"
timingBuilder ConstraintAttributeTiming
InitiallyImmediate = ByteString -> Builder
byteString ByteString
"INITIALLY IMMEDIATE"
deferrableBuilder :: Bool -> Builder
deferrableBuilder Bool
False = ByteString -> Builder
byteString ByteString
"NOT DEFERRABLE"
deferrableBuilder Bool
True = ByteString -> Builder
byteString ByteString
"DEFERRABLE"
sqlConstraintAttributesSerialized :: SqlConstraintAttributesBuilder -> BeamSerializedConstraintAttributes
sqlConstraintAttributesSerialized :: SqlConstraintAttributesBuilder
-> BeamSerializedConstraintAttributes
sqlConstraintAttributesSerialized (SqlConstraintAttributesBuilder Maybe ConstraintAttributeTiming
timing Maybe Bool
deferrable) =
[BeamSerializedConstraintAttributes]
-> BeamSerializedConstraintAttributes
forall a. Monoid a => [a] -> a
mconcat [ BeamSerializedConstraintAttributes
-> (ConstraintAttributeTiming
-> BeamSerializedConstraintAttributes)
-> Maybe ConstraintAttributeTiming
-> BeamSerializedConstraintAttributes
forall b a. b -> (a -> b) -> Maybe a -> b
maybe BeamSerializedConstraintAttributes
forall a. Monoid a => a
mempty ConstraintAttributeTiming -> BeamSerializedConstraintAttributes
forall {attrs}.
IsSql92ConstraintAttributesSyntax attrs =>
ConstraintAttributeTiming -> attrs
serializeTiming Maybe ConstraintAttributeTiming
timing
, BeamSerializedConstraintAttributes
-> (Bool -> BeamSerializedConstraintAttributes)
-> Maybe Bool
-> BeamSerializedConstraintAttributes
forall b a. b -> (a -> b) -> Maybe a -> b
maybe BeamSerializedConstraintAttributes
forall a. Monoid a => a
mempty Bool -> BeamSerializedConstraintAttributes
forall {attrs}.
IsSql92ConstraintAttributesSyntax attrs =>
Bool -> attrs
serializeDeferrable Maybe Bool
deferrable ]
where
serializeTiming :: ConstraintAttributeTiming -> attrs
serializeTiming ConstraintAttributeTiming
InitiallyDeferred = attrs
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
initiallyDeferredAttributeSyntax
serializeTiming ConstraintAttributeTiming
InitiallyImmediate = attrs
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
initiallyImmediateAttributeSyntax
serializeDeferrable :: Bool -> attrs
serializeDeferrable Bool
True = attrs
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
deferrableAttributeSyntax
serializeDeferrable Bool
False = attrs
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
notDeferrableAttributeSyntax
instance IsSql92ConstraintAttributesSyntax SqlConstraintAttributesBuilder where
initiallyDeferredAttributeSyntax :: SqlConstraintAttributesBuilder
initiallyDeferredAttributeSyntax = Maybe ConstraintAttributeTiming
-> Maybe Bool -> SqlConstraintAttributesBuilder
SqlConstraintAttributesBuilder (ConstraintAttributeTiming -> Maybe ConstraintAttributeTiming
forall a. a -> Maybe a
Just ConstraintAttributeTiming
InitiallyDeferred) Maybe Bool
forall a. Maybe a
Nothing
initiallyImmediateAttributeSyntax :: SqlConstraintAttributesBuilder
initiallyImmediateAttributeSyntax = Maybe ConstraintAttributeTiming
-> Maybe Bool -> SqlConstraintAttributesBuilder
SqlConstraintAttributesBuilder (ConstraintAttributeTiming -> Maybe ConstraintAttributeTiming
forall a. a -> Maybe a
Just ConstraintAttributeTiming
InitiallyImmediate) Maybe Bool
forall a. Maybe a
Nothing
deferrableAttributeSyntax :: SqlConstraintAttributesBuilder
deferrableAttributeSyntax = Maybe ConstraintAttributeTiming
-> Maybe Bool -> SqlConstraintAttributesBuilder
SqlConstraintAttributesBuilder Maybe ConstraintAttributeTiming
forall a. Maybe a
Nothing (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True)
notDeferrableAttributeSyntax :: SqlConstraintAttributesBuilder
notDeferrableAttributeSyntax = Maybe ConstraintAttributeTiming
-> Maybe Bool -> SqlConstraintAttributesBuilder
SqlConstraintAttributesBuilder Maybe ConstraintAttributeTiming
forall a. Maybe a
Nothing (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False)
instance IsSql92ColumnSchemaSyntax SqlSyntaxBuilder where
type Sql92ColumnSchemaColumnConstraintDefinitionSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92ColumnSchemaColumnTypeSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92ColumnSchemaExpressionSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
columnSchemaSyntax :: Sql92ColumnSchemaColumnTypeSyntax SqlSyntaxBuilder
-> Maybe (Sql92ColumnSchemaExpressionSyntax SqlSyntaxBuilder)
-> [Sql92ColumnSchemaColumnConstraintDefinitionSyntax
SqlSyntaxBuilder]
-> Maybe Text
-> SqlSyntaxBuilder
columnSchemaSyntax Sql92ColumnSchemaColumnTypeSyntax SqlSyntaxBuilder
type_ Maybe (Sql92ColumnSchemaExpressionSyntax SqlSyntaxBuilder)
default_ [Sql92ColumnSchemaColumnConstraintDefinitionSyntax
SqlSyntaxBuilder]
constraints Maybe Text
collation =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
SqlSyntaxBuilder -> Builder
buildSql Sql92ColumnSchemaColumnTypeSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
type_ Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlSyntaxBuilder -> Builder)
-> Maybe SqlSyntaxBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\SqlSyntaxBuilder
d -> ByteString -> Builder
byteString ByteString
" DEFAULT " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
d) Maybe (Sql92ColumnSchemaExpressionSyntax SqlSyntaxBuilder)
Maybe SqlSyntaxBuilder
default_ Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
(case [Sql92ColumnSchemaColumnConstraintDefinitionSyntax
SqlSyntaxBuilder]
constraints of
[] -> Builder
forall a. Monoid a => a
mempty
[Sql92ColumnSchemaColumnConstraintDefinitionSyntax
SqlSyntaxBuilder]
_ -> (SqlSyntaxBuilder -> Builder) -> [SqlSyntaxBuilder] -> Builder
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\SqlSyntaxBuilder
c -> ByteString -> Builder
byteString ByteString
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
c) [Sql92ColumnSchemaColumnConstraintDefinitionSyntax
SqlSyntaxBuilder]
[SqlSyntaxBuilder]
constraints) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder -> (Text -> Builder) -> Maybe Text -> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\Text
nm -> ByteString -> Builder
byteString ByteString
" COLLATE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
nm) Maybe Text
collation
instance IsSql92ColumnConstraintDefinitionSyntax SqlSyntaxBuilder where
type Sql92ColumnConstraintDefinitionConstraintSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92ColumnConstraintDefinitionAttributesSyntax SqlSyntaxBuilder = SqlConstraintAttributesBuilder
constraintDefinitionSyntax :: Maybe Text
-> Sql92ColumnConstraintDefinitionConstraintSyntax SqlSyntaxBuilder
-> Maybe
(Sql92ColumnConstraintDefinitionAttributesSyntax SqlSyntaxBuilder)
-> SqlSyntaxBuilder
constraintDefinitionSyntax Maybe Text
nm Sql92ColumnConstraintDefinitionConstraintSyntax SqlSyntaxBuilder
c Maybe
(Sql92ColumnConstraintDefinitionAttributesSyntax SqlSyntaxBuilder)
attrs =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
Builder -> (Text -> Builder) -> Maybe Text -> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\Text
nm' -> ByteString -> Builder
byteString ByteString
"CONSTRAINT " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
nm' Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> ByteString -> Builder
byteString ByteString
" ") Maybe Text
nm Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
SqlSyntaxBuilder -> Builder
buildSql Sql92ColumnConstraintDefinitionConstraintSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
c Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlConstraintAttributesBuilder -> Builder)
-> Maybe SqlConstraintAttributesBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty SqlConstraintAttributesBuilder -> Builder
fromSqlConstraintAttributes Maybe
(Sql92ColumnConstraintDefinitionAttributesSyntax SqlSyntaxBuilder)
Maybe SqlConstraintAttributesBuilder
attrs
instance IsSql92ColumnConstraintSyntax SqlSyntaxBuilder where
type Sql92ColumnConstraintMatchTypeSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
type Sql92ColumnConstraintExpressionSyntax SqlSyntaxBuilder = SqlSyntaxBuilder
notNullConstraintSyntax :: SqlSyntaxBuilder
notNullConstraintSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (ByteString -> Builder
byteString ByteString
"NOT NULL")
uniqueColumnConstraintSyntax :: SqlSyntaxBuilder
uniqueColumnConstraintSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (ByteString -> Builder
byteString ByteString
"UNIQUE")
primaryKeyColumnConstraintSyntax :: SqlSyntaxBuilder
primaryKeyColumnConstraintSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (ByteString -> Builder
byteString ByteString
"PRIMARY KEY")
checkColumnConstraintSyntax :: Sql92ColumnConstraintExpressionSyntax SqlSyntaxBuilder
-> SqlSyntaxBuilder
checkColumnConstraintSyntax Sql92ColumnConstraintExpressionSyntax SqlSyntaxBuilder
e = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder
"CHECK (" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql Sql92ColumnConstraintExpressionSyntax SqlSyntaxBuilder
SqlSyntaxBuilder
e Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")")
referencesConstraintSyntax :: Text
-> [Text]
-> Maybe (Sql92ColumnConstraintMatchTypeSyntax SqlSyntaxBuilder)
-> Maybe
(Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder)
-> Maybe
(Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder)
-> SqlSyntaxBuilder
referencesConstraintSyntax Text
tbl [Text]
fields Maybe (Sql92ColumnConstraintMatchTypeSyntax SqlSyntaxBuilder)
match Maybe
(Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder)
onUpdate Maybe
(Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder)
onDelete =
Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder (Builder -> SqlSyntaxBuilder) -> Builder -> SqlSyntaxBuilder
forall a b. (a -> b) -> a -> b
$
Builder
"REFERENCES " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Text -> Builder
quoteSql Text
tbl Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
"(" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder -> [Builder] -> Builder
buildSepBy Builder
", " ((Text -> Builder) -> [Text] -> [Builder]
forall a b. (a -> b) -> [a] -> [b]
map Text -> Builder
quoteSql [Text]
fields) Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> Builder
")" Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlSyntaxBuilder -> Builder)
-> Maybe SqlSyntaxBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\SqlSyntaxBuilder
m -> Builder
" " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
m) Maybe (Sql92ColumnConstraintMatchTypeSyntax SqlSyntaxBuilder)
Maybe SqlSyntaxBuilder
match Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlSyntaxBuilder -> Builder)
-> Maybe SqlSyntaxBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\SqlSyntaxBuilder
a -> Builder
" ON UPDATE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
a) Maybe
(Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder)
Maybe SqlSyntaxBuilder
onUpdate Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<>
Builder
-> (SqlSyntaxBuilder -> Builder)
-> Maybe SqlSyntaxBuilder
-> Builder
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Builder
forall a. Monoid a => a
mempty (\SqlSyntaxBuilder
a -> Builder
" ON DELETE " Builder -> Builder -> Builder
forall a. Semigroup a => a -> a -> a
<> SqlSyntaxBuilder -> Builder
buildSql SqlSyntaxBuilder
a) Maybe
(Sql92ColumnConstraintReferentialActionSyntax SqlSyntaxBuilder)
Maybe SqlSyntaxBuilder
onDelete
instance IsSql92MatchTypeSyntax SqlSyntaxBuilder where
fullMatchSyntax :: SqlSyntaxBuilder
fullMatchSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder Builder
"FULL"
partialMatchSyntax :: SqlSyntaxBuilder
partialMatchSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder Builder
"PARTIAL"
instance IsSql92ReferentialActionSyntax SqlSyntaxBuilder where
referentialActionCascadeSyntax :: SqlSyntaxBuilder
referentialActionCascadeSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder Builder
"CASCADE"
referentialActionNoActionSyntax :: SqlSyntaxBuilder
referentialActionNoActionSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder Builder
"NO ACTION"
referentialActionSetDefaultSyntax :: SqlSyntaxBuilder
referentialActionSetDefaultSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder Builder
"SET DEFAULT"
referentialActionSetNullSyntax :: SqlSyntaxBuilder
referentialActionSetNullSyntax = Builder -> SqlSyntaxBuilder
SqlSyntaxBuilder Builder
"SET NULL"
instance Sql92DisplaySyntax SqlSyntaxBuilder where
displaySyntax :: SqlSyntaxBuilder -> String
displaySyntax = ByteString -> String
BCL.unpack (ByteString -> String)
-> (SqlSyntaxBuilder -> ByteString) -> SqlSyntaxBuilder -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> ByteString
toLazyByteString (Builder -> ByteString)
-> (SqlSyntaxBuilder -> Builder) -> SqlSyntaxBuilder -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SqlSyntaxBuilder -> Builder
buildSql