Skip to content

drivers(turso): RemoteTransport still refuses a dotted groupBy alias while driver-sql escapes it — the second output-name position #14113 deliberately left alone #14235

Description

@claude

Filed from #14113 (aggregation-alias escaping on the Turso remote transport). Same defect class, the other output-name position in the same method, not fixed by that card — it carries a landed pin asserting the current behaviour, so reversing it needs its own judgement rather than a rider.

What

RemoteTransport.aggregate (packages/drivers/driver-turso/src/remote-transport.ts) has exactly two positions that emit a caller-supplied output NAME:

selectParts.push(outKey === field ? `"${field}"` : `"${field}" AS "${outKey}"`);   // groupBy alias
selectParts.push(`${lowering.sql}(${argSql}) AS ${this.aliasIdentifierSql(alias)}`); // aggregation alias

#14113 moved the aggregation alias to escaping (quote doubled, assertSafeIdentifier dropped from that position only). The groupBy alias (outKey, which is g.alias ?? g.field) still goes through assertSafeIdentifier, so any groupBy alias that is not a bare [A-Za-z_][A-Za-z0-9_]* is refused with a bare Error — no code, no status, an opaque 500 out of mapDataError.

Why it is a divergence

driver-sql post-#13714 routes both positions through SqlDriver.aliasIdentifierSql:

  • sql-driver.ts groupBy select site — ?? as ${this.aliasIdentifierSql(outKey)}
  • sql-driver.ts aggregation select sites — ${lowering.sql}(*) as ${this.aliasIdentifierSql(agg.alias)}
  • and the window-function alias site

So after #14113 the Turso remote face agrees with the SQL face on the aggregation alias and still disagrees on the groupBy alias. GroupByNodeSchema.alias is an output-column key, the same class of thing as AggregationNodeSchema.alias, and the in-memory path projects g.alias ?? g.field verbatim.

Why it was NOT patched inline under #14113

The position carries a landed pin that asserts the refusal:

packages/drivers/driver-turso/src/remote-transport-groupby-node.test.ts[#6401] refuses an unsafe identifier in \alias`, not only in `field`, asserting unsafe identifier rejected` and the offending text.

That pin was a deliberate call at #6401, when the alias was newly read here. Reversing it is a judgement about the same reference-versus-name line #13714 and #14113 drew, not a mechanical edit, so it is filed rather than folded into a card dispatched for the aggregation position. #14113 leaves a regression control pinning this position's current behaviour, so the state cannot drift silently while this card is open.

Exposure

⚠️ Lower than #14113's, and measured rather than assumed: no analytics query sends a dotted groupBy alias. ObjectQLStrategy.resolveFieldName resolves a dimension to member.sql or member.split('.')[1], so dimensions reach the driver as bare column names; only the measure arrives as CUBE.MEASURE. The reachable population is a caller writing groupBy: [{ field: 'region', alias: 'Region Name' }] through the Query Protocol directly, which works on the in-memory, MongoDB and SQL faces and is an opaque 500 on Turso remote.

Acceptance

Either escape the groupBy alias the way #14113 escaped the aggregation alias (and rewrite the #6401 pin to assert the new truth, as #14113 did not have to), or rule that this position stays gated and record why the two output-name positions differ. Either way the two faces should stop disagreeing silently.


Generated by Claude Code

Activity

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

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions