Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Since: 1.0.0.0
Synopsis
- data SyntheticField a
- syntheticFieldExpression :: SyntheticField a -> ValueExpression
- syntheticFieldAlias :: SyntheticField a -> FieldName
- syntheticFieldValueFromSqlValue :: SyntheticField a -> SqlValue -> Either String a
- syntheticField :: ValueExpression -> String -> (SqlValue -> Either String a) -> SyntheticField a
- nullableSyntheticField :: SyntheticField a -> SyntheticField (Maybe a)
- prefixSyntheticField :: String -> SyntheticField a -> SyntheticField a
Documentation
data SyntheticField a Source #
A SyntheticField
can be used to evaluate a SQL expression based on the
columns of a table when records are selected from the database. Synthetic
fields are inherently read-only.
Since: 1.0.0.0
syntheticFieldExpression :: SyntheticField a -> ValueExpression Source #
Returns the SQL expression that should be used in select statements to calculate the synthetic field.
Since: 1.0.0.0
syntheticFieldAlias :: SyntheticField a -> FieldName Source #
Returns the alias that should be used in select statements to name the synthetic field.
Since: 1.0.0.0
syntheticFieldValueFromSqlValue :: SyntheticField a -> SqlValue -> Either String a Source #
Decodes a calculated value selected from the database to its expected
Haskell type. Returns a Left
with an error message if the decoding fails.
Since: 1.0.0.0
:: ValueExpression | The SQL expression to be selected. |
-> String | The alias to be used to name the calculation in SQL expressions. |
-> (SqlValue -> Either String a) | A function to decode the expression result from a |
-> SyntheticField a |
Constructs a SyntheticField
that will select a SQL expression using
the given alias.
Since: 1.0.0.0
nullableSyntheticField :: SyntheticField a -> SyntheticField (Maybe a) Source #
Modifies a SyntheticField
to allow it to decode NULL
values.
Since: 1.0.0.0
prefixSyntheticField :: String -> SyntheticField a -> SyntheticField a Source #
Adds a prefix, followed by an underscore, to the alias used to name the synthetic field.
Since: 1.0.0.0