Open
Description
When the type of _pathQty
is Int64
(or Integer
), the following query fails at runtime with an exception, but works when the type is Double
.
aggregate_
(\path ->
( group_ (_pathSrc path)
, fromMaybe_ 0 (sum_ (_pathQty path))
)
)
(all_ (_paths someDb))
Exception thrown:
PgRowParseError (PgRowCouldNotParseField 1 [Incompatible {errSQLType = "numeric", errSQLTableOid = Nothing, errSQLField = "res1", errHaskellType = "Integer", errMessage = "types incompatible"}])
There's a minimal example in this repo which works when a Postgres docker instance is running using the command docker run -p 5432:5432 --name postgres-test -e POSTGRES_PASSWORD=test -e POSTGRES_USER=test -e POSTGRES_DB=test -d postgres:9.6
.
Here's the output of the minimal example:
CREATE TABLE "paths" ("id" SERIAL UNIQUE NOT NULL, "src" TEXT NOT NULL, "qty" BIGINT NOT NULL, PRIMARY KEY("id"))
INSERT INTO "paths"("id", "src", "qty") VALUES (DEFAULT, 'ABC', 47), (DEFAULT, 'ABC', 3), (DEFAULT, 'ABC', 19), (DEFAULT, 'LOL', 8)
SELECT "t0"."src" AS "res0", COALESCE(SUM("t0"."qty"), 0) AS "res1" FROM "paths" AS "t0" GROUP BY "t0"."src"
DROP TABLE "paths"
example-exe: PgRowParseError (PgRowCouldNotParseField 1 [Incompatible {errSQLType = "numeric", errSQLTableOid = Nothing, errSQLField = "res1", errHaskellType = "Integer", errMessage = "types incompatible"}])