beam-core-0.6.0.0: Type-safe, feature-complete SQL query and manipulation interface for Haskell

Safe HaskellNone
LanguageHaskell2010

Database.Beam.Query.CustomSQL

Contents

Description

Allows the creation of custom SQL expressions from arbitrary ByteStrings.

Simply create a function with an arbitrary number of ByteString arguments that returns a ByteString. Then, apply customExpr_ to your function. This will result in a function with the same arity, that takes in QGenExprs instead of ByteString's, and returns a QGenExpr as well.

Semantically, the expression builder function is called with arguments representing SQL expressions, that, when evaluated, will evaluate to the result of the expressions supplied as arguments to customExpr_. See the section on extensibility in the user guide for example usage.

Synopsis

The customExpr_ function

class IsCustomExprFn fn res | res -> fn where Source #

Minimal complete definition

customExpr_

Methods

customExpr_ :: fn -> res Source #

Type-inference help

valueExpr_ :: QExpr syntax s a -> QExpr syntax s a Source #

Force a QGenExpr to be typed as a value expression (a QExpr). Useful for getting around type-inference errors with supplying the entire type.

agg_ :: QAgg syntax s a -> QAgg syntax s a Source #

Force a QGenExpr to be typed as an aggregate. Useful for defining custom aggregates for use in aggregate_.

For backends

class (Monoid (CustomSqlSyntax syntax), IsString (CustomSqlSyntax syntax)) => IsCustomSqlSyntax syntax where Source #

A type-class for expression syntaxes that can embed custom expressions.

Minimal complete definition

customExprSyntax, renderSyntax

Associated Types

data CustomSqlSyntax syntax :: * Source #

Methods

customExprSyntax :: CustomSqlSyntax syntax -> syntax Source #

Given an arbitrary ByteString, produce a syntax that represents the ByteString as a SQL expression.

renderSyntax :: syntax -> CustomSqlSyntax syntax Source #

Given an arbitrary syntax, produce a ByteString that corresponds to how that syntax would look when rendered in the backend.