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

Hasura.Backends.MSSQL.FromIr.Query

Description

This module defines translation functions for queries which select data. Principally this includes translating the query root field, but parts are also reused for serving the responses for mutations.

Synopsis

Documentation

fromQueryRootField :: QueryDB 'MSSQL Void Expression -> FromIr Select Source #

This is the top-level entry point for translation of Query root fields.

fromSourceRelationship Source #

Arguments

:: NonEmpty Object

List of json objects, each of which becomes a row of the table

-> HashMap FieldName (ColumnName, ScalarType)

The above objects have this schema

-> FieldName 
-> (FieldName, SourceRelationshipSelection 'MSSQL Void (Const Expression)) 
-> FromIr Select 

Used in planSourceRelationship, which is in turn used by to implement mkDBRemoteRelationship for BackendExecute. For more information, see the module/documentation of Source.

fromRemoteRelationFieldsG :: Map TableName EntityAlias -> HashMap ColumnName ColumnName -> (FieldName, SourceRelationshipSelection 'MSSQL Void (Const Expression)) -> ReaderT EntityAlias FromIr FieldSource Source #

Build the FieldSource for the relation field, depending on whether it's an object, array, or aggregate relationship.

fromSelectRows :: AnnSelectG 'MSSQL (AnnFieldG 'MSSQL Void) Expression -> FromIr Select Source #

Toproot-level Select. All descendentsub-translations are collected to produce a root TSQL.Select.

fromTableExpFieldG :: (Int, (FieldName, TableAggregateFieldG 'MSSQL Void Expression)) -> Maybe (ReaderT EntityAlias FromIr (Int, Projection)) Source #

Get FieldSource from a TAFExp type table aggregate field

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

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

fromAnnColumnField :: AnnColumnField 'MSSQL 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.

fromColumn :: ColumnName -> ReaderT EntityAlias FromIr FieldName Source #

This is where a field name "foo" is resolved to a fully qualified field name [table].[foo]. The table name comes from EntityAlias in the ReaderT.

fromMapping :: From -> HashMap ColumnName ColumnName -> 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 ColumnName ColumnName corresponds to the left/right of select ... join .... Therefore left=remote, right=local in this context.

safeJsonQueryExpression :: JsonCardinality -> Expression -> Expression Source #

A version of JSON_QUERY(..) that returns a proper json literal, rather than SQL null, which does not compose properly with FOR JSON clauses.

data UnfurledJoin Source #

Constructors

UnfurledJoin 

Fields

unfurlAnnotatedOrderByElement :: AnnotatedOrderByElement 'MSSQL 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).