-
Notifications
You must be signed in to change notification settings - Fork 182
Closed
Description
Minimal example:
query ::
(BeamSqlBackend be, BeamSqlBackendCanSerialize be Int32, BeamSqlBackendCanSerialize be Double) =>
Q be db s (QExpr be s Int32, QExpr be s Double)
query = pure (val_ 99, val_ 1.0)
...
_ <- runSelectReturningList $ select query
Running this query throws an exception:
BeamRowReadError {brreColumn = Just 1, brreError = ColumnTypeMismatch {ctmHaskellType = "Double", ctmSQLType = "numeric", ctmMessage = "types incompatible"}}
The generated SQL is SELECT 99 AS "res0", 1.0 AS "res1".
Using as_ doesn't helpl, i.e. as_ @Double (val_ 1.0).
The workaround is to use cast_ in a pretty redundant way: cast_ (val_ (1.0 :: Double)) Database.Beam.Query.DataTypes.double. That compiles to the following SQL: SELECT 99 AS "res0", CAST((1.0) AS DOUBLE PRECISION) AS "res1".
I'm surprised that the integer value isn't affected by the same issue.
beam-core version: 0.10.1.0
beam-postgres version: 0.5.3.1
Metadata
Metadata
Assignees
Labels
No labels