graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.Backends.Postgres.Translate.Select.Internal.Helpers

Description

Stuff gutted from Translate.Select.

Synopsis

Documentation

mkFirstElementExp :: SQLExp -> SQLExp Source #

First element extractor expression from given record set For example:- To get first "id" column from given row set, the function generates the SQL expression AS `(array_agg("id"))[1]`

mkLastElementExp :: SQLExp -> SQLExp Source #

Last element extractor expression from given record set. For example:- To get first "id" column from given row set, the function generates the SQL expression AS `(array_agg("id"))[array_length(array_agg("id"), 1)]`

nativeQueryNameToAlias :: NativeQueryName -> Int -> TableAlias Source #

Given a NativeQueryName, what should we call the CTE generated for it?

functionToIdentifier :: QualifiedFunction -> Identifier Source #

Converts a function name to an Identifier.

If the schema name is public, it will just use its name, otherwise it will prefix it by the schema name.

withForceAggregation :: TypeAnn -> SQLExp -> SQLExp Source #

Forces aggregation

selectToSelectWith :: Writer CustomSQLCTEs Select -> SelectWith Source #

unwrap any emitted TopLevelCTEs for custom sql from the Writer and combine them with a Select to create a SelectWith

customSQLToTopLevelCTEs :: CustomSQLCTEs -> [(TableAlias, TopLevelCTE)] Source #

convert map of CustomSQL CTEs into named TopLevelCTEs

customSQLToInnerCTEs :: CustomSQLCTEs -> [(TableAlias, InnerCTE)] Source #

convert map of CustomSQL CTEs into named InnerCTEs