{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE CPP #-}

-- | Serialization and deserialization helpers for beam data types.
--
-- Used to read and write machine-readable schema descriptions.

module Database.Beam.Migrate.Serialization
       ( -- * Serialization helpers
         -- $serialization
         BeamSerializedDataType(..)
       , BeamSerializedConstraintDefinition(..)
       , BeamSerializedConstraintAttributes(..)
       , BeamSerializedConstraint(..)
       , BeamSerializedMatchType(..)
       , BeamSerializedReferentialAction(..)
       , BeamSerializedExpression(..)

       , beamSerializeJSON, serializePrecAndDecimal

       -- * Deserialization helpers
       -- $deserialization

       , BeamDeserializers(..)

       , beamDeserialize, beamDeserializeMaybe
       , beamDeserializer, sql92Deserializers
       , sql99DataTypeDeserializers
       , sql2003BinaryAndVarBinaryDataTypeDeserializers
       , sql2008BigIntDataTypeDeserializers
       ) where

import           Database.Beam.Backend.SQL
import           Database.Beam.Migrate.SQL.SQL92
import           Database.Beam.Migrate.SQL.Types

import           Control.Applicative
import           Control.Monad

import           Data.Aeson
#if MIN_VERSION_aeson(2,0,0)
import qualified Data.Aeson.Key as DAK
#endif
import           Data.Aeson.Types (Parser)
import qualified Data.Dependent.Map as D
import qualified Data.GADT.Compare as D
import           Data.Text (Text, unpack)
import           Data.Typeable (Typeable, (:~:)( Refl ), eqT, typeRep, typeOf)
import qualified Data.Vector as V
#if !MIN_VERSION_base(4, 11, 0)
import           Data.Semigroup
#endif

-- * Serialization helpers

-- | An 'IsSql92DataTypeSyntax' for JSON. Supports all superclasses of
-- `IsSql92DataTypeSyntax` declared in @beam-core@.
newtype BeamSerializedDataType
  = BeamSerializedDataType { BeamSerializedDataType -> Value
fromBeamSerializedDataType :: Value }
  deriving (Int -> BeamSerializedDataType -> ShowS
[BeamSerializedDataType] -> ShowS
BeamSerializedDataType -> String
(Int -> BeamSerializedDataType -> ShowS)
-> (BeamSerializedDataType -> String)
-> ([BeamSerializedDataType] -> ShowS)
-> Show BeamSerializedDataType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedDataType] -> ShowS
$cshowList :: [BeamSerializedDataType] -> ShowS
show :: BeamSerializedDataType -> String
$cshow :: BeamSerializedDataType -> String
showsPrec :: Int -> BeamSerializedDataType -> ShowS
$cshowsPrec :: Int -> BeamSerializedDataType -> ShowS
Show, BeamSerializedDataType -> BeamSerializedDataType -> Bool
(BeamSerializedDataType -> BeamSerializedDataType -> Bool)
-> (BeamSerializedDataType -> BeamSerializedDataType -> Bool)
-> Eq BeamSerializedDataType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedDataType -> BeamSerializedDataType -> Bool
$c/= :: BeamSerializedDataType -> BeamSerializedDataType -> Bool
== :: BeamSerializedDataType -> BeamSerializedDataType -> Bool
$c== :: BeamSerializedDataType -> BeamSerializedDataType -> Bool
Eq)

instance IsSql92DataTypeSyntax BeamSerializedDataType where
  domainType :: Text -> BeamSerializedDataType
domainType Text
nm = Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"domain" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
nm])
  charType :: Maybe Word -> Maybe Text -> BeamSerializedDataType
charType Maybe Word
prec Maybe Text
collation =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"char" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec
                                                      , Key
"collation" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
collation ]])
  varCharType :: Maybe Word -> Maybe Text -> BeamSerializedDataType
varCharType Maybe Word
prec Maybe Text
collation =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"varchar" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec
                                                         , Key
"collation" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
collation ]])
  nationalCharType :: Maybe Word -> BeamSerializedDataType
nationalCharType Maybe Word
prec =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"national-char" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec ]])
  nationalVarCharType :: Maybe Word -> BeamSerializedDataType
nationalVarCharType Maybe Word
prec =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"national-varchar" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec ]])

  bitType :: Maybe Word -> BeamSerializedDataType
bitType Maybe Word
prec =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"bit" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec ]])
  varBitType :: Maybe Word -> BeamSerializedDataType
varBitType Maybe Word
prec =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"varbit" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec ]])

  numericType :: Maybe (Word, Maybe Word) -> BeamSerializedDataType
numericType Maybe (Word, Maybe Word)
precAndDecimal =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"numeric" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe (Word, Maybe Word) -> Value
serializePrecAndDecimal Maybe (Word, Maybe Word)
precAndDecimal ])
  decimalType :: Maybe (Word, Maybe Word) -> BeamSerializedDataType
decimalType Maybe (Word, Maybe Word)
precAndDecimal =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"decimal" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe (Word, Maybe Word) -> Value
serializePrecAndDecimal Maybe (Word, Maybe Word)
precAndDecimal ])

  intType :: BeamSerializedDataType
intType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"int"
  smallIntType :: BeamSerializedDataType
smallIntType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"smallint"
  floatType :: Maybe Word -> BeamSerializedDataType
floatType Maybe Word
prec =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"float" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec ] ])
  doubleType :: BeamSerializedDataType
doubleType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"double"
  realType :: BeamSerializedDataType
realType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"real"

  dateType :: BeamSerializedDataType
dateType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"date"
  timeType :: Maybe Word -> Bool -> BeamSerializedDataType
timeType Maybe Word
prec Bool
withTz =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"time" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec
                                                      , Key
"timezone" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
withTz ]])
  timestampType :: Maybe Word -> Bool -> BeamSerializedDataType
timestampType Maybe Word
prec Bool
withTz =
    Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"timestamp" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"prec" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
prec
                                                           , Key
"timezone" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Bool
withTz ]])

instance IsSql99DataTypeSyntax BeamSerializedDataType where
  characterLargeObjectType :: BeamSerializedDataType
characterLargeObjectType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"clob"
  binaryLargeObjectType :: BeamSerializedDataType
binaryLargeObjectType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"blob"
  booleanType :: BeamSerializedDataType
booleanType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"boolean"
  arrayType :: BeamSerializedDataType -> Int -> BeamSerializedDataType
arrayType BeamSerializedDataType
ty Int
count = Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"array" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [ Key
"of" Key -> BeamSerializedDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BeamSerializedDataType
ty
                                                                          , Key
"count" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
count ]])
  rowType :: [(Text, BeamSerializedDataType)] -> BeamSerializedDataType
rowType [(Text, BeamSerializedDataType)]
tys = Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"row" Key -> [(Text, BeamSerializedDataType)] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [(Text, BeamSerializedDataType)]
tys ])

instance IsSql2003BinaryAndVarBinaryDataTypeSyntax BeamSerializedDataType where
  binaryType :: Maybe Word -> BeamSerializedDataType
binaryType Maybe Word
sz = Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"binary" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
sz ])
  varBinaryType :: Maybe Word -> BeamSerializedDataType
varBinaryType Maybe Word
sz = Value -> BeamSerializedDataType
BeamSerializedDataType ([Pair] -> Value
object [ Key
"varbinary" Key -> Maybe Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Word
sz ])

instance IsSql2008BigIntDataTypeSyntax BeamSerializedDataType where
  bigIntType :: BeamSerializedDataType
bigIntType = Value -> BeamSerializedDataType
BeamSerializedDataType Value
"bigint"

instance ToJSON BeamSerializedDataType where
  toJSON :: BeamSerializedDataType -> Value
toJSON = BeamSerializedDataType -> Value
fromBeamSerializedDataType

-- | 'IsSql92ColumnConstraintDefinitionSyntax' type for JSON
newtype BeamSerializedConstraintDefinition
  = BeamSerializedConstraintDefinition
  { BeamSerializedConstraintDefinition -> Value
fromBeamSerializedConstraintDefinition :: Value
  } deriving (Int -> BeamSerializedConstraintDefinition -> ShowS
[BeamSerializedConstraintDefinition] -> ShowS
BeamSerializedConstraintDefinition -> String
(Int -> BeamSerializedConstraintDefinition -> ShowS)
-> (BeamSerializedConstraintDefinition -> String)
-> ([BeamSerializedConstraintDefinition] -> ShowS)
-> Show BeamSerializedConstraintDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedConstraintDefinition] -> ShowS
$cshowList :: [BeamSerializedConstraintDefinition] -> ShowS
show :: BeamSerializedConstraintDefinition -> String
$cshow :: BeamSerializedConstraintDefinition -> String
showsPrec :: Int -> BeamSerializedConstraintDefinition -> ShowS
$cshowsPrec :: Int -> BeamSerializedConstraintDefinition -> ShowS
Show, BeamSerializedConstraintDefinition
-> BeamSerializedConstraintDefinition -> Bool
(BeamSerializedConstraintDefinition
 -> BeamSerializedConstraintDefinition -> Bool)
-> (BeamSerializedConstraintDefinition
    -> BeamSerializedConstraintDefinition -> Bool)
-> Eq BeamSerializedConstraintDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedConstraintDefinition
-> BeamSerializedConstraintDefinition -> Bool
$c/= :: BeamSerializedConstraintDefinition
-> BeamSerializedConstraintDefinition -> Bool
== :: BeamSerializedConstraintDefinition
-> BeamSerializedConstraintDefinition -> Bool
$c== :: BeamSerializedConstraintDefinition
-> BeamSerializedConstraintDefinition -> Bool
Eq)

-- | 'IsSql92ConstraintAttributesSyntax' type for JSON
newtype BeamSerializedConstraintAttributes
  = BeamSerializedConstraintAttributes
  { BeamSerializedConstraintAttributes -> [Value]
fromBeamSerializedConstraintAttributes :: [ Value ]
  } deriving (Int -> BeamSerializedConstraintAttributes -> ShowS
[BeamSerializedConstraintAttributes] -> ShowS
BeamSerializedConstraintAttributes -> String
(Int -> BeamSerializedConstraintAttributes -> ShowS)
-> (BeamSerializedConstraintAttributes -> String)
-> ([BeamSerializedConstraintAttributes] -> ShowS)
-> Show BeamSerializedConstraintAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedConstraintAttributes] -> ShowS
$cshowList :: [BeamSerializedConstraintAttributes] -> ShowS
show :: BeamSerializedConstraintAttributes -> String
$cshow :: BeamSerializedConstraintAttributes -> String
showsPrec :: Int -> BeamSerializedConstraintAttributes -> ShowS
$cshowsPrec :: Int -> BeamSerializedConstraintAttributes -> ShowS
Show, BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes -> Bool
(BeamSerializedConstraintAttributes
 -> BeamSerializedConstraintAttributes -> Bool)
-> (BeamSerializedConstraintAttributes
    -> BeamSerializedConstraintAttributes -> Bool)
-> Eq BeamSerializedConstraintAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes -> Bool
$c/= :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes -> Bool
== :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes -> Bool
$c== :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes -> Bool
Eq, Semigroup BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes
Semigroup BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> (BeamSerializedConstraintAttributes
    -> BeamSerializedConstraintAttributes
    -> BeamSerializedConstraintAttributes)
-> ([BeamSerializedConstraintAttributes]
    -> BeamSerializedConstraintAttributes)
-> Monoid BeamSerializedConstraintAttributes
[BeamSerializedConstraintAttributes]
-> BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [BeamSerializedConstraintAttributes]
-> BeamSerializedConstraintAttributes
$cmconcat :: [BeamSerializedConstraintAttributes]
-> BeamSerializedConstraintAttributes
mappend :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
$cmappend :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
mempty :: BeamSerializedConstraintAttributes
$cmempty :: BeamSerializedConstraintAttributes
Monoid, NonEmpty BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
(BeamSerializedConstraintAttributes
 -> BeamSerializedConstraintAttributes
 -> BeamSerializedConstraintAttributes)
-> (NonEmpty BeamSerializedConstraintAttributes
    -> BeamSerializedConstraintAttributes)
-> (forall b.
    Integral b =>
    b
    -> BeamSerializedConstraintAttributes
    -> BeamSerializedConstraintAttributes)
-> Semigroup BeamSerializedConstraintAttributes
forall b.
Integral b =>
b
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b.
Integral b =>
b
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
$cstimes :: forall b.
Integral b =>
b
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
sconcat :: NonEmpty BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
$csconcat :: NonEmpty BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
<> :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
$c<> :: BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
-> BeamSerializedConstraintAttributes
Semigroup)

-- | 'IsSql92ColumnConstraintSyntax' type for JSON
newtype BeamSerializedConstraint
  = BeamSerializedConstraint
  { BeamSerializedConstraint -> Value
fromBeamSerializedConstraint :: Value
  } deriving (Int -> BeamSerializedConstraint -> ShowS
[BeamSerializedConstraint] -> ShowS
BeamSerializedConstraint -> String
(Int -> BeamSerializedConstraint -> ShowS)
-> (BeamSerializedConstraint -> String)
-> ([BeamSerializedConstraint] -> ShowS)
-> Show BeamSerializedConstraint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedConstraint] -> ShowS
$cshowList :: [BeamSerializedConstraint] -> ShowS
show :: BeamSerializedConstraint -> String
$cshow :: BeamSerializedConstraint -> String
showsPrec :: Int -> BeamSerializedConstraint -> ShowS
$cshowsPrec :: Int -> BeamSerializedConstraint -> ShowS
Show, BeamSerializedConstraint -> BeamSerializedConstraint -> Bool
(BeamSerializedConstraint -> BeamSerializedConstraint -> Bool)
-> (BeamSerializedConstraint -> BeamSerializedConstraint -> Bool)
-> Eq BeamSerializedConstraint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedConstraint -> BeamSerializedConstraint -> Bool
$c/= :: BeamSerializedConstraint -> BeamSerializedConstraint -> Bool
== :: BeamSerializedConstraint -> BeamSerializedConstraint -> Bool
$c== :: BeamSerializedConstraint -> BeamSerializedConstraint -> Bool
Eq)

-- | 'IsSql92MatchTypeSyntax' type for JSON
newtype BeamSerializedMatchType
  = BeamSerializedMatchType
  { BeamSerializedMatchType -> Value
fromBeamSerializedMatchType :: Value
  } deriving (Int -> BeamSerializedMatchType -> ShowS
[BeamSerializedMatchType] -> ShowS
BeamSerializedMatchType -> String
(Int -> BeamSerializedMatchType -> ShowS)
-> (BeamSerializedMatchType -> String)
-> ([BeamSerializedMatchType] -> ShowS)
-> Show BeamSerializedMatchType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedMatchType] -> ShowS
$cshowList :: [BeamSerializedMatchType] -> ShowS
show :: BeamSerializedMatchType -> String
$cshow :: BeamSerializedMatchType -> String
showsPrec :: Int -> BeamSerializedMatchType -> ShowS
$cshowsPrec :: Int -> BeamSerializedMatchType -> ShowS
Show, BeamSerializedMatchType -> BeamSerializedMatchType -> Bool
(BeamSerializedMatchType -> BeamSerializedMatchType -> Bool)
-> (BeamSerializedMatchType -> BeamSerializedMatchType -> Bool)
-> Eq BeamSerializedMatchType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedMatchType -> BeamSerializedMatchType -> Bool
$c/= :: BeamSerializedMatchType -> BeamSerializedMatchType -> Bool
== :: BeamSerializedMatchType -> BeamSerializedMatchType -> Bool
$c== :: BeamSerializedMatchType -> BeamSerializedMatchType -> Bool
Eq)

-- | 'IsSql92ReferentialActionSyntax' type for JSON
newtype BeamSerializedReferentialAction
  = BeamSerializedReferentialAction
  { BeamSerializedReferentialAction -> Value
fromBeamSerializedReferentialAction :: Value
  } deriving (Int -> BeamSerializedReferentialAction -> ShowS
[BeamSerializedReferentialAction] -> ShowS
BeamSerializedReferentialAction -> String
(Int -> BeamSerializedReferentialAction -> ShowS)
-> (BeamSerializedReferentialAction -> String)
-> ([BeamSerializedReferentialAction] -> ShowS)
-> Show BeamSerializedReferentialAction
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedReferentialAction] -> ShowS
$cshowList :: [BeamSerializedReferentialAction] -> ShowS
show :: BeamSerializedReferentialAction -> String
$cshow :: BeamSerializedReferentialAction -> String
showsPrec :: Int -> BeamSerializedReferentialAction -> ShowS
$cshowsPrec :: Int -> BeamSerializedReferentialAction -> ShowS
Show, BeamSerializedReferentialAction
-> BeamSerializedReferentialAction -> Bool
(BeamSerializedReferentialAction
 -> BeamSerializedReferentialAction -> Bool)
-> (BeamSerializedReferentialAction
    -> BeamSerializedReferentialAction -> Bool)
-> Eq BeamSerializedReferentialAction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedReferentialAction
-> BeamSerializedReferentialAction -> Bool
$c/= :: BeamSerializedReferentialAction
-> BeamSerializedReferentialAction -> Bool
== :: BeamSerializedReferentialAction
-> BeamSerializedReferentialAction -> Bool
$c== :: BeamSerializedReferentialAction
-> BeamSerializedReferentialAction -> Bool
Eq)

-- | 'IsSql92ExpressionSyntax' is too complex for us to store in JSON.
-- Additionally, many backends provide substantial amounts of extensions to the
-- syntax that would make storing this highly unfeasible. Expressions are
-- therefore represented as their full text rendering.
--
-- This means that expressions only match as equal if they match /exactly/.
-- While this may seem overly pedantic, it's not much of a concern if your
-- migrations are generated solely by @beam-migrate@. If you've modified the
-- schema yourself, you may have to use 'IsCustomSqlSyntax' to provide an exact
-- expression.
newtype BeamSerializedExpression
  = BeamSerializedExpression
  { BeamSerializedExpression -> Text
fromBeamSerializedExpression :: Text
  } deriving (Int -> BeamSerializedExpression -> ShowS
[BeamSerializedExpression] -> ShowS
BeamSerializedExpression -> String
(Int -> BeamSerializedExpression -> ShowS)
-> (BeamSerializedExpression -> String)
-> ([BeamSerializedExpression] -> ShowS)
-> Show BeamSerializedExpression
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BeamSerializedExpression] -> ShowS
$cshowList :: [BeamSerializedExpression] -> ShowS
show :: BeamSerializedExpression -> String
$cshow :: BeamSerializedExpression -> String
showsPrec :: Int -> BeamSerializedExpression -> ShowS
$cshowsPrec :: Int -> BeamSerializedExpression -> ShowS
Show, BeamSerializedExpression -> BeamSerializedExpression -> Bool
(BeamSerializedExpression -> BeamSerializedExpression -> Bool)
-> (BeamSerializedExpression -> BeamSerializedExpression -> Bool)
-> Eq BeamSerializedExpression
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BeamSerializedExpression -> BeamSerializedExpression -> Bool
$c/= :: BeamSerializedExpression -> BeamSerializedExpression -> Bool
== :: BeamSerializedExpression -> BeamSerializedExpression -> Bool
$c== :: BeamSerializedExpression -> BeamSerializedExpression -> Bool
Eq)

instance IsSql92ColumnConstraintDefinitionSyntax BeamSerializedConstraintDefinition where
  type Sql92ColumnConstraintDefinitionAttributesSyntax BeamSerializedConstraintDefinition =
    BeamSerializedConstraintAttributes
  type Sql92ColumnConstraintDefinitionConstraintSyntax BeamSerializedConstraintDefinition =
    BeamSerializedConstraint

  constraintDefinitionSyntax :: Maybe Text
-> Sql92ColumnConstraintDefinitionConstraintSyntax
     BeamSerializedConstraintDefinition
-> Maybe
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        BeamSerializedConstraintDefinition)
-> BeamSerializedConstraintDefinition
constraintDefinitionSyntax Maybe Text
nm Sql92ColumnConstraintDefinitionConstraintSyntax
  BeamSerializedConstraintDefinition
constraint Maybe
  (Sql92ColumnConstraintDefinitionAttributesSyntax
     BeamSerializedConstraintDefinition)
attrs =
    Value -> BeamSerializedConstraintDefinition
BeamSerializedConstraintDefinition (Value -> BeamSerializedConstraintDefinition)
-> Value -> BeamSerializedConstraintDefinition
forall a b. (a -> b) -> a -> b
$
    [Pair] -> Value
object [ Key
"name" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
nm
           , Key
"attributes" Key -> Maybe [Value] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (BeamSerializedConstraintAttributes -> [Value])
-> Maybe BeamSerializedConstraintAttributes -> Maybe [Value]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BeamSerializedConstraintAttributes -> [Value]
fromBeamSerializedConstraintAttributes Maybe
  (Sql92ColumnConstraintDefinitionAttributesSyntax
     BeamSerializedConstraintDefinition)
Maybe BeamSerializedConstraintAttributes
attrs
           , Key
"constraint" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BeamSerializedConstraint -> Value
fromBeamSerializedConstraint Sql92ColumnConstraintDefinitionConstraintSyntax
  BeamSerializedConstraintDefinition
BeamSerializedConstraint
constraint ]

instance IsSql92ColumnConstraintSyntax BeamSerializedConstraint where
  type Sql92ColumnConstraintMatchTypeSyntax BeamSerializedConstraint =
    BeamSerializedMatchType
  type Sql92ColumnConstraintReferentialActionSyntax BeamSerializedConstraint =
    BeamSerializedReferentialAction
  type Sql92ColumnConstraintExpressionSyntax BeamSerializedConstraint =
    BeamSerializedExpression

  notNullConstraintSyntax :: BeamSerializedConstraint
notNullConstraintSyntax = Value -> BeamSerializedConstraint
BeamSerializedConstraint Value
"not-null"
  uniqueColumnConstraintSyntax :: BeamSerializedConstraint
uniqueColumnConstraintSyntax = Value -> BeamSerializedConstraint
BeamSerializedConstraint Value
"unique"
  primaryKeyColumnConstraintSyntax :: BeamSerializedConstraint
primaryKeyColumnConstraintSyntax = Value -> BeamSerializedConstraint
BeamSerializedConstraint Value
"primary-key"
  checkColumnConstraintSyntax :: Sql92ColumnConstraintExpressionSyntax BeamSerializedConstraint
-> BeamSerializedConstraint
checkColumnConstraintSyntax Sql92ColumnConstraintExpressionSyntax BeamSerializedConstraint
e = Value -> BeamSerializedConstraint
BeamSerializedConstraint ([Pair] -> Value
object [ Key
"check-column" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= BeamSerializedExpression -> Text
fromBeamSerializedExpression Sql92ColumnConstraintExpressionSyntax BeamSerializedConstraint
BeamSerializedExpression
e])
  referencesConstraintSyntax :: Text
-> [Text]
-> Maybe
     (Sql92ColumnConstraintMatchTypeSyntax BeamSerializedConstraint)
-> Maybe
     (Sql92ColumnConstraintReferentialActionSyntax
        BeamSerializedConstraint)
-> Maybe
     (Sql92ColumnConstraintReferentialActionSyntax
        BeamSerializedConstraint)
-> BeamSerializedConstraint
referencesConstraintSyntax Text
tbl [Text]
fields Maybe
  (Sql92ColumnConstraintMatchTypeSyntax BeamSerializedConstraint)
matchType Maybe
  (Sql92ColumnConstraintReferentialActionSyntax
     BeamSerializedConstraint)
onUpdate Maybe
  (Sql92ColumnConstraintReferentialActionSyntax
     BeamSerializedConstraint)
onDelete =
    Value -> BeamSerializedConstraint
BeamSerializedConstraint ([Pair] -> Value
object [ Key
"references" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.=
                                         [Pair] -> Value
object [ Key
"table" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
tbl, Key
"fields" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= [Text]
fields
                                                , Key
"match-type" Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (BeamSerializedMatchType -> Value)
-> Maybe BeamSerializedMatchType -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BeamSerializedMatchType -> Value
fromBeamSerializedMatchType Maybe
  (Sql92ColumnConstraintMatchTypeSyntax BeamSerializedConstraint)
Maybe BeamSerializedMatchType
matchType
                                                , Key
"on-update"  Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (BeamSerializedReferentialAction -> Value)
-> Maybe BeamSerializedReferentialAction -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BeamSerializedReferentialAction -> Value
fromBeamSerializedReferentialAction Maybe
  (Sql92ColumnConstraintReferentialActionSyntax
     BeamSerializedConstraint)
Maybe BeamSerializedReferentialAction
onUpdate
                                                , Key
"on-delete"  Key -> Maybe Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (BeamSerializedReferentialAction -> Value)
-> Maybe BeamSerializedReferentialAction -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap BeamSerializedReferentialAction -> Value
fromBeamSerializedReferentialAction Maybe
  (Sql92ColumnConstraintReferentialActionSyntax
     BeamSerializedConstraint)
Maybe BeamSerializedReferentialAction
onDelete ] ])

instance IsSql92MatchTypeSyntax BeamSerializedMatchType where
  fullMatchSyntax :: BeamSerializedMatchType
fullMatchSyntax = Value -> BeamSerializedMatchType
BeamSerializedMatchType Value
"full"
  partialMatchSyntax :: BeamSerializedMatchType
partialMatchSyntax = Value -> BeamSerializedMatchType
BeamSerializedMatchType Value
"partial"

instance IsSql92ReferentialActionSyntax BeamSerializedReferentialAction where
  referentialActionCascadeSyntax :: BeamSerializedReferentialAction
referentialActionCascadeSyntax = Value -> BeamSerializedReferentialAction
BeamSerializedReferentialAction Value
"cascade"
  referentialActionSetNullSyntax :: BeamSerializedReferentialAction
referentialActionSetNullSyntax = Value -> BeamSerializedReferentialAction
BeamSerializedReferentialAction Value
"set-null"
  referentialActionSetDefaultSyntax :: BeamSerializedReferentialAction
referentialActionSetDefaultSyntax = Value -> BeamSerializedReferentialAction
BeamSerializedReferentialAction Value
"set-default"
  referentialActionNoActionSyntax :: BeamSerializedReferentialAction
referentialActionNoActionSyntax = Value -> BeamSerializedReferentialAction
BeamSerializedReferentialAction Value
"nothing"

instance IsSql92ConstraintAttributesSyntax BeamSerializedConstraintAttributes where
  initiallyDeferredAttributeSyntax :: BeamSerializedConstraintAttributes
initiallyDeferredAttributeSyntax = [Value] -> BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes [ Value
"initially-deferred" ]
  initiallyImmediateAttributeSyntax :: BeamSerializedConstraintAttributes
initiallyImmediateAttributeSyntax = [Value] -> BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes [ Value
"initially-immediate" ]
  notDeferrableAttributeSyntax :: BeamSerializedConstraintAttributes
notDeferrableAttributeSyntax = [Value] -> BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes [ Value
"not-deferrable" ]
  deferrableAttributeSyntax :: BeamSerializedConstraintAttributes
deferrableAttributeSyntax = [Value] -> BeamSerializedConstraintAttributes
BeamSerializedConstraintAttributes [ Value
"deferrable" ]

-- | Some backends serialize data that can only be read by that backend. If so,
-- they should wrap these data in 'beamSerializeJSON', which provides a standard
-- syntax for specifying backend specific data, as well as which backend the
-- data are valid for.
--
-- The first argument is a string that is unique to a given backend
beamSerializeJSON :: Text -> Value -> Value
beamSerializeJSON :: Text -> Value -> Value
beamSerializeJSON Text
backend Value
v =
  [Pair] -> Value
object [ Key
"be-specific" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
backend
         , Key
"be-data" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Value
v ]

-- | Helper for serializing the precision and decimal count parameters to
-- 'decimalType', etc.
serializePrecAndDecimal :: Maybe (Word, Maybe Word) -> Value
serializePrecAndDecimal :: Maybe (Word, Maybe Word) -> Value
serializePrecAndDecimal Maybe (Word, Maybe Word)
Nothing =
  [Pair] -> Value
object []
serializePrecAndDecimal (Just (Word
prec, Maybe Word
Nothing)) =
  [Pair] -> Value
object [ Key
"prec" Key -> Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word
prec ]
serializePrecAndDecimal (Just (Word
prec, Just Word
decimal)) =
  [Pair] -> Value
object [ Key
"prec" Key -> Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word
prec
         , Key
"decimal" Key -> Word -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Word
decimal ]

-- * Deserialization helpers

-- ** Data types

newtype BeamDeserializer syntax
  = BeamDeserializer (forall be. BeamDeserializers be -> Value -> Parser syntax)

-- | Provides a collection of deserializers from aeson 'Value's for arbitrary
-- types. The @cmd@ type parameter is a phantom type parameter. Notionally, all
-- deserializers within this 'BeamDeserializers' relate to the @cmd@ syntax.
newtype BeamDeserializers be
  = BeamDeserializers
  { forall be.
BeamDeserializers be -> DMap BeamDeserializerLabel BeamDeserializer
beamArbitraryDeserializers :: D.DMap BeamDeserializerLabel BeamDeserializer
  }

instance Semigroup (BeamDeserializer be) where
  <> :: BeamDeserializer be -> BeamDeserializer be -> BeamDeserializer be
(<>) = BeamDeserializer be -> BeamDeserializer be -> BeamDeserializer be
forall a. Monoid a => a -> a -> a
mappend

instance Monoid (BeamDeserializer be) where
  mempty :: BeamDeserializer be
mempty = (forall be. BeamDeserializers be -> Value -> Parser be)
-> BeamDeserializer be
forall syntax.
(forall be. BeamDeserializers be -> Value -> Parser syntax)
-> BeamDeserializer syntax
BeamDeserializer ((Value -> Parser be) -> BeamDeserializers be -> Value -> Parser be
forall a b. a -> b -> a
const (Parser be -> Value -> Parser be
forall a b. a -> b -> a
const Parser be
forall (m :: * -> *) a. MonadPlus m => m a
mzero))
  mappend :: BeamDeserializer be -> BeamDeserializer be -> BeamDeserializer be
mappend (BeamDeserializer forall be. BeamDeserializers be -> Value -> Parser be
a) (BeamDeserializer forall be. BeamDeserializers be -> Value -> Parser be
b) =
    (forall be. BeamDeserializers be -> Value -> Parser be)
-> BeamDeserializer be
forall syntax.
(forall be. BeamDeserializers be -> Value -> Parser syntax)
-> BeamDeserializer syntax
BeamDeserializer ((forall be. BeamDeserializers be -> Value -> Parser be)
 -> BeamDeserializer be)
-> (forall be. BeamDeserializers be -> Value -> Parser be)
-> BeamDeserializer be
forall a b. (a -> b) -> a -> b
$ \BeamDeserializers be
d Value
o ->
    BeamDeserializers be -> Value -> Parser be
forall be. BeamDeserializers be -> Value -> Parser be
a BeamDeserializers be
d Value
o Parser be -> Parser be -> Parser be
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> BeamDeserializers be -> Value -> Parser be
forall be. BeamDeserializers be -> Value -> Parser be
b BeamDeserializers be
d Value
o

instance Semigroup (BeamDeserializers be) where
  <> :: BeamDeserializers be
-> BeamDeserializers be -> BeamDeserializers be
(<>) = BeamDeserializers be
-> BeamDeserializers be -> BeamDeserializers be
forall a. Monoid a => a -> a -> a
mappend

instance Monoid (BeamDeserializers be) where
  mempty :: BeamDeserializers be
mempty = DMap BeamDeserializerLabel BeamDeserializer -> BeamDeserializers be
forall be.
DMap BeamDeserializerLabel BeamDeserializer -> BeamDeserializers be
BeamDeserializers DMap BeamDeserializerLabel BeamDeserializer
forall a. Monoid a => a
mempty
  mappend :: BeamDeserializers be
-> BeamDeserializers be -> BeamDeserializers be
mappend (BeamDeserializers DMap BeamDeserializerLabel BeamDeserializer
a) (BeamDeserializers DMap BeamDeserializerLabel BeamDeserializer
b) =
    DMap BeamDeserializerLabel BeamDeserializer -> BeamDeserializers be
forall be.
DMap BeamDeserializerLabel BeamDeserializer -> BeamDeserializers be
BeamDeserializers ((forall v.
 BeamDeserializerLabel v
 -> BeamDeserializer v -> BeamDeserializer v -> BeamDeserializer v)
-> DMap BeamDeserializerLabel BeamDeserializer
-> DMap BeamDeserializerLabel BeamDeserializer
-> DMap BeamDeserializerLabel BeamDeserializer
forall {k1} (k2 :: k1 -> *) (f :: k1 -> *).
GCompare k2 =>
(forall (v :: k1). k2 v -> f v -> f v -> f v)
-> DMap k2 f -> DMap k2 f -> DMap k2 f
D.unionWithKey ((BeamDeserializer v -> BeamDeserializer v -> BeamDeserializer v)
-> BeamDeserializerLabel v
-> BeamDeserializer v
-> BeamDeserializer v
-> BeamDeserializer v
forall a b. a -> b -> a
const BeamDeserializer v -> BeamDeserializer v -> BeamDeserializer v
forall a. Monoid a => a -> a -> a
mappend) DMap BeamDeserializerLabel BeamDeserializer
a DMap BeamDeserializerLabel BeamDeserializer
b)

-- | Helper function to deserialize data from a 'Maybe' 'Value'.
--
-- @
-- beamDeserializeMaybe _ Nothing = pure Nothing
-- beamDeserializeMaybe d (Just v) = Just <$> beamDeserialize d v
-- @
--
beamDeserializeMaybe :: Typeable a
                     => BeamDeserializers be
                     -> Maybe Value
                     -> Parser (Maybe a)
beamDeserializeMaybe :: forall a be.
Typeable a =>
BeamDeserializers be -> Maybe Value -> Parser (Maybe a)
beamDeserializeMaybe BeamDeserializers be
_ Maybe Value
Nothing = Maybe a -> Parser (Maybe a)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe a
forall a. Maybe a
Nothing
beamDeserializeMaybe BeamDeserializers be
d (Just Value
v) =
  a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> Parser a -> Parser (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BeamDeserializers be -> Value -> Parser a
forall a be.
Typeable a =>
BeamDeserializers be -> Value -> Parser a
beamDeserialize BeamDeserializers be
d Value
v

-- | Deserialize the requested type from the given deserializers and aeson 'Value'.
beamDeserialize :: forall a be. Typeable a
                => BeamDeserializers be -> Value
                -> Parser a
beamDeserialize :: forall a be.
Typeable a =>
BeamDeserializers be -> Value -> Parser a
beamDeserialize allD :: BeamDeserializers be
allD@(BeamDeserializers DMap BeamDeserializerLabel BeamDeserializer
d) Value
v =
  case BeamDeserializerLabel a
-> DMap BeamDeserializerLabel BeamDeserializer
-> Maybe (BeamDeserializer a)
forall {k1} (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare k2 =>
k2 v -> DMap k2 f -> Maybe (f v)
D.lookup (BeamDeserializerLabel a
forall ty. Typeable ty => BeamDeserializerLabel ty
BeamDeserializerLabel :: BeamDeserializerLabel a) DMap BeamDeserializerLabel BeamDeserializer
d of
    Maybe (BeamDeserializer a)
Nothing -> String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"beamDeserialize: No deserializer for " String -> ShowS
forall a. [a] -> [a] -> [a]
++ TypeRep -> String
forall a. Show a => a -> String
show (a -> TypeRep
forall a. Typeable a => a -> TypeRep
typeOf (a
forall a. HasCallStack => a
undefined :: a)))
    Just (BeamDeserializer forall be. BeamDeserializers be -> Value -> Parser a
doParse) ->
      BeamDeserializers be -> Value -> Parser a
forall be. BeamDeserializers be -> Value -> Parser a
doParse BeamDeserializers be
allD Value
v

data BeamDeserializerLabel ty where
  BeamDeserializerLabel :: Typeable ty
                        => BeamDeserializerLabel ty
instance D.GEq BeamDeserializerLabel where
  geq :: forall a b.
BeamDeserializerLabel a
-> BeamDeserializerLabel b -> Maybe (a :~: b)
geq BeamDeserializerLabel a
a BeamDeserializerLabel b
b =
    case BeamDeserializerLabel a -> BeamDeserializerLabel b -> GOrdering a b
forall k (f :: k -> *) (a :: k) (b :: k).
GCompare f =>
f a -> f b -> GOrdering a b
D.gcompare BeamDeserializerLabel a
a BeamDeserializerLabel b
b of
      GOrdering a b
D.GEQ -> (a :~: a) -> Maybe (a :~: a)
forall a. a -> Maybe a
Just a :~: a
forall {k} (a :: k). a :~: a
Refl
      GOrdering a b
_ -> Maybe (a :~: b)
forall a. Maybe a
Nothing
instance D.GCompare BeamDeserializerLabel where
  gcompare :: forall a b.
BeamDeserializerLabel a -> BeamDeserializerLabel b -> GOrdering a b
gcompare a :: BeamDeserializerLabel a
a@(BeamDeserializerLabel a
BeamDeserializerLabel :: BeamDeserializerLabel a)
           b :: BeamDeserializerLabel b
b@(BeamDeserializerLabel b
BeamDeserializerLabel :: BeamDeserializerLabel b) =
    case Maybe (a :~: b)
forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT of
      Just (a :~: b
Refl :: a :~: b)-> GOrdering a b
forall {k} (a :: k). GOrdering a a
D.GEQ
      Maybe (a :~: b)
Nothing ->
        case TypeRep -> TypeRep -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (BeamDeserializerLabel a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep BeamDeserializerLabel a
a) (BeamDeserializerLabel b -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep BeamDeserializerLabel b
b) of
          Ordering
LT -> GOrdering a b
forall {k} (a :: k) (b :: k). GOrdering a b
D.GLT
          Ordering
GT -> GOrdering a b
forall {k} (a :: k) (b :: k). GOrdering a b
D.GGT
          Ordering
EQ -> String -> GOrdering a b
forall a. HasCallStack => String -> a
error String
"Impossible"

beamDeserializer :: Typeable ty
                 => (forall be'. BeamDeserializers be' -> Value -> Parser ty)
                 -> BeamDeserializers be
beamDeserializer :: forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'. BeamDeserializers be' -> Value -> Parser ty
parse =
  DMap BeamDeserializerLabel BeamDeserializer -> BeamDeserializers be
forall be.
DMap BeamDeserializerLabel BeamDeserializer -> BeamDeserializers be
BeamDeserializers (BeamDeserializerLabel ty
-> BeamDeserializer ty
-> DMap BeamDeserializerLabel BeamDeserializer
forall {k1} (k2 :: k1 -> *) (v :: k1) (f :: k1 -> *).
k2 v -> f v -> DMap k2 f
D.singleton BeamDeserializerLabel ty
forall ty. Typeable ty => BeamDeserializerLabel ty
BeamDeserializerLabel ((forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializer ty
forall syntax.
(forall be. BeamDeserializers be -> Value -> Parser syntax)
-> BeamDeserializer syntax
BeamDeserializer forall be'. BeamDeserializers be' -> Value -> Parser ty
parse))

-- | Deserializers for SQL92 syntaxes
sql92Deserializers :: forall be
                    . BeamMigrateSqlBackend be
                   => BeamDeserializers be
sql92Deserializers :: forall be. BeamMigrateSqlBackend be => BeamDeserializers be
sql92Deserializers = [BeamDeserializers be] -> BeamDeserializers be
forall a. Monoid a => [a] -> a
mconcat
                   [ (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ExpressionCastTargetSyntax
        (Sql92ExpressionSyntax (BeamSqlBackendSyntax be)))
forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
deserializeSql92DataType
                   , (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
deserializeSql92ConstraintDefinition
                   , (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnConstraintDefinitionConstraintSyntax
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
deserializeSql92Constraint
                   , (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnConstraintMatchTypeSyntax
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintMatchTypeSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
deserializeSql92MatchType
                   , (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnConstraintReferentialActionSyntax
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
deserializeSql92ReferentialAction
                   , (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnConstraintDefinitionAttributesSyntax
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
deserializeSql92Attributes ]
  where
#if MIN_VERSION_aeson(2,0,0)
    makeKey :: Text -> Key
makeKey = Text -> Key
DAK.fromText
#else
    makeKey = id
#endif
    parseSub :: Text -> Object -> Text -> (Object -> Parser b) -> Parser b
parseSub Text
nm Object
o Text
key Object -> Parser b
parse =
      String -> (Object -> Parser b) -> Value -> Parser b
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject (Text -> String
unpack (Text
nm Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"." Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
key)) Object -> Parser b
parse (Value -> Parser b) -> Parser Value -> Parser b
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
o Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Text -> Key
makeKey Text
key

    deserializeSql92DataType :: BeamDeserializers be' -> Value
                             -> Parser (BeamSqlBackendDataTypeSyntax be)
    deserializeSql92DataType :: forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ExpressionCastTargetSyntax
        (Sql92ExpressionSyntax (BeamSqlBackendSyntax be)))
deserializeSql92DataType BeamDeserializers be'
_ Value
o =
      Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
deserializeSql92DataTypeObject Value
o Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall {a} {f :: * -> *} {a}.
(Eq a, IsString a, IsSql92DataTypeSyntax a, MonadPlus f) =>
a -> f a
deserializeSql92DataTypeScalar Value
o

    deserializeSql92DataTypeScalar :: a -> f a
deserializeSql92DataTypeScalar a
"int" = a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall dataType. IsSql92DataTypeSyntax dataType => dataType
intType
    deserializeSql92DataTypeScalar a
"smallint" = a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall dataType. IsSql92DataTypeSyntax dataType => dataType
smallIntType
    deserializeSql92DataTypeScalar a
"double" = a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall dataType. IsSql92DataTypeSyntax dataType => dataType
dateType
    deserializeSql92DataTypeScalar a
"real" = a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall dataType. IsSql92DataTypeSyntax dataType => dataType
realType
    deserializeSql92DataTypeScalar a
"date" = a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall dataType. IsSql92DataTypeSyntax dataType => dataType
dateType
    deserializeSql92DataTypeScalar a
_ = f a
forall (m :: * -> *) a. MonadPlus m => m a
mzero

    deserializeSql92DataTypeObject :: Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
deserializeSql92DataTypeObject =
      String
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Sql92DataType" ((Object
  -> Parser
       (Sql92ColumnSchemaColumnTypeSyntax
          (Sql92CreateTableColumnSchemaSyntax
             (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a b. (a -> b) -> a -> b
$ \Object
o ->
      let ==> :: Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
(==>) = Text
-> Object
-> Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall {b}.
Text -> Object -> Text -> (Object -> Parser b) -> Parser b
parseSub Text
"Sql92DataType" Object
o
      in (Text
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType. IsSql92DataTypeSyntax dataType => Text -> dataType
domainType (Text
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser Text
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"domain") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"char" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Maybe Text
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> Maybe Text -> dataType
charType (Maybe Word
 -> Maybe Text
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Maybe Text
      -> Sql92ColumnSchemaColumnTypeSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec" Parser
  (Maybe Text
   -> Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Text)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"collation") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"varchar" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Maybe Text
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> Maybe Text -> dataType
varCharType (Maybe Word
 -> Maybe Text
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Maybe Text
      -> Sql92ColumnSchemaColumnTypeSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec" Parser
  (Maybe Text
   -> Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Text)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"collation") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"national-char" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> dataType
nationalCharType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"national-varchar" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> dataType
nationalVarCharType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"bit" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> dataType
bitType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"varbit" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> dataType
varBitType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"numeric" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe (Word, Maybe Word)
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe (Word, Maybe Word) -> dataType
numericType (Maybe (Word, Maybe Word)
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe (Word, Maybe Word))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object -> Parser (Maybe (Word, Maybe Word))
forall {a} {a}.
(FromJSON a, FromJSON a) =>
Object -> Parser (Maybe (a, Maybe a))
deserializePrecAndDecimal Object
v) Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"decimal" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe (Word, Maybe Word)
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe (Word, Maybe Word) -> dataType
decimalType (Maybe (Word, Maybe Word)
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe (Word, Maybe Word))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object -> Parser (Maybe (Word, Maybe Word))
forall {a} {a}.
(FromJSON a, FromJSON a) =>
Object -> Parser (Maybe (a, Maybe a))
deserializePrecAndDecimal Object
v) Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"float" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> dataType
floatType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"time" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Bool
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> Bool -> dataType
timeType (Maybe Word
 -> Bool
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Bool
      -> Sql92ColumnSchemaColumnTypeSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec" Parser
  (Bool
   -> Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser Bool
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"timezone") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
         (Text
"timestamp" Text
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
==> \Object
v ->
             Maybe Word
-> Bool
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql92DataTypeSyntax dataType =>
Maybe Word -> Bool -> dataType
timestampType (Maybe Word
 -> Bool
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Bool
      -> Sql92ColumnSchemaColumnTypeSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec" Parser
  (Bool
   -> Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser Bool
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"timezone")

    deserializePrecAndDecimal :: Object -> Parser (Maybe (a, Maybe a))
deserializePrecAndDecimal Object
o =
      (a, Maybe a) -> Maybe (a, Maybe a)
forall a. a -> Maybe a
Just ((a, Maybe a) -> Maybe (a, Maybe a))
-> Parser (a, Maybe a) -> Parser (Maybe (a, Maybe a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (((,) (a -> Maybe a -> (a, Maybe a))
-> Parser a -> Parser (Maybe a -> (a, Maybe a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec" Parser (Maybe a -> (a, Maybe a))
-> Parser (Maybe a) -> Parser (a, Maybe a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> Parser a -> Parser (Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"decimal")) Parser (a, Maybe a) -> Parser (a, Maybe a) -> Parser (a, Maybe a)
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
                ((,Maybe a
forall a. Maybe a
Nothing) (a -> (a, Maybe a)) -> Parser a -> Parser (a, Maybe a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser a
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"prec")) Parser (Maybe (a, Maybe a))
-> Parser (Maybe (a, Maybe a)) -> Parser (Maybe (a, Maybe a))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      Maybe (a, Maybe a) -> Parser (Maybe (a, Maybe a))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (a, Maybe a)
forall a. Maybe a
Nothing

    deserializeSql92ConstraintDefinition :: BeamDeserializers be' -> Value
                                         -> Parser (BeamSqlBackendColumnConstraintDefinitionSyntax be)
    deserializeSql92ConstraintDefinition :: forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
deserializeSql92ConstraintDefinition BeamDeserializers be'
d =
      String
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Value
-> Parser
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Sql92ColumnConstraintDefinition" ((Object
  -> Parser
       (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
          (Sql92CreateTableColumnSchemaSyntax
             (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Value
-> Parser
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a b. (a -> b) -> a -> b
$ \Object
o ->
      Maybe Text
-> Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Maybe
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall constraint.
IsSql92ColumnConstraintDefinitionSyntax constraint =>
Maybe Text
-> Sql92ColumnConstraintDefinitionConstraintSyntax constraint
-> Maybe
     (Sql92ColumnConstraintDefinitionAttributesSyntax constraint)
-> constraint
constraintDefinitionSyntax (Maybe Text
 -> Sql92ColumnConstraintDefinitionConstraintSyntax
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
 -> Maybe
      (Sql92ColumnConstraintDefinitionAttributesSyntax
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> Sql92ColumnSchemaColumnConstraintDefinitionSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Text)
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
      -> Maybe
           (Sql92ColumnConstraintDefinitionAttributesSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
      -> Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
                                 Parser
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
   -> Maybe
        (Sql92ColumnConstraintDefinitionAttributesSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
   -> Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintDefinitionAttributesSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
      -> Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall a be.
Typeable a =>
BeamDeserializers be -> Value -> Parser a
beamDeserialize BeamDeserializers be'
d (Value
 -> Parser
      (Sql92ColumnConstraintDefinitionConstraintSyntax
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Parser Value
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
o Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"constraint")
                                 Parser
  (Maybe
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
   -> Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintDefinitionAttributesSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Parser
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (BeamDeserializers be'
-> Maybe Value
-> Parser
     (Maybe
        (Sql92ColumnConstraintDefinitionAttributesSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall a be.
Typeable a =>
BeamDeserializers be -> Maybe Value -> Parser (Maybe a)
beamDeserializeMaybe BeamDeserializers be'
d (Maybe Value
 -> Parser
      (Maybe
         (Sql92ColumnConstraintDefinitionAttributesSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> Parser (Maybe Value)
-> Parser
     (Maybe
        (Sql92ColumnConstraintDefinitionAttributesSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
o Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"attributes")

    deserializeSql92Constraint :: BeamDeserializers be' -> Value
                               -> Parser (BeamSqlBackendConstraintSyntax be)
    deserializeSql92Constraint :: forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
deserializeSql92Constraint BeamDeserializers be'
d Value
o =
      case Value
o of
        Value
"not-null" -> Sql92ColumnConstraintDefinitionConstraintSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintDefinitionConstraintSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall constraint.
IsSql92ColumnConstraintSyntax constraint =>
constraint
notNullConstraintSyntax
        Value
"unique" -> Sql92ColumnConstraintDefinitionConstraintSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintDefinitionConstraintSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall constraint.
IsSql92ColumnConstraintSyntax constraint =>
constraint
uniqueColumnConstraintSyntax
        Value
_ -> String
-> (Object
    -> Parser
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Sql92ColumnConstraint" Object
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
parseObject Value
o
      where
        parseObject :: Object
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
parseObject Object
v =
          let ==> :: Text
-> (Object
    -> Parser
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
(==>) = Text
-> Object
-> Text
-> (Object
    -> Parser
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall {b}.
Text -> Object -> Text -> (Object -> Parser b) -> Parser b
parseSub Text
"Sql92ColumnConstraint" Object
v
          in Sql92ColumnConstraintExpressionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall constraint.
IsSql92ColumnConstraintSyntax constraint =>
Sql92ColumnConstraintExpressionSyntax constraint -> constraint
checkColumnConstraintSyntax (Sql92ColumnConstraintExpressionSyntax
   (Sql92ColumnConstraintDefinitionConstraintSyntax
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> Sql92ColumnConstraintDefinitionConstraintSyntax
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintExpressionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintExpressionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall a be.
Typeable a =>
BeamDeserializers be -> Value -> Parser a
beamDeserialize BeamDeserializers be'
d (Value
 -> Parser
      (Sql92ColumnConstraintExpressionSyntax
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> Parser Value
-> Parser
     (Sql92ColumnConstraintExpressionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"check-column") Parser
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
             (Text
"references" Text
-> (Object
    -> Parser
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
==> \Object
v' ->
                 Text
-> [Text]
-> Maybe
     (Sql92ColumnConstraintMatchTypeSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Maybe
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Maybe
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall constraint.
IsSql92ColumnConstraintSyntax constraint =>
Text
-> [Text]
-> Maybe (Sql92ColumnConstraintMatchTypeSyntax constraint)
-> Maybe (Sql92ColumnConstraintReferentialActionSyntax constraint)
-> Maybe (Sql92ColumnConstraintReferentialActionSyntax constraint)
-> constraint
referencesConstraintSyntax (Text
 -> [Text]
 -> Maybe
      (Sql92ColumnConstraintMatchTypeSyntax
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
 -> Maybe
      (Sql92ColumnConstraintReferentialActionSyntax
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
 -> Maybe
      (Sql92ColumnConstraintReferentialActionSyntax
         (Sql92ColumnConstraintDefinitionConstraintSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
 -> Sql92ColumnConstraintDefinitionConstraintSyntax
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser Text
-> Parser
     ([Text]
      -> Maybe
           (Sql92ColumnConstraintMatchTypeSyntax
              (Sql92ColumnConstraintDefinitionConstraintSyntax
                 (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                    (Sql92CreateTableColumnSchemaSyntax
                       (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Maybe
           (Sql92ColumnConstraintReferentialActionSyntax
              (Sql92ColumnConstraintDefinitionConstraintSyntax
                 (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                    (Sql92CreateTableColumnSchemaSyntax
                       (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Maybe
           (Sql92ColumnConstraintReferentialActionSyntax
              (Sql92ColumnConstraintDefinitionConstraintSyntax
                 (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                    (Sql92CreateTableColumnSchemaSyntax
                       (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v' Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"table" Parser
  ([Text]
   -> Maybe
        (Sql92ColumnConstraintMatchTypeSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser [Text]
-> Parser
     (Maybe
        (Sql92ColumnConstraintMatchTypeSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Maybe
           (Sql92ColumnConstraintReferentialActionSyntax
              (Sql92ColumnConstraintDefinitionConstraintSyntax
                 (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                    (Sql92CreateTableColumnSchemaSyntax
                       (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Maybe
           (Sql92ColumnConstraintReferentialActionSyntax
              (Sql92ColumnConstraintDefinitionConstraintSyntax
                 (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                    (Sql92CreateTableColumnSchemaSyntax
                       (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v' Object -> Key -> Parser [Text]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"fields"
                                            Parser
  (Maybe
     (Sql92ColumnConstraintMatchTypeSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintMatchTypeSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Maybe
           (Sql92ColumnConstraintReferentialActionSyntax
              (Sql92ColumnConstraintDefinitionConstraintSyntax
                 (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                    (Sql92CreateTableColumnSchemaSyntax
                       (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (BeamDeserializers be'
-> Maybe Value
-> Parser
     (Maybe
        (Sql92ColumnConstraintMatchTypeSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
forall a be.
Typeable a =>
BeamDeserializers be -> Maybe Value -> Parser (Maybe a)
beamDeserializeMaybe BeamDeserializers be'
d (Maybe Value
 -> Parser
      (Maybe
         (Sql92ColumnConstraintMatchTypeSyntax
            (Sql92ColumnConstraintDefinitionConstraintSyntax
               (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                  (Sql92CreateTableColumnSchemaSyntax
                     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))))
-> Parser (Maybe Value)
-> Parser
     (Maybe
        (Sql92ColumnConstraintMatchTypeSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v' Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"match-type")
                                            Parser
  (Maybe
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
      -> Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (BeamDeserializers be'
-> Maybe Value
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
forall a be.
Typeable a =>
BeamDeserializers be -> Maybe Value -> Parser (Maybe a)
beamDeserializeMaybe BeamDeserializers be'
d (Maybe Value
 -> Parser
      (Maybe
         (Sql92ColumnConstraintReferentialActionSyntax
            (Sql92ColumnConstraintDefinitionConstraintSyntax
               (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                  (Sql92CreateTableColumnSchemaSyntax
                     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))))
-> Parser (Maybe Value)
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v' Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"on-update")
                                            Parser
  (Maybe
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
   -> Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
-> Parser
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (BeamDeserializers be'
-> Maybe Value
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
forall a be.
Typeable a =>
BeamDeserializers be -> Maybe Value -> Parser (Maybe a)
beamDeserializeMaybe BeamDeserializers be'
d (Maybe Value
 -> Parser
      (Maybe
         (Sql92ColumnConstraintReferentialActionSyntax
            (Sql92ColumnConstraintDefinitionConstraintSyntax
               (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                  (Sql92CreateTableColumnSchemaSyntax
                     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))))
-> Parser (Maybe Value)
-> Parser
     (Maybe
        (Sql92ColumnConstraintReferentialActionSyntax
           (Sql92ColumnConstraintDefinitionConstraintSyntax
              (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
                 (Sql92CreateTableColumnSchemaSyntax
                    (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))))
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v' Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"on-delete"))

    deserializeSql92MatchType :: BeamDeserializers be' -> Value
                              -> Parser (BeamSqlBackendMatchTypeSyntax be)
    deserializeSql92MatchType :: forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintMatchTypeSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
deserializeSql92MatchType BeamDeserializers be'
_ Value
v =
      case Value
v of
        Value
"full" -> Sql92ColumnConstraintMatchTypeSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintMatchTypeSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintMatchTypeSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall match. IsSql92MatchTypeSyntax match => match
fullMatchSyntax
        Value
"partial" -> Sql92ColumnConstraintMatchTypeSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintMatchTypeSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintMatchTypeSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall match. IsSql92MatchTypeSyntax match => match
partialMatchSyntax
        Value
_ -> Parser
  (Sql92ColumnConstraintMatchTypeSyntax
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (m :: * -> *) a. MonadPlus m => m a
mzero

    deserializeSql92ReferentialAction :: BeamDeserializers be' -> Value
                                      -> Parser (BeamSqlBackendReferentialActionSyntax be)
    deserializeSql92ReferentialAction :: forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
deserializeSql92ReferentialAction BeamDeserializers be'
_ Value
v =
      case Value
v of
        Value
"cascade" -> Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall refAction.
IsSql92ReferentialActionSyntax refAction =>
refAction
referentialActionCascadeSyntax
        Value
"set-null" -> Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall refAction.
IsSql92ReferentialActionSyntax refAction =>
refAction
referentialActionSetNullSyntax
        Value
"set-default" -> Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall refAction.
IsSql92ReferentialActionSyntax refAction =>
refAction
referentialActionSetDefaultSyntax
        Value
"nothing" -> Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnConstraintReferentialActionSyntax
        (Sql92ColumnConstraintDefinitionConstraintSyntax
           (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
              (Sql92CreateTableColumnSchemaSyntax
                 (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnConstraintReferentialActionSyntax
  (Sql92ColumnConstraintDefinitionConstraintSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall refAction.
IsSql92ReferentialActionSyntax refAction =>
refAction
referentialActionNoActionSyntax
        Value
_ -> Parser
  (Sql92ColumnConstraintReferentialActionSyntax
     (Sql92ColumnConstraintDefinitionConstraintSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
forall (m :: * -> *) a. MonadPlus m => m a
mzero

    deserializeSql92Attributes :: BeamDeserializers be' -> Value
                               -> Parser (BeamSqlBackendConstraintAttributesSyntax be)
    deserializeSql92Attributes :: forall be'.
BeamDeserializers be'
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
deserializeSql92Attributes BeamDeserializers be'
_ =
      String
-> (Array
    -> Parser
         (Sql92ColumnConstraintDefinitionAttributesSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall a. String -> (Array -> Parser a) -> Value -> Parser a
withArray String
"Sql92Attributes" ((Array
  -> Parser
       (Sql92ColumnConstraintDefinitionAttributesSyntax
          (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
             (Sql92CreateTableColumnSchemaSyntax
                (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
 -> Value
 -> Parser
      (Sql92ColumnConstraintDefinitionAttributesSyntax
         (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> (Array
    -> Parser
         (Sql92ColumnConstraintDefinitionAttributesSyntax
            (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
               (Sql92CreateTableColumnSchemaSyntax
                  (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))))
-> Value
-> Parser
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall a b. (a -> b) -> a -> b
$ \Array
a ->
      Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnConstraintDefinitionAttributesSyntax
        (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
           (Sql92CreateTableColumnSchemaSyntax
              (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((Value
 -> Sql92ColumnConstraintDefinitionAttributesSyntax
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
 -> Sql92ColumnConstraintDefinitionAttributesSyntax
      (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Array
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\Value
o Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
accum ->
                      case Value
o of
                        Value
"initially-deferred" -> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
initiallyDeferredAttributeSyntax Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. Semigroup a => a -> a -> a
<> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
accum
                        Value
"initially-immediate" -> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
initiallyImmediateAttributeSyntax Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. Semigroup a => a -> a -> a
<> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
accum
                        Value
"not-deferrable" -> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
notDeferrableAttributeSyntax Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. Semigroup a => a -> a -> a
<> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
accum
                        Value
"deferrable" -> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall attrs. IsSql92ConstraintAttributesSyntax attrs => attrs
deferrableAttributeSyntax Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Sql92ColumnConstraintDefinitionAttributesSyntax
     (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. Semigroup a => a -> a -> a
<> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
accum
                        Value
_ -> Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
accum
                  ) Sql92ColumnConstraintDefinitionAttributesSyntax
  (Sql92ColumnSchemaColumnConstraintDefinitionSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. Monoid a => a
mempty Array
a)

-- | Deserializes data types that are instances of 'IsSql99DataTypeSyntax'
sql99DataTypeDeserializers
  :: forall be
   . BeamMigrateSql99Backend be
  => BeamDeserializers be
sql99DataTypeDeserializers :: forall be. BeamMigrateSql99Backend be => BeamDeserializers be
sql99DataTypeDeserializers =
  (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer ((forall be'.
  BeamDeserializers be'
  -> Value
  -> Parser
       (Sql92ColumnSchemaColumnTypeSyntax
          (Sql92CreateTableColumnSchemaSyntax
             (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> BeamDeserializers be)
-> (forall be'.
    BeamDeserializers be'
    -> Value
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall a b. (a -> b) -> a -> b
$ \BeamDeserializers be'
d Value
v ->
  (Sql92ColumnSchemaColumnTypeSyntax
   (Sql92CreateTableColumnSchemaSyntax
      (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. a -> a
id @(BeamSqlBackendDataTypeSyntax be)) (Parser
   (Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a b. (a -> b) -> a -> b
$
  case Value
v of
    Value
"clob" -> Sql92ColumnSchemaColumnTypeSyntax
  (Sql92CreateTableColumnSchemaSyntax
     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnSchemaColumnTypeSyntax
  (Sql92CreateTableColumnSchemaSyntax
     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType. IsSql99DataTypeSyntax dataType => dataType
characterLargeObjectType
    Value
"blob" -> Sql92ColumnSchemaColumnTypeSyntax
  (Sql92CreateTableColumnSchemaSyntax
     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnSchemaColumnTypeSyntax
  (Sql92CreateTableColumnSchemaSyntax
     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType. IsSql99DataTypeSyntax dataType => dataType
binaryLargeObjectType
    Value
_ -> String
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Sql99DataType" (BeamDeserializers be'
-> Object
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall {a} {be}.
(IsSql99DataTypeSyntax a, Typeable a) =>
BeamDeserializers be -> Object -> Parser a
parseObject BeamDeserializers be'
d) Value
v
  where
    parseObject :: BeamDeserializers be -> Object -> Parser a
parseObject BeamDeserializers be
d Object
v =
      a -> Int -> a
forall dataType.
IsSql99DataTypeSyntax dataType =>
dataType -> Int -> dataType
arrayType (a -> Int -> a) -> Parser a -> Parser (Int -> a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (BeamDeserializers be -> Value -> Parser a
forall a be.
Typeable a =>
BeamDeserializers be -> Value -> Parser a
beamDeserialize BeamDeserializers be
d (Value -> Parser a) -> Parser Value -> Parser a
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Object
v Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"of") Parser (Int -> a) -> Parser Int -> Parser a
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"count" Parser a -> Parser a -> Parser a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
      [(Text, a)] -> a
forall dataType.
IsSql99DataTypeSyntax dataType =>
[(Text, dataType)] -> dataType
rowType ([(Text, a)] -> a) -> Parser [(Text, a)] -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (do Value
rowTypes <- Object
v Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"row"
                      let parseArray :: Array -> Parser [(Text, a)]
parseArray Array
a =
                            [Value] -> (Value -> Parser (Text, a)) -> Parser [(Text, a)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM (Array -> [Value]
forall a. Vector a -> [a]
V.toList Array
a) ((Value -> Parser (Text, a)) -> Parser [(Text, a)])
-> (Value -> Parser (Text, a)) -> Parser [(Text, a)]
forall a b. (a -> b) -> a -> b
$ \Value
a' -> do
                            (Text
nm, Value
a'') <- Value -> Parser (Text, Value)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
a'
                            (Text
nm,) (a -> (Text, a)) -> Parser a -> Parser (Text, a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> BeamDeserializers be -> Value -> Parser a
forall a be.
Typeable a =>
BeamDeserializers be -> Value -> Parser a
beamDeserialize BeamDeserializers be
d Value
a''
                      String
-> (Array -> Parser [(Text, a)]) -> Value -> Parser [(Text, a)]
forall a. String -> (Array -> Parser a) -> Value -> Parser a
withArray String
"Sql99DataType.rowType" Array -> Parser [(Text, a)]
parseArray Value
rowTypes)

-- | Deserialize data types that are instances of 'IsSql2003BinaryAndVarBinaryDataTypeSyntax'
sql2003BinaryAndVarBinaryDataTypeDeserializers
  :: forall be
   . ( BeamMigrateSqlBackend be, BeamSqlT021Backend be )
  => BeamDeserializers be
sql2003BinaryAndVarBinaryDataTypeDeserializers :: forall be.
(BeamMigrateSqlBackend be, BeamSqlT021Backend be) =>
BeamDeserializers be
sql2003BinaryAndVarBinaryDataTypeDeserializers =
  (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer ((forall be'.
  BeamDeserializers be'
  -> Value
  -> Parser
       (Sql92ColumnSchemaColumnTypeSyntax
          (Sql92CreateTableColumnSchemaSyntax
             (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> BeamDeserializers be)
-> (forall be'.
    BeamDeserializers be'
    -> Value
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall a b. (a -> b) -> a -> b
$ \BeamDeserializers be'
_ Value
v ->
  (Sql92ColumnSchemaColumnTypeSyntax
   (Sql92CreateTableColumnSchemaSyntax
      (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. a -> a
id @(BeamSqlBackendDataTypeSyntax be)) (Parser
   (Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a b. (a -> b) -> a -> b
$
  String
-> (Object
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Value
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Sql2003DataType"
    (\Object
o -> (Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql2003BinaryAndVarBinaryDataTypeSyntax dataType =>
Maybe Word -> dataType
binaryType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"binary") Parser
  (Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
           (Maybe Word
-> Sql92ColumnSchemaColumnTypeSyntax
     (Sql92CreateTableColumnSchemaSyntax
        (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType.
IsSql2003BinaryAndVarBinaryDataTypeSyntax dataType =>
Maybe Word -> dataType
varBinaryType (Maybe Word
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser (Maybe Word)
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Maybe Word)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"varbinary"))
    Value
v

-- | Deserialize data types that are instance of 'IsSql2008BigIntDataTypeSyntax'
sql2008BigIntDataTypeDeserializers
  :: forall be
   . ( BeamMigrateSqlBackend be, BeamSqlT071Backend be )
  => BeamDeserializers be
sql2008BigIntDataTypeDeserializers :: forall be.
(BeamMigrateSqlBackend be, BeamSqlT071Backend be) =>
BeamDeserializers be
sql2008BigIntDataTypeDeserializers =
  (forall be'.
 BeamDeserializers be'
 -> Value
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall ty be.
Typeable ty =>
(forall be'. BeamDeserializers be' -> Value -> Parser ty)
-> BeamDeserializers be
beamDeserializer ((forall be'.
  BeamDeserializers be'
  -> Value
  -> Parser
       (Sql92ColumnSchemaColumnTypeSyntax
          (Sql92CreateTableColumnSchemaSyntax
             (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
 -> BeamDeserializers be)
-> (forall be'.
    BeamDeserializers be'
    -> Value
    -> Parser
         (Sql92ColumnSchemaColumnTypeSyntax
            (Sql92CreateTableColumnSchemaSyntax
               (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> BeamDeserializers be
forall a b. (a -> b) -> a -> b
$ \BeamDeserializers be'
_ Value
v ->
  (Sql92ColumnSchemaColumnTypeSyntax
   (Sql92CreateTableColumnSchemaSyntax
      (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
 -> Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (forall a. a -> a
id @(BeamSqlBackendDataTypeSyntax be)) (Parser
   (Sql92ColumnSchemaColumnTypeSyntax
      (Sql92CreateTableColumnSchemaSyntax
         (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
 -> Parser
      (Sql92ColumnSchemaColumnTypeSyntax
         (Sql92CreateTableColumnSchemaSyntax
            (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall a b. (a -> b) -> a -> b
$
  case Value
v of
    Value
"bigint" -> Sql92ColumnSchemaColumnTypeSyntax
  (Sql92CreateTableColumnSchemaSyntax
     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Sql92ColumnSchemaColumnTypeSyntax
  (Sql92CreateTableColumnSchemaSyntax
     (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be)))
forall dataType. IsSql2008BigIntDataTypeSyntax dataType => dataType
bigIntType
    Value
_ -> String
-> Parser
     (Sql92ColumnSchemaColumnTypeSyntax
        (Sql92CreateTableColumnSchemaSyntax
           (Sql92DdlCommandCreateTableSyntax (BeamSqlBackendSyntax be))))
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Sql2008DataType.bigint: expected 'bigint'"

-- $serialization
--   Below we provide various instances of Beam SQL syntax types that produce an
--   aeson 'Value' that reflects the call tree. This allows us to read back
--   these data types in various syntaxes.
--
--   Because these are formatted as standard beam syntaxes, backends can easily
--   serialize their data to disk. For an example of what we mean by this, see
--   the instance of 'IsSql92DataTypeSyntax' for 'SqliteDataTypeSyntax' in
--   @beam-sqlite@.


-- $deserialization
--
--   Deserialization requires that knowledge of every type of data we can
--   deserialize is stored in one place. While this is not much of an issue when
--   compiling full Haskell applications, due to the type class mechanism,
--   beam-migrate tools load backends dynamically. This means that we need a
--   separate way to discover deserialization instances for types we care about.
--
--   Values of the 'BeamDeserializers' type represent a set of deserializers all
--   related to one kind of command syntax. You can ask for the deserializers to
--   deserialize any type from an aeson 'Value'. The deserialization will
--   succeed only if a deserializer for the requested type exists and the
--   deserializer was able to parse the 'Value'.
--
--   'BeamDeserializers' compose monoidally. Thus, you can extend any
--   'BeamDeserializers' with your own custom deserializers, by 'mappend'ing it
--   with a new 'BeamDeserializers', created by calling 'beamDeserializer'.