graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Backends.MySQL.FromIr

Description

Translate from the DML to the MySQL dialect.

Synopsis

Documentation

data Error Source #

Most of these errors should be checked for legitimacy.

Instances

Instances details
Eq Error Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

Methods

(==) :: Error -> Error -> Bool #

(/=) :: Error -> Error -> Bool #

Show Error Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

Methods

showsPrec :: Int -> Error -> ShowS #

show :: Error -> String #

showList :: [Error] -> ShowS #

MonadValidate (NonEmpty Error) FromIr Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

newtype FromIr a Source #

The base monad used throughout this module for all conversion functions.

It's a Validate, so it'll continue going when it encounters errors to accumulate as many as possible.

It also contains a mapping from entity prefixes to counters. So if my prefix is "table" then there'll be a counter that lets me generate table1, table2, etc. Same for any other prefix needed (e.g. names for joins).

A ReaderT is used around this in most of the module too, for setting the current entity that a given field name refers to. See fromColumn.

Constructors

FromIr 

Fields

Instances

Instances details
Monad FromIr Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

Methods

(>>=) :: FromIr a -> (a -> FromIr b) -> FromIr b #

(>>) :: FromIr a -> FromIr b -> FromIr b #

return :: a -> FromIr a #

Functor FromIr Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

Methods

fmap :: (a -> b) -> FromIr a -> FromIr b #

(<$) :: a -> FromIr b -> FromIr a #

Applicative FromIr Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

Methods

pure :: a -> FromIr a #

(<*>) :: FromIr (a -> b) -> FromIr a -> FromIr b #

liftA2 :: (a -> b -> c) -> FromIr a -> FromIr b -> FromIr c #

(*>) :: FromIr a -> FromIr b -> FromIr b #

(<*) :: FromIr a -> FromIr b -> FromIr a #

MonadValidate (NonEmpty Error) FromIr Source # 
Instance details

Defined in Hasura.Backends.MySQL.FromIr

runFromIr :: FromIr a -> Validate (NonEmpty Error) a Source #

fromQualifiedTable :: TableName -> FromIr From Source #

This is really the start where you query the base table, everything else is joins attached to it.

fromColumnInfoForBoolExp :: ColumnInfo 'MySQL -> ReaderT EntityAlias FromIr Expression Source #

For boolean operators, various comparison operators used need special handling to ensure that SQL Server won't outright reject the comparison. See also shouldCastToVarcharMax.

fromMapping :: From -> HashMap Column Column -> ReaderT EntityAlias FromIr [Expression] Source #

The context given by the reader is of the previous/parent "remote" table. The WHERE that we're generating goes in the child, "local" query. The From passed in as argument is the local table.

We should hope to see e.g. "post.category = category.id" for a local table of post and a remote table of category.

The left/right columns in HashMap Column Column corresponds to the left/right of select ... join .... Therefore left=remote, right=local in this context.

data UnfurledJoin Source #

Constructors

UnfurledJoin 

Fields

unfurlAnnOrderByElement :: AnnotatedOrderByElement 'MySQL Expression -> WriterT (Seq UnfurledJoin) (ReaderT EntityAlias FromIr) (FieldName, Maybe ScalarType) Source #

Unfurl the nested set of object relations (tell'd in the writer) that are terminated by field name (IR.AOCColumn and IR.AOCArrayAggregation).

fromAnnOrderByItemG :: AnnotatedOrderByItemG 'MySQL Expression -> WriterT (Seq UnfurledJoin) (ReaderT EntityAlias FromIr) OrderBy Source #

Produce a valid ORDER BY construct, telling about any joins needed on the side.

fromAnnColumnField :: AnnColumnField 'MySQL Expression -> ReaderT EntityAlias FromIr Expression Source #

Here is where we project a field as a column expression. If number stringification is on, then we wrap it in a ToStringExpression so that it's casted when being projected.

fromAnnFieldsG :: (FieldName, AnnFieldG 'MySQL Void Expression) -> ReaderT EntityAlias FromIr FieldSource Source #

The main sources of fields, either constants, fields or via joins.

fromRootField :: QueryDB 'MySQL Void Expression -> FromIr Select Source #

Convert from the IR database query into a select.