orville-postgresql-1.0.0.0: A Haskell library for PostgreSQL
CopyrightFlipstone Technology Partners 2023
LicenseMIT
StabilityStable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Orville.PostgreSQL.Execution.SelectOptions

Description

Since: 1.0.0.0

Synopsis

Documentation

data SelectOptions Source #

A SelectOptions is a set of options that can be used to change the way a basic query function works by adding WHERE, ORDER BY, GROUP BY, etc. Functions are provided to construct SelectOptions for individual options, which may then be combined via <> (also exposed as appendSelectOptions).

Since: 1.0.0.0

emptySelectOptions :: SelectOptions Source #

A set of empty SelectOptions that will not change how a query is run.

Since: 1.0.0.0

appendSelectOptions :: SelectOptions -> SelectOptions -> SelectOptions Source #

Combines multple select options together, unioning the options together where possible. For options where this is not possible (e.g. LIMIT), the one on the left is preferred.

Since: 1.0.0.0

selectDistinct :: SelectOptions -> SelectClause Source #

Builds the SelectClause that should be used to include the distincts from the SelectOptions on a query.

Since: 1.0.0.0

selectWhereClause :: SelectOptions -> Maybe WhereClause Source #

Builds the WhereClause that should be used to include the BooleanExprs from the SelectOptions on a query. This will be Nothing when no BooleanExprs have been specified.

Since: 1.0.0.0

selectOrderByClause :: SelectOptions -> Maybe OrderByClause Source #

Builds the OrderByClause that should be used to include the OrderByClauses from the SelectOptions on a query. This will be Nothing when no OrderByClauses have been specified.

Since: 1.0.0.0

selectGroupByClause :: SelectOptions -> Maybe GroupByClause Source #

Builds the GroupByClause that should be used to include the GroupByClauses from the SelectOptions on a query. This will be Nothing when no GroupByClauses have been specified.

Since: 1.0.0.0

selectLimitExpr :: SelectOptions -> Maybe LimitExpr Source #

Builds a LimitExpr that will limit the query results to the number specified in the SelectOptions (if any).

Since: 1.0.0.0

selectOffsetExpr :: SelectOptions -> Maybe OffsetExpr Source #

Builds an OffsetExpr that will limit the query results to the number specified in the SelectOptions (if any).

Since: 1.0.0.0

distinct :: SelectOptions Source #

Constructs a SelectOptions with just distinct set to True.

Since: 1.0.0.0

where_ :: BooleanExpr -> SelectOptions Source #

Constructs a SelectOptions with just the given BooleanExpr.

Since: 1.0.0.0

orderBy :: OrderByExpr -> SelectOptions Source #

Constructs a SelectOptions with just the given OrderByExpr.

Since: 1.0.0.0

limit :: Int -> SelectOptions Source #

Constructs a SelectOptions that will apply the given limit.

Since: 1.0.0.0

offset :: Int -> SelectOptions Source #

Constructs a SelectOptions that will apply the given offset.

Since: 1.0.0.0

groupBy :: GroupByExpr -> SelectOptions Source #

Constructs a SelectOptions with just the given GroupByClause.

Since: 1.0.0.0

selectOptionsQueryExpr :: SelectList -> TableReferenceList -> SelectOptions -> QueryExpr Source #

Builds a QueryExpr that will use the specified SelectList when building the SELECT statement to execute. It is up to the caller to make sure that the SelectList expression makes sense for the table being queried, and that the names of the columns in the result set match those expected by the SqlMarshaller that is ultimately used to decode it.

This function is useful for building more advanced queries that need to select things other than simple columns from the table, such as using aggregate functions. The SelectList can be built however the caller desires. If Orville does not support building the SelectList you need using any of the expression-building functions, you can resort to RawSql.fromRawSql as an escape hatch to build the SelectList here.

Since: 1.0.0.0