Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines functions that translate from the Postgres IR into Postgres SQL AST.
NOTE: These functions processAnnAggregateSelect
, processAnnSimpleSelect
,
processConnectionSelect
, are all mutually recursive.
These functions are generally called from the top level functions in Translate.Select, and the call stack looks like:
selectQuerySQL
->mkSQLSelect
->processAnnSimpleSelect
->processSelectParams
/processAnnFields
selectAggregateQuerySQL
->mkAggregateSelect
->processAnnAggregateSelect
->processSelectParams
/processAnnFields
connetionSelectQuerySQL
->mkConnectionSelect
->processConnectionSelection
->processSelectParams
SelectSource
consists of a prefix, a source, a boolean conditional
expression, and info on whether sorting or slicing is done (needed to handle
the LIMIT optimisation)
Documentation
processSelectParams :: forall pgKind m. (MonadReader StringifyNumbers m, MonadWriter JoinTree m, Backend ('Postgres pgKind)) => SourcePrefixes -> FieldName -> SimilarArrayFields -> SelectFrom ('Postgres pgKind) -> PermissionLimitSubQuery -> TablePerm ('Postgres pgKind) -> SelectArgs ('Postgres pgKind) -> m (SelectSource, [(ColumnAlias, SQLExp)], Maybe SQLExp) Source #
processAnnAggregateSelect :: forall pgKind m. (MonadReader StringifyNumbers m, MonadWriter JoinTree m, Backend ('Postgres pgKind), PostgresAnnotatedFieldJSON pgKind) => SourcePrefixes -> FieldName -> AnnAggregateSelect ('Postgres pgKind) -> m (SelectSource, HashMap ColumnAlias SQLExp, Extractor) Source #
processAnnFields :: forall pgKind m. (MonadReader StringifyNumbers m, MonadWriter JoinTree m, Backend ('Postgres pgKind), PostgresAnnotatedFieldJSON pgKind) => Identifier -> FieldName -> SimilarArrayFields -> AnnFields ('Postgres pgKind) -> Maybe NamingCase -> m (ColumnAlias, SQLExp) Source #
mkSimilarArrayFields :: forall pgKind v. (Backend ('Postgres pgKind), Eq v) => AnnFieldsG ('Postgres pgKind) Void v -> Maybe (NonEmpty (AnnotatedOrderByItemG ('Postgres pgKind) v)) -> SimilarArrayFields Source #
processArrayRelation :: forall pgKind m. (MonadReader StringifyNumbers m, MonadWriter JoinTree m, Backend ('Postgres pgKind), PostgresAnnotatedFieldJSON pgKind) => SourcePrefixes -> FieldName -> TableAlias -> ArraySelect ('Postgres pgKind) -> Maybe NamingCase -> m () Source #
aggregateFieldToExp :: AggregateFields ('Postgres pgKind) -> StringifyNumbers -> SQLExp Source #
processAnnSimpleSelect :: forall pgKind m. (MonadReader StringifyNumbers m, MonadWriter JoinTree m, Backend ('Postgres pgKind), PostgresAnnotatedFieldJSON pgKind) => SourcePrefixes -> FieldName -> PermissionLimitSubQuery -> AnnSimpleSelect ('Postgres pgKind) -> m (SelectSource, HashMap ColumnAlias SQLExp) Source #
processConnectionSelect :: forall pgKind m. (MonadReader StringifyNumbers m, MonadWriter JoinTree m, Backend ('Postgres pgKind), PostgresAnnotatedFieldJSON pgKind) => SourcePrefixes -> FieldName -> TableAlias -> HashMap PGCol PGCol -> ConnectionSelect ('Postgres pgKind) Void SQLExp -> m (ArrayConnectionSource, Extractor, HashMap ColumnAlias SQLExp) Source #