vapor / fluent-postgres-driver

🐘 PostgreSQL driver for Fluent.
MIT License
149 stars 53 forks source link

Adding filter using an empty array throws error #57

Closed patchthecode closed 6 years ago

patchthecode commented 6 years ago
let operationalModes = try RestaurantOperationalHourMode.query(on: req).filter(\.id ~~ opertionHrModeIds).all()

opertionHrModeIds is an empty array

Thrown error log is shown below

[psql] [2018-05-18 04:34:25 +0000] select oid, relname from pg_class []
[psql] [2018-05-18 04:34:25 +0000] SELECT * FROM "tokens" WHERE ("tokens"."value" = $1) LIMIT 1 OFFSET 0 ["TEXT (binary) 7278D68E-1A48-495B-BD69-AA12489E20CB)"]
[psql] [2018-05-18 04:34:25 +0000] SELECT * FROM "users" WHERE ("users"."id" = $1) LIMIT 1 OFFSET 0 ["UUID (binary) »ïJé€$OG²\rvCñËÚY)"]
Getting restaurant
[psql] [2018-05-18 04:34:25 +0000] SELECT * FROM "restaurants" WHERE ("restaurants"."userId" = $1) ["UUID (binary) »ïJé€$OG²\rvCñËÚY)"]
[psql] [2018-05-18 04:34:25 +0000] SELECT * FROM "restaurantoperationalhourmodes" WHERE (0) []
[ ERROR ] PostgreSQLDiagnosticResponse.coerce_to_boolean: ERROR: argument of WHERE must be type boolean, not type integer (Logger+LogError.swift:17)
[ DEBUG ] Possible causes for PostgreSQLDiagnosticResponse.coerce_to_boolean: argument of WHERE must be type boolean, not type integer (Logger+LogError.swift:23)
tanner0101 commented 6 years ago

A test for this was added in Fluent's benchmarker a while back (and the related issue fixed). Let me know if you're still seeing it, thanks!