| Copyright | (c) digitally induced GmbH 2025 |
|---|---|
| Safe Haskell | None |
| Language | GHC2021 |
IHP.QueryBuilder.HasqlCompiler
Description
This module compiles QueryBuilder queries directly to Hasql Statement values
by threading a parameter counter and encoder accumulator through compilation.
Synopsis
- buildStatement :: SQLQuery -> Result a -> Statement () a
- buildWrappedStatement :: Text -> SQLQuery -> Text -> Result a -> Statement () a
- toSQL :: forall (table :: Symbol). KnownSymbol table => QueryBuilder table -> Text
- compileOperator :: FilterOperator -> Text
- data CompilerState = CompilerState !Int !(Params ())
- emptyCompilerState :: CompilerState
- nextParam :: Params () -> CompilerState -> (Text, CompilerState)
Documentation
buildStatement :: SQLQuery -> Result a -> Statement () a Source #
Build a Hasql Statement from a compiled SQLQuery and a result decoder.
buildWrappedStatement :: Text -> SQLQuery -> Text -> Result a -> Statement () a Source #
Like buildStatement, but wraps the compiled SQL with a prefix and suffix.
Used for SELECT COUNT(*) FROM (inner) AS alias patterns.
toSQL :: forall (table :: Symbol). KnownSymbol table => QueryBuilder table -> Text Source #
Compile a QueryBuilder to SQL text (for testing / error messages). Discards the encoder.
compileOperator :: FilterOperator -> Text Source #
Compiles a FilterOperator to its SQL representation
data CompilerState Source #
Compile context: parameter counter + accumulated encoder.
Constructors
| CompilerState !Int !(Params ()) |
emptyCompilerState :: CompilerState Source #
Initial compile context: counter starts at 1, no params.
nextParam :: Params () -> CompilerState -> (Text, CompilerState) Source #
Assign the next $N placeholder and accumulate the encoder.