{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE TemplateHaskellQuotes #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Hasura.Backends.MySQL.Instances.Schema () where

import Data.ByteString (ByteString)
import Data.Has
import Data.HashMap.Strict qualified as HM
import Data.List.NonEmpty qualified as NE
import Data.Text.Encoding (encodeUtf8)
import Data.Text.Extended
import Database.MySQL.Base.Types qualified as MySQL
import Hasura.Backends.MySQL.Types qualified as MySQL
import Hasura.Base.Error
import Hasura.Base.ErrorMessage (toErrorMessage)
import Hasura.GraphQL.Schema.Backend
import Hasura.GraphQL.Schema.Build qualified as GSB
import Hasura.GraphQL.Schema.Common
import Hasura.GraphQL.Schema.NamingCase
import Hasura.GraphQL.Schema.Parser
  ( InputFieldsParser,
    Kind (..),
    MonadMemoize,
    MonadParse,
    Parser,
  )
import Hasura.GraphQL.Schema.Parser qualified as P
import Hasura.GraphQL.Schema.Select
import Hasura.GraphQL.Schema.Typename (MkTypename)
import Hasura.Name qualified as Name
import Hasura.Prelude
import Hasura.RQL.IR
import Hasura.RQL.IR.Select qualified as IR
import Hasura.RQL.Types.Backend as RQL
import Hasura.RQL.Types.Column as RQL
import Hasura.RQL.Types.SchemaCache as RQL
import Hasura.RQL.Types.Source as RQL
import Hasura.SQL.Backend
import Language.GraphQL.Draft.Syntax qualified as GQL

instance BackendSchema 'MySQL where
  buildTableQueryAndSubscriptionFields :: MkRootFieldName
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m ([FieldParser
         n
         (QueryDB
            'MySQL
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'MySQL))],
      [FieldParser
         n
         (QueryDB
            'MySQL
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'MySQL))],
      Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n)))
buildTableQueryAndSubscriptionFields = MkRootFieldName
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m ([FieldParser
         n
         (QueryDB
            'MySQL
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'MySQL))],
      [FieldParser
         n
         (QueryDB
            'MySQL
            (RemoteRelationshipField UnpreparedValue)
            (UnpreparedValue 'MySQL))],
      Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, AggregationPredicatesSchema b,
 BackendTableSelectSchema b) =>
MkRootFieldName
-> SourceInfo b
-> TableName b
-> TableInfo b
-> GQLNameIdentifier
-> m ([FieldParser
         n
         (QueryDB
            b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))],
      [FieldParser
         n
         (QueryDB
            b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))],
      Maybe (Name, Parser 'Output n (ApolloFederationParserFunction n)))
GSB.buildTableQueryAndSubscriptionFields
  buildTableRelayQueryFields :: MkRootFieldName
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> NESeq (ColumnInfo 'MySQL)
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildTableRelayQueryFields MkRootFieldName
_ SourceInfo 'MySQL
_ TableName 'MySQL
_ TableInfo 'MySQL
_ GQLNameIdentifier
_ NESeq (ColumnInfo 'MySQL)
_ = [FieldParser
   n
   (QueryDB
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildTableStreamingSubscriptionFields :: MkRootFieldName
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildTableStreamingSubscriptionFields = MkRootFieldName
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, AggregationPredicatesSchema b,
 BackendTableSelectSchema b) =>
MkRootFieldName
-> SourceInfo b
-> TableName b
-> TableInfo b
-> GQLNameIdentifier
-> m [FieldParser
        n
        (QueryDB
           b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b))]
GSB.buildTableStreamingSubscriptionFields
  buildTableInsertMutationFields :: MkRootFieldName
-> Scenario
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m [FieldParser
        n
        (AnnotatedInsert
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildTableInsertMutationFields MkRootFieldName
_ Scenario
_ SourceInfo 'MySQL
_ TableName 'MySQL
_ TableInfo 'MySQL
_ GQLNameIdentifier
_ = [FieldParser
   n
   (AnnotatedInsert
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (AnnotatedInsert
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildTableUpdateMutationFields :: MkRootFieldName
-> Scenario
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m [FieldParser
        n
        (AnnotatedUpdateG
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildTableUpdateMutationFields MkRootFieldName
_ Scenario
_ SourceInfo 'MySQL
_ TableName 'MySQL
_ TableInfo 'MySQL
_ GQLNameIdentifier
_ = [FieldParser
   n
   (AnnotatedUpdateG
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (AnnotatedUpdateG
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildTableDeleteMutationFields :: MkRootFieldName
-> Scenario
-> SourceInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> GQLNameIdentifier
-> m [FieldParser
        n
        (AnnDelG
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildTableDeleteMutationFields MkRootFieldName
_ Scenario
_ SourceInfo 'MySQL
_ TableName 'MySQL
_ TableInfo 'MySQL
_ GQLNameIdentifier
_ = [FieldParser
   n
   (AnnDelG
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (AnnDelG
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildFunctionQueryFields :: MkRootFieldName
-> SourceInfo 'MySQL
-> FunctionName 'MySQL
-> FunctionInfo 'MySQL
-> TableName 'MySQL
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildFunctionQueryFields MkRootFieldName
_ SourceInfo 'MySQL
_ FunctionName 'MySQL
_ FunctionInfo 'MySQL
_ TableName 'MySQL
_ = [FieldParser
   n
   (QueryDB
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildFunctionRelayQueryFields :: MkRootFieldName
-> SourceInfo 'MySQL
-> FunctionName 'MySQL
-> FunctionInfo 'MySQL
-> TableName 'MySQL
-> NESeq (ColumnInfo 'MySQL)
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildFunctionRelayQueryFields MkRootFieldName
_ SourceInfo 'MySQL
_ FunctionName 'MySQL
_ FunctionInfo 'MySQL
_ TableName 'MySQL
_ NESeq (ColumnInfo 'MySQL)
_ = [FieldParser
   n
   (QueryDB
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (QueryDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  buildFunctionMutationFields :: MkRootFieldName
-> SourceInfo 'MySQL
-> FunctionName 'MySQL
-> FunctionInfo 'MySQL
-> TableName 'MySQL
-> m [FieldParser
        n
        (MutationDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
buildFunctionMutationFields MkRootFieldName
_ SourceInfo 'MySQL
_ FunctionName 'MySQL
_ FunctionInfo 'MySQL
_ TableName 'MySQL
_ = [FieldParser
   n
   (MutationDB
      'MySQL
      (RemoteRelationshipField UnpreparedValue)
      (UnpreparedValue 'MySQL))]
-> m [FieldParser
        n
        (MutationDB
           'MySQL
           (RemoteRelationshipField UnpreparedValue)
           (UnpreparedValue 'MySQL))]
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
  relayExtension :: Maybe (XRelay 'MySQL)
relayExtension = Maybe (XRelay 'MySQL)
forall a. Maybe a
Nothing
  nodesAggExtension :: Maybe (XNodesAgg 'MySQL)
nodesAggExtension = () -> Maybe ()
forall a. a -> Maybe a
Just ()
  streamSubscriptionExtension :: Maybe (XStreamingSubscription 'MySQL)
streamSubscriptionExtension = Maybe (XStreamingSubscription 'MySQL)
forall a. Maybe a
Nothing
  columnParser :: ColumnType 'MySQL
-> Nullability
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
columnParser = ColumnType 'MySQL
-> Nullability
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
forall (n :: * -> *) (m :: * -> *) r.
(MonadParse n, MonadError QErr m, MonadReader r m,
 Has MkTypename r, Has NamingCase r) =>
ColumnType 'MySQL
-> Nullability
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
columnParser'
  scalarSelectionArgumentsParser :: ColumnType 'MySQL
-> InputFieldsParser n (Maybe (ScalarSelectionArguments 'MySQL))
scalarSelectionArgumentsParser ColumnType 'MySQL
_ = Maybe Void -> InputFieldsParser MetadataObjId n (Maybe Void)
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Void
forall a. Maybe a
Nothing
  orderByOperators :: SourceInfo 'MySQL
-> NamingCase
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'MySQL, NullsOrderType 'MySQL)))
orderByOperators SourceInfo 'MySQL
_sourceInfo = NamingCase
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'MySQL, NullsOrderType 'MySQL)))
orderByOperators'
  comparisonExps :: ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL])
comparisonExps = ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL])
forall (m :: * -> *) (n :: * -> *) r.
(BackendSchema 'MySQL, MonadMemoize m, MonadParse n,
 MonadError QErr m, MonadReader r m, Has MkTypename r,
 Has NamingCase r) =>
ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL])
comparisonExps'
  countTypeInput :: Maybe (Parser 'Both n (Column 'MySQL))
-> InputFieldsParser n (CountDistinct -> CountType 'MySQL)
countTypeInput = Maybe (Parser 'Both n (Column 'MySQL))
-> InputFieldsParser n (CountDistinct -> CountType 'MySQL)
forall (n :: * -> *).
MonadParse n =>
Maybe (Parser 'Both n (Column 'MySQL))
-> InputFieldsParser n (CountDistinct -> CountType 'MySQL)
mysqlCountTypeInput
  aggregateOrderByCountType :: ScalarType 'MySQL
aggregateOrderByCountType = [Char] -> Type
forall a. HasCallStack => [Char] -> a
error [Char]
"aggregateOrderByCountType: MySQL backend does not support this operation yet."
  computedField :: SourceInfo 'MySQL
-> ComputedFieldInfo 'MySQL
-> TableName 'MySQL
-> TableInfo 'MySQL
-> m (Maybe (FieldParser n (AnnotatedField 'MySQL)))
computedField = [Char]
-> SourceInfo 'MySQL
-> ComputedFieldInfo 'MySQL
-> TableName
-> TableInfo 'MySQL
-> m (Maybe (FieldParser n (AnnotatedField 'MySQL)))
forall a. HasCallStack => [Char] -> a
error [Char]
"computedField: MySQL backend does not support this operation yet."

instance BackendTableSelectSchema 'MySQL where
  tableArguments :: SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (InputFieldsParser
        n (SelectArgsG 'MySQL (UnpreparedValue 'MySQL)))
tableArguments = SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (InputFieldsParser
        n (SelectArgsG 'MySQL (UnpreparedValue 'MySQL)))
forall r (m :: * -> *) (n :: * -> *).
MonadBuildSchema 'MySQL r m n =>
SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (InputFieldsParser
        n (SelectArgsG 'MySQL (UnpreparedValue 'MySQL)))
mysqlTableArgs
  selectTable :: SourceInfo 'MySQL
-> TableInfo 'MySQL
-> Name
-> Maybe Description
-> m (Maybe (FieldParser n (SelectExp 'MySQL)))
selectTable = SourceInfo 'MySQL
-> TableInfo 'MySQL
-> Name
-> Maybe Description
-> m (Maybe (FieldParser n (SelectExp 'MySQL)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendTableSelectSchema b) =>
SourceInfo b
-> TableInfo b
-> Name
-> Maybe Description
-> m (Maybe (FieldParser n (SelectExp b)))
defaultSelectTable
  selectTableAggregate :: SourceInfo 'MySQL
-> TableInfo 'MySQL
-> Name
-> Maybe Description
-> m (Maybe (FieldParser n (AggSelectExp 'MySQL)))
selectTableAggregate = SourceInfo 'MySQL
-> TableInfo 'MySQL
-> Name
-> Maybe Description
-> m (Maybe (FieldParser n (AggSelectExp 'MySQL)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(MonadBuildSchema b r m n, BackendTableSelectSchema b) =>
SourceInfo b
-> TableInfo b
-> Name
-> Maybe Description
-> m (Maybe (FieldParser n (AggSelectExp b)))
defaultSelectTableAggregate
  tableSelectionSet :: SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (Maybe (Parser 'Output n (AnnotatedFields 'MySQL)))
tableSelectionSet = SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (Maybe (Parser 'Output n (AnnotatedFields 'MySQL)))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(AggregationPredicatesSchema b, BackendTableSelectSchema b,
 Eq (AnnBoolExp b (UnpreparedValue b)), MonadBuildSchema b r m n) =>
SourceInfo b
-> TableInfo b -> m (Maybe (Parser 'Output n (AnnotatedFields b)))
defaultTableSelectionSet

mysqlTableArgs ::
  forall r m n.
  MonadBuildSchema 'MySQL r m n =>
  RQL.SourceInfo 'MySQL ->
  TableInfo 'MySQL ->
  m (InputFieldsParser n (IR.SelectArgsG 'MySQL (UnpreparedValue 'MySQL)))
mysqlTableArgs :: SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (InputFieldsParser
        n (SelectArgsG 'MySQL (UnpreparedValue 'MySQL)))
mysqlTableArgs SourceInfo 'MySQL
sourceInfo TableInfo 'MySQL
tableInfo = do
  InputFieldsParser
  n (Maybe (AnnBoolExp 'MySQL (UnpreparedValue 'MySQL)))
whereParser <- SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (InputFieldsParser
        n (Maybe (AnnBoolExp 'MySQL (UnpreparedValue 'MySQL))))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
(AggregationPredicatesSchema b, MonadBuildSchema b r m n) =>
SourceInfo b
-> TableInfo b
-> m (InputFieldsParser
        n (Maybe (AnnBoolExp b (UnpreparedValue b))))
tableWhereArg SourceInfo 'MySQL
sourceInfo TableInfo 'MySQL
tableInfo
  InputFieldsParser
  n
  (Maybe
     (NonEmpty (AnnotatedOrderByItemG 'MySQL (UnpreparedValue 'MySQL))))
orderByParser <- SourceInfo 'MySQL
-> TableInfo 'MySQL
-> m (InputFieldsParser
        n
        (Maybe
           (NonEmpty
              (AnnotatedOrderByItemG 'MySQL (UnpreparedValue 'MySQL)))))
forall (b :: BackendType) r (m :: * -> *) (n :: * -> *).
MonadBuildSchema b r m n =>
SourceInfo b
-> TableInfo b
-> m (InputFieldsParser
        n (Maybe (NonEmpty (AnnotatedOrderByItemG b (UnpreparedValue b)))))
tableOrderByArg SourceInfo 'MySQL
sourceInfo TableInfo 'MySQL
tableInfo
  pure do
    Maybe (AnnBoolExp 'MySQL (UnpreparedValue 'MySQL))
whereArg <- InputFieldsParser
  n (Maybe (AnnBoolExp 'MySQL (UnpreparedValue 'MySQL)))
whereParser
    Maybe
  (NonEmpty (AnnotatedOrderByItemG 'MySQL (UnpreparedValue 'MySQL)))
orderByArg <- InputFieldsParser
  n
  (Maybe
     (NonEmpty (AnnotatedOrderByItemG 'MySQL (UnpreparedValue 'MySQL))))
orderByParser
    Maybe Int
limitArg <- InputFieldsParser n (Maybe Int)
forall (n :: * -> *).
MonadParse n =>
InputFieldsParser n (Maybe Int)
tableLimitArg
    Maybe Int64
offsetArg <- InputFieldsParser n (Maybe Int64)
forall (n :: * -> *).
MonadParse n =>
InputFieldsParser n (Maybe Int64)
tableOffsetArg
    pure $
      SelectArgs :: forall (b :: BackendType) v.
Maybe (AnnBoolExp b v)
-> Maybe (NonEmpty (AnnotatedOrderByItemG b v))
-> Maybe Int
-> Maybe Int64
-> Maybe (NonEmpty (Column b))
-> SelectArgsG b v
IR.SelectArgs
        { $sel:_saWhere:SelectArgs :: Maybe (AnnBoolExp 'MySQL (UnpreparedValue 'MySQL))
IR._saWhere = Maybe (AnnBoolExp 'MySQL (UnpreparedValue 'MySQL))
whereArg,
          $sel:_saOrderBy:SelectArgs :: Maybe
  (NonEmpty (AnnotatedOrderByItemG 'MySQL (UnpreparedValue 'MySQL)))
IR._saOrderBy = Maybe
  (NonEmpty (AnnotatedOrderByItemG 'MySQL (UnpreparedValue 'MySQL)))
orderByArg,
          $sel:_saLimit:SelectArgs :: Maybe Int
IR._saLimit = Maybe Int
limitArg,
          $sel:_saOffset:SelectArgs :: Maybe Int64
IR._saOffset = Maybe Int64
offsetArg,
          $sel:_saDistinct:SelectArgs :: Maybe (NonEmpty (Column 'MySQL))
IR._saDistinct = Maybe (NonEmpty (Column 'MySQL))
forall a. Maybe a
Nothing
        }

bsParser :: MonadParse m => Parser 'Both m ByteString
bsParser :: Parser 'Both m ByteString
bsParser = Text -> ByteString
encodeUtf8 (Text -> ByteString)
-> Parser MetadataObjId 'Both m Text -> Parser 'Both m ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both m Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string

columnParser' ::
  (MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) =>
  ColumnType 'MySQL ->
  GQL.Nullability ->
  m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
columnParser' :: ColumnType 'MySQL
-> Nullability
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
columnParser' ColumnType 'MySQL
columnType (GQL.Nullability Bool
isNullable) =
  Parser 'Both n (ColumnValue 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
forall (m :: * -> *) a.
MonadParse m =>
Parser 'Both m a -> Parser 'Both m (ValueWithOrigin a)
peelWithOrigin (Parser 'Both n (ColumnValue 'MySQL)
 -> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
-> (Parser MetadataObjId 'Both n ScalarValue
    -> Parser 'Both n (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ScalarValue -> ColumnValue 'MySQL)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser 'Both n (ColumnValue 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ColumnType 'MySQL -> ScalarValue 'MySQL -> ColumnValue 'MySQL
forall (b :: BackendType).
ColumnType b -> ScalarValue b -> ColumnValue b
ColumnValue ColumnType 'MySQL
columnType) (Parser MetadataObjId 'Both n ScalarValue
 -> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
-> m (Parser MetadataObjId 'Both n ScalarValue)
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case ColumnType 'MySQL
columnType of
    ColumnScalar ScalarType 'MySQL
scalarType -> case ScalarType 'MySQL
scalarType of
      ScalarType 'MySQL
MySQL.Decimal -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Double -> ScalarValue
MySQL.DecimalValue (Double -> ScalarValue)
-> Parser MetadataObjId 'Both n Double
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Double
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Double
P.float
      ScalarType 'MySQL
MySQL.Tiny -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Int32 -> ScalarValue
MySQL.TinyValue (Int32 -> ScalarValue)
-> Parser MetadataObjId 'Both n Int32
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int32
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Int32
P.int
      ScalarType 'MySQL
MySQL.Short -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Int32 -> ScalarValue
MySQL.SmallValue (Int32 -> ScalarValue)
-> Parser MetadataObjId 'Both n Int32
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int32
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Int32
P.int
      ScalarType 'MySQL
MySQL.Long -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Int32 -> ScalarValue
MySQL.IntValue (Int32 -> ScalarValue)
-> Parser MetadataObjId 'Both n Int32
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int32
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Int32
P.int
      ScalarType 'MySQL
MySQL.Float -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Double -> ScalarValue
MySQL.FloatValue (Double -> ScalarValue)
-> Parser MetadataObjId 'Both n Double
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Double
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Double
P.float
      ScalarType 'MySQL
MySQL.Double -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Double -> ScalarValue
MySQL.DoubleValue (Double -> ScalarValue)
-> Parser MetadataObjId 'Both n Double
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Double
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Double
P.float
      ScalarType 'MySQL
MySQL.Null -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ ScalarValue
MySQL.NullValue ScalarValue
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
MySQL.LongLong -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Int32 -> ScalarValue
MySQL.BigValue (Int32 -> ScalarValue)
-> Parser MetadataObjId 'Both n Int32
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int32
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Int32
P.int
      ScalarType 'MySQL
MySQL.Int24 -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Int32 -> ScalarValue
MySQL.MediumValue (Int32 -> ScalarValue)
-> Parser MetadataObjId 'Both n Int32
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Int32
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Int32
P.int
      ScalarType 'MySQL
MySQL.Date -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Text -> ScalarValue
MySQL.DateValue (Text -> ScalarValue)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
MySQL.Year -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Text -> ScalarValue
MySQL.YearValue (Text -> ScalarValue)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
MySQL.Bit -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Bool -> ScalarValue
MySQL.BitValue (Bool -> ScalarValue)
-> Parser MetadataObjId 'Both n Bool
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Bool
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Bool
P.boolean
      ScalarType 'MySQL
MySQL.String -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Text -> ScalarValue
MySQL.VarcharValue (Text -> ScalarValue)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
MySQL.VarChar -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Text -> ScalarValue
MySQL.VarcharValue (Text -> ScalarValue)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
MySQL.DateTime -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Text -> ScalarValue
MySQL.DatetimeValue (Text -> ScalarValue)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
MySQL.Blob -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ ByteString -> ScalarValue
MySQL.BlobValue (ByteString -> ScalarValue)
-> Parser MetadataObjId 'Both n ByteString
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n ByteString
forall (m :: * -> *). MonadParse m => Parser 'Both m ByteString
bsParser
      ScalarType 'MySQL
MySQL.Timestamp -> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable ScalarType 'MySQL
Type
scalarType (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Text -> ScalarValue
MySQL.TimestampValue (Text -> ScalarValue)
-> Parser MetadataObjId 'Both n Text
-> Parser MetadataObjId 'Both n ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Text
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Text
P.string
      ScalarType 'MySQL
_ -> do
        Name
name <- Type -> m Name
forall (m :: * -> *). MonadError QErr m => Type -> m Name
MySQL.mkMySQLScalarTypeName ScalarType 'MySQL
Type
scalarType
        let schemaType :: Type MetadataObjId 'Both
schemaType = Nullability
-> Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
-> Type MetadataObjId 'Both
forall origin (k :: Kind).
Nullability
-> Definition origin (TypeInfo origin k) -> Type origin k
P.TNamed Nullability
P.NonNullable (Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
 -> Type MetadataObjId 'Both)
-> Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
-> Type MetadataObjId 'Both
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe Description
-> Maybe MetadataObjId
-> [Directive Void]
-> TypeInfo MetadataObjId 'Both
-> Definition MetadataObjId (TypeInfo MetadataObjId 'Both)
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
name Maybe Description
forall a. Maybe a
Nothing Maybe MetadataObjId
forall a. Maybe a
Nothing [] TypeInfo MetadataObjId 'Both
forall origin. TypeInfo origin 'Both
P.TIScalar
        Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser MetadataObjId 'Both n ScalarValue
 -> m (Parser MetadataObjId 'Both n ScalarValue))
-> Parser MetadataObjId 'Both n ScalarValue
-> m (Parser MetadataObjId 'Both n ScalarValue)
forall a b. (a -> b) -> a -> b
$
          Parser :: forall origin (k :: Kind) (m :: * -> *) a.
Type origin k -> (ParserInput k -> m a) -> Parser origin k m a
P.Parser
            { pType :: Type MetadataObjId 'Both
pType = Type MetadataObjId 'Both
schemaType,
              pParser :: ParserInput 'Both -> n ScalarValue
pParser =
                GType -> InputValue Variable -> n Value
forall (m :: * -> *).
MonadParse m =>
GType -> InputValue Variable -> m Value
P.valueToJSON (Type MetadataObjId 'Both -> GType
forall origin (k :: Kind). Type origin k -> GType
P.toGraphQLType Type MetadataObjId 'Both
schemaType)
                  (InputValue Variable -> n Value)
-> (Value -> n ScalarValue) -> InputValue Variable -> n ScalarValue
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (QErr -> n ScalarValue)
-> (ScalarValue -> n ScalarValue)
-> Either QErr ScalarValue
-> n ScalarValue
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (ParseErrorCode -> ErrorMessage -> n ScalarValue
forall (m :: * -> *) a.
MonadParse m =>
ParseErrorCode -> ErrorMessage -> m a
P.parseErrorWith ParseErrorCode
P.ParseFailed (ErrorMessage -> n ScalarValue)
-> (QErr -> ErrorMessage) -> QErr -> n ScalarValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> ErrorMessage
toErrorMessage (Text -> ErrorMessage) -> (QErr -> Text) -> QErr -> ErrorMessage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. QErr -> Text
qeError) ScalarValue -> n ScalarValue
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either QErr ScalarValue -> n ScalarValue)
-> (Value -> Either QErr ScalarValue) -> Value -> n ScalarValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Type -> Value -> Either QErr ScalarValue
MySQL.parseScalarValue ScalarType 'MySQL
Type
scalarType)
            }
    ColumnEnumReference enumRef :: EnumReference 'MySQL
enumRef@(EnumReference TableName 'MySQL
_ EnumValues
enumValues Maybe Name
_) ->
      case [(EnumValue, EnumValueInfo)]
-> Maybe (NonEmpty (EnumValue, EnumValueInfo))
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty (EnumValues -> [(EnumValue, EnumValueInfo)]
forall k v. HashMap k v -> [(k, v)]
HM.toList EnumValues
enumValues) of
        Just NonEmpty (EnumValue, EnumValueInfo)
enumValuesList -> do
          Name
enumName <- EnumReference 'MySQL -> m Name
forall (b :: BackendType) (m :: * -> *) r.
(Backend b, MonadReader r m, Has MkTypename r, MonadError QErr m,
 Has NamingCase r) =>
EnumReference b -> m Name
mkEnumTypeName EnumReference 'MySQL
enumRef
          pure $ Type
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *).
MonadParse m =>
Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable Type
MySQL.VarChar (Parser MetadataObjId 'Both n ScalarValue
 -> Parser MetadataObjId 'Both n ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
-> Parser MetadataObjId 'Both n ScalarValue
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe Description
-> NonEmpty (Definition EnumValueInfo, ScalarValue)
-> Parser MetadataObjId 'Both n ScalarValue
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> NonEmpty (Definition origin EnumValueInfo, a)
-> Parser origin 'Both m a
P.enum Name
enumName Maybe Description
forall a. Maybe a
Nothing ((EnumValue, EnumValueInfo)
-> (Definition EnumValueInfo, ScalarValue 'MySQL)
(EnumValue, EnumValueInfo)
-> (Definition EnumValueInfo, ScalarValue)
mkEnumValue ((EnumValue, EnumValueInfo)
 -> (Definition EnumValueInfo, ScalarValue))
-> NonEmpty (EnumValue, EnumValueInfo)
-> NonEmpty (Definition EnumValueInfo, ScalarValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmpty (EnumValue, EnumValueInfo)
enumValuesList)
        Maybe (NonEmpty (EnumValue, EnumValueInfo))
Nothing -> Code -> Text -> m (Parser MetadataObjId 'Both n ScalarValue)
forall (m :: * -> *) a. QErrM m => Code -> Text -> m a
throw400 Code
ValidationFailed Text
"empty enum values"
  where
    possiblyNullable :: (MonadParse m) => MySQL.Type -> Parser 'Both m MySQL.ScalarValue -> Parser 'Both m MySQL.ScalarValue
    possiblyNullable :: Type -> Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
possiblyNullable Type
_scalarType
      | Bool
isNullable = (Maybe ScalarValue -> ScalarValue)
-> Parser MetadataObjId 'Both m (Maybe ScalarValue)
-> Parser 'Both m ScalarValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (ScalarValue -> Maybe ScalarValue -> ScalarValue
forall a. a -> Maybe a -> a
fromMaybe ScalarValue
MySQL.NullValue) (Parser MetadataObjId 'Both m (Maybe ScalarValue)
 -> Parser 'Both m ScalarValue)
-> (Parser 'Both m ScalarValue
    -> Parser MetadataObjId 'Both m (Maybe ScalarValue))
-> Parser 'Both m ScalarValue
-> Parser 'Both m ScalarValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Parser 'Both m ScalarValue
-> Parser MetadataObjId 'Both m (Maybe ScalarValue)
forall origin (k :: Kind) (m :: * -> *) a.
(MonadParse m, 'Input <: k) =>
Parser origin k m a -> Parser origin k m (Maybe a)
P.nullable
      | Bool
otherwise = Parser 'Both m ScalarValue -> Parser 'Both m ScalarValue
forall a. a -> a
id
    mkEnumValue :: (EnumValue, EnumValueInfo) -> (P.Definition P.EnumValueInfo, RQL.ScalarValue 'MySQL)
    mkEnumValue :: (EnumValue, EnumValueInfo)
-> (Definition EnumValueInfo, ScalarValue 'MySQL)
mkEnumValue (RQL.EnumValue Name
value, EnumValueInfo Maybe Text
description) =
      ( Name
-> Maybe Description
-> Maybe MetadataObjId
-> [Directive Void]
-> EnumValueInfo
-> Definition EnumValueInfo
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
value (Text -> Description
GQL.Description (Text -> Description) -> Maybe Text -> Maybe Description
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
description) Maybe MetadataObjId
forall a. Maybe a
Nothing [] EnumValueInfo
P.EnumValueInfo,
        Text -> ScalarValue
MySQL.VarcharValue (Text -> ScalarValue) -> Text -> ScalarValue
forall a b. (a -> b) -> a -> b
$ Name -> Text
GQL.unName Name
value
      )

orderByOperators' :: NamingCase -> (GQL.Name, NonEmpty (P.Definition P.EnumValueInfo, (BasicOrderType 'MySQL, NullsOrderType 'MySQL)))
orderByOperators' :: NamingCase
-> (Name,
    NonEmpty
      (Definition EnumValueInfo,
       (BasicOrderType 'MySQL, NullsOrderType 'MySQL)))
orderByOperators' NamingCase
_tCase =
  (Name
Name._order_by,) (NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))
 -> (Name,
     NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))))
-> NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))
-> (Name, NonEmpty (Definition EnumValueInfo, (Order, NullsOrder)))
forall a b. (a -> b) -> a -> b
$
    -- NOTE: NamingCase is not being used here as we don't support naming conventions for this DB
    [(Definition EnumValueInfo, (Order, NullsOrder))]
-> NonEmpty (Definition EnumValueInfo, (Order, NullsOrder))
forall a. [a] -> NonEmpty a
NE.fromList
      [ ( Name -> Description -> Definition EnumValueInfo
forall origin.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._asc Description
"in ascending order, nulls first",
          (Order
MySQL.Asc, NullsOrder
MySQL.NullsFirst)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall origin.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._asc_nulls_first Description
"in ascending order, nulls first",
          (Order
MySQL.Asc, NullsOrder
MySQL.NullsFirst)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall origin.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._asc_nulls_last Description
"in ascending order, nulls last",
          (Order
MySQL.Asc, NullsOrder
MySQL.NullsLast)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall origin.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._desc Description
"in descending order, nulls last",
          (Order
MySQL.Desc, NullsOrder
MySQL.NullsLast)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall origin.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._desc_nulls_first Description
"in descending order, nulls first",
          (Order
MySQL.Desc, NullsOrder
MySQL.NullsFirst)
        ),
        ( Name -> Description -> Definition EnumValueInfo
forall origin.
Name -> Description -> Definition origin EnumValueInfo
define Name
Name._desc_nulls_last Description
"in descending order, nulls last",
          (Order
MySQL.Desc, NullsOrder
MySQL.NullsLast)
        )
      ]
  where
    define :: Name -> Description -> Definition origin EnumValueInfo
define Name
name Description
desc = Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> EnumValueInfo
-> Definition origin EnumValueInfo
forall origin a.
Name
-> Maybe Description
-> Maybe origin
-> [Directive Void]
-> a
-> Definition origin a
P.Definition Name
name (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
desc) Maybe origin
forall a. Maybe a
Nothing [] EnumValueInfo
P.EnumValueInfo

-- | TODO: Make this as thorough as the one for MSSQL/PostgreSQL
comparisonExps' ::
  forall m n r.
  (BackendSchema 'MySQL, MonadMemoize m, MonadParse n, MonadError QErr m, MonadReader r m, Has MkTypename r, Has NamingCase r) =>
  ColumnType 'MySQL ->
  m (Parser 'Input n [ComparisonExp 'MySQL])
comparisonExps' :: ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL])
comparisonExps' = Name
-> (ColumnType 'MySQL
    -> m (Parser 'Input n [ComparisonExp 'MySQL]))
-> ColumnType 'MySQL
-> m (Parser 'Input n [ComparisonExp 'MySQL])
forall (m :: * -> *) a (p :: (* -> *) -> * -> *) (n :: * -> *) b.
(MonadMemoize m, Ord a, Typeable a, Typeable p, MonadParse n,
 Typeable b) =>
Name -> (a -> m (p n b)) -> a -> m (p n b)
P.memoize 'comparisonExps ((ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL]))
 -> ColumnType 'MySQL -> m (Parser 'Input n [ComparisonExp 'MySQL]))
-> (ColumnType 'MySQL
    -> m (Parser 'Input n [ComparisonExp 'MySQL]))
-> ColumnType 'MySQL
-> m (Parser 'Input n [ComparisonExp 'MySQL])
forall a b. (a -> b) -> a -> b
$ \ColumnType 'MySQL
columnType -> do
  -- see Note [Columns in comparison expression are never nullable]
  Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser <- ColumnType 'MySQL
-> Nullability
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)))
forall (b :: BackendType) (n :: * -> *) (m :: * -> *) r.
(BackendSchema b, MonadParse n, MonadError QErr m, MonadReader r m,
 Has MkTypename r, Has NamingCase r) =>
ColumnType b
-> Nullability
-> m (Parser 'Both n (ValueWithOrigin (ColumnValue b)))
columnParser ColumnType 'MySQL
columnType (Bool -> Nullability
GQL.Nullability Bool
False)
  let name :: Name
name = Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)) -> Name
forall a. HasName a => a -> Name
P.getName Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser Name -> Name -> Name
forall a. Semigroup a => a -> a -> a
<> Name
Name.__MySQL_comparison_exp
      desc :: Description
desc =
        Text -> Description
GQL.Description (Text -> Description) -> Text -> Description
forall a b. (a -> b) -> a -> b
$
          Text
"Boolean expression to compare columns of type "
            Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL)) -> Name
forall a. HasName a => a -> Name
P.getName Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser
            Name -> Text -> Text
forall t. ToTxt t => t -> Text -> Text
<<> Text
". All fields are combined with logical 'AND'."
  Parser 'Input n [ComparisonExp 'MySQL]
-> m (Parser 'Input n [ComparisonExp 'MySQL])
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Parser 'Input n [ComparisonExp 'MySQL]
 -> m (Parser 'Input n [ComparisonExp 'MySQL]))
-> Parser 'Input n [ComparisonExp 'MySQL]
-> m (Parser 'Input n [ComparisonExp 'MySQL])
forall a b. (a -> b) -> a -> b
$
    Name
-> Maybe Description
-> InputFieldsParser MetadataObjId n [ComparisonExp 'MySQL]
-> Parser 'Input n [ComparisonExp 'MySQL]
forall (m :: * -> *) origin a.
MonadParse m =>
Name
-> Maybe Description
-> InputFieldsParser origin m a
-> Parser origin 'Input m a
P.object Name
name (Description -> Maybe Description
forall a. a -> Maybe a
Just Description
desc) (InputFieldsParser MetadataObjId n [ComparisonExp 'MySQL]
 -> Parser 'Input n [ComparisonExp 'MySQL])
-> InputFieldsParser MetadataObjId n [ComparisonExp 'MySQL]
-> Parser 'Input n [ComparisonExp 'MySQL]
forall a b. (a -> b) -> a -> b
$
      [Maybe (ComparisonExp 'MySQL)] -> [ComparisonExp 'MySQL]
forall (f :: * -> *) a. Filterable f => f (Maybe a) -> f a
catMaybes
        ([Maybe (ComparisonExp 'MySQL)] -> [ComparisonExp 'MySQL])
-> InputFieldsParser MetadataObjId n [Maybe (ComparisonExp 'MySQL)]
-> InputFieldsParser MetadataObjId n [ComparisonExp 'MySQL]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))]
-> InputFieldsParser MetadataObjId n [Maybe (ComparisonExp 'MySQL)]
forall (t :: * -> *) (f :: * -> *) a.
(Traversable t, Applicative f) =>
t (f a) -> f (t a)
sequenceA
          [ Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__is_null Maybe Description
forall a. Maybe a
Nothing (ComparisonExp 'MySQL
-> ComparisonExp 'MySQL -> Bool -> ComparisonExp 'MySQL
forall a. a -> a -> Bool -> a
bool ComparisonExp 'MySQL
forall (backend :: BackendType) field. OpExpG backend field
ANISNOTNULL ComparisonExp 'MySQL
forall (backend :: BackendType) field. OpExpG backend field
ANISNULL (Bool -> ComparisonExp 'MySQL)
-> Parser MetadataObjId 'Both n Bool
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser MetadataObjId 'Both n Bool
forall (m :: * -> *) origin.
MonadParse m =>
Parser origin 'Both m Bool
P.boolean),
            Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__eq Maybe Description
forall a. Maybe a
Nothing (Bool -> UnpreparedValue 'MySQL -> ComparisonExp 'MySQL
forall (backend :: BackendType) field.
Bool -> field -> OpExpG backend field
AEQ Bool
True (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL)
-> (ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL)
-> ValueWithOrigin (ColumnValue 'MySQL)
-> ComparisonExp 'MySQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
mkParameter (ValueWithOrigin (ColumnValue 'MySQL) -> ComparisonExp 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser),
            Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__neq Maybe Description
forall a. Maybe a
Nothing (Bool -> UnpreparedValue 'MySQL -> ComparisonExp 'MySQL
forall (backend :: BackendType) field.
Bool -> field -> OpExpG backend field
ANE Bool
True (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL)
-> (ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL)
-> ValueWithOrigin (ColumnValue 'MySQL)
-> ComparisonExp 'MySQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
mkParameter (ValueWithOrigin (ColumnValue 'MySQL) -> ComparisonExp 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser),
            Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__gt Maybe Description
forall a. Maybe a
Nothing (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL
forall (backend :: BackendType) field.
field -> OpExpG backend field
AGT (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL)
-> (ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL)
-> ValueWithOrigin (ColumnValue 'MySQL)
-> ComparisonExp 'MySQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
mkParameter (ValueWithOrigin (ColumnValue 'MySQL) -> ComparisonExp 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser),
            Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__lt Maybe Description
forall a. Maybe a
Nothing (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL
forall (backend :: BackendType) field.
field -> OpExpG backend field
ALT (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL)
-> (ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL)
-> ValueWithOrigin (ColumnValue 'MySQL)
-> ComparisonExp 'MySQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
mkParameter (ValueWithOrigin (ColumnValue 'MySQL) -> ComparisonExp 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser),
            Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__gte Maybe Description
forall a. Maybe a
Nothing (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL
forall (backend :: BackendType) field.
field -> OpExpG backend field
AGTE (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL)
-> (ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL)
-> ValueWithOrigin (ColumnValue 'MySQL)
-> ComparisonExp 'MySQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
mkParameter (ValueWithOrigin (ColumnValue 'MySQL) -> ComparisonExp 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser),
            Name
-> Maybe Description
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
-> InputFieldsParser MetadataObjId n (Maybe (ComparisonExp 'MySQL))
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name.__lte Maybe Description
forall a. Maybe a
Nothing (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL
forall (backend :: BackendType) field.
field -> OpExpG backend field
ALTE (UnpreparedValue 'MySQL -> ComparisonExp 'MySQL)
-> (ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL)
-> ValueWithOrigin (ColumnValue 'MySQL)
-> ComparisonExp 'MySQL
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValueWithOrigin (ColumnValue 'MySQL) -> UnpreparedValue 'MySQL
forall (b :: BackendType).
ValueWithOrigin (ColumnValue b) -> UnpreparedValue b
mkParameter (ValueWithOrigin (ColumnValue 'MySQL) -> ComparisonExp 'MySQL)
-> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
-> Parser MetadataObjId 'Both n (ComparisonExp 'MySQL)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser 'Both n (ValueWithOrigin (ColumnValue 'MySQL))
typedParser)
          ]

mysqlCountTypeInput ::
  MonadParse n =>
  Maybe (Parser 'Both n (Column 'MySQL)) ->
  InputFieldsParser n (IR.CountDistinct -> CountType 'MySQL)
mysqlCountTypeInput :: Maybe (Parser 'Both n (Column 'MySQL))
-> InputFieldsParser n (CountDistinct -> CountType 'MySQL)
mysqlCountTypeInput = \case
  Just Parser 'Both n (Column 'MySQL)
columnEnum -> do
    Maybe [Column]
columns <- Name
-> Maybe Description
-> Parser MetadataObjId 'Both n [Column]
-> InputFieldsParser MetadataObjId n (Maybe [Column])
forall (m :: * -> *) (k :: Kind) origin a.
(MonadParse m, 'Input <: k) =>
Name
-> Maybe Description
-> Parser origin k m a
-> InputFieldsParser origin m (Maybe a)
P.fieldOptional Name
Name._columns Maybe Description
forall a. Maybe a
Nothing (Parser MetadataObjId 'Both n [Column]
 -> InputFieldsParser MetadataObjId n (Maybe [Column]))
-> Parser MetadataObjId 'Both n [Column]
-> InputFieldsParser MetadataObjId n (Maybe [Column])
forall a b. (a -> b) -> a -> b
$ Parser MetadataObjId 'Both n Column
-> Parser MetadataObjId 'Both n [Column]
forall origin (k :: Kind) (m :: * -> *) a.
(MonadParse m, 'Input <: k) =>
Parser origin k m a -> Parser origin k m [a]
P.list Parser 'Both n (Column 'MySQL)
Parser MetadataObjId 'Both n Column
columnEnum
    pure $ (CountDistinct -> Maybe [Column] -> Countable Column)
-> Maybe [Column] -> CountDistinct -> Countable Column
forall a b c. (a -> b -> c) -> b -> a -> c
flip CountDistinct -> Maybe [Column 'MySQL] -> CountType 'MySQL
CountDistinct -> Maybe [Column] -> Countable Column
mkCountType Maybe [Column]
columns
  Maybe (Parser 'Both n (Column 'MySQL))
Nothing -> (CountDistinct -> Countable Column)
-> InputFieldsParser
     MetadataObjId n (CountDistinct -> Countable Column)
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((CountDistinct -> Countable Column)
 -> InputFieldsParser
      MetadataObjId n (CountDistinct -> Countable Column))
-> (CountDistinct -> Countable Column)
-> InputFieldsParser
     MetadataObjId n (CountDistinct -> Countable Column)
forall a b. (a -> b) -> a -> b
$ (CountDistinct -> Maybe [Column] -> Countable Column)
-> Maybe [Column] -> CountDistinct -> Countable Column
forall a b c. (a -> b -> c) -> b -> a -> c
flip CountDistinct -> Maybe [Column 'MySQL] -> CountType 'MySQL
CountDistinct -> Maybe [Column] -> Countable Column
mkCountType Maybe [Column]
forall a. Maybe a
Nothing
  where
    mkCountType :: IR.CountDistinct -> Maybe [Column 'MySQL] -> CountType 'MySQL
    mkCountType :: CountDistinct -> Maybe [Column 'MySQL] -> CountType 'MySQL
mkCountType CountDistinct
_ Maybe [Column 'MySQL]
Nothing = CountType 'MySQL
forall name. Countable name
MySQL.StarCountable
    mkCountType CountDistinct
IR.SelectCountDistinct (Just [Column 'MySQL]
cols) =
      Countable Column
-> (NonEmpty Column -> Countable Column)
-> Maybe (NonEmpty Column)
-> Countable Column
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Countable Column
forall name. Countable name
MySQL.StarCountable NonEmpty Column -> Countable Column
forall name. NonEmpty name -> Countable name
MySQL.DistinctCountable (Maybe (NonEmpty Column) -> Countable Column)
-> Maybe (NonEmpty Column) -> Countable Column
forall a b. (a -> b) -> a -> b
$ [Column] -> Maybe (NonEmpty Column)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty [Column 'MySQL]
[Column]
cols
    mkCountType CountDistinct
IR.SelectCountNonDistinct (Just [Column 'MySQL]
cols) =
      Countable Column
-> (NonEmpty Column -> Countable Column)
-> Maybe (NonEmpty Column)
-> Countable Column
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Countable Column
forall name. Countable name
MySQL.StarCountable NonEmpty Column -> Countable Column
forall name. NonEmpty name -> Countable name
MySQL.NonNullFieldCountable (Maybe (NonEmpty Column) -> Countable Column)
-> Maybe (NonEmpty Column) -> Countable Column
forall a b. (a -> b) -> a -> b
$ [Column] -> Maybe (NonEmpty Column)
forall a. [a] -> Maybe (NonEmpty a)
nonEmpty [Column 'MySQL]
[Column]
cols