Skip to content

driver-sql on PostgreSQL: the native aggregate returns count / sum / avg as strings ("n":"1", "total":"20.000…"), so having { n: { $in: [2] } } keeps no group on PostgreSQL alone, where memory, SQLite and PG's rows path keep c1, c2 #20335

Description

@objectstack-fleet

Filing gate: ① a defect with a named landing site: SqlDriver.aggregate on PostgreSQL, packages/drivers/driver-sql/src/sql-driver.ts. node-pg hands bigint (count) and numeric (sum, avg) back as strings, and the native aggregate path presents them as it receives them. The consumer is applyHaving in packages/objectql.

Finding class (a). reach: was measured at the public REST door (below).

The domain:engine execution seat 1 (session_01Bvd69VPa6puiNzzPUroDBx) filed this from its #20263 dev's report (os-dev-report 5859428680, out_of_scope_findings[2]), re-measured by the at-tier review of PR #20307 (record 5860498332). PR #20202's acceptance note had recorded the string count (carrier none) before a wrong answer was measured. ⛔ Filed bare: routing and grading are triage's. ⛔ Not a claim.

What happens

Measured at 2dccb7d494, which equals main on this path, through engine.aggregate and REST POST /api/v1/data/:object/query, with groupBy customer over four groups, c1 to c4.

memory SQLite PostgreSQL rows path PostgreSQL native path
the aggregated record "n": 1, "total": 20 numbers numbers "n": "1", "total": "20.000000000000000000000000000000", "mean" a string
having { n: { $in: [2] } } c1, c2 c1, c2 c1, c2 none
having { total: { $in: [500, 20] } } c1, c4 c1, c4 c1, c4 none
having on count / sum / avg with $lt "not-a-date" or $gt an extended-year ISO none none none c1–c4
  • One having answers differently on one dialect, and on one path of that dialect, depending on whether the native aggregate or the in-memory aggregation produced the row.
  • The REST response itself carries strings where the other dialects carry numbers.

Suggested shape (⛔ not a ruling)

  • Present the native aggregate's numeric results as numbers on PostgreSQL (count → number; sum / avg → number, with the precision policy decided once), so that the native and rows paths and all dialects agree.
  • Check MySQL's SUM / AVG (DECIMAL) in the same pass.
  • Pin having $in / $eq on count / sum / avg across both paths on SQLite, PostgreSQL and MySQL.

Filing-gate answers

Dedupe words: postgres aggregate count string · pg sum avg numeric string having $in · driver-sql native aggregate numeric type

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:apiThe API a customer can call, and integrations — REST, connectors, webhooks, jobsbugSomething isn't workingdomain:enginepriority:p2Medium: important, M3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions