Skip to content

fix(driver-sql): an unknown $select column must not zero the result set#1818

Merged
xuyushun441-sys merged 1 commit into
mainfrom
fix/select-unknown-column-empty
Jun 13, 2026
Merged

fix(driver-sql): an unknown $select column must not zero the result set#1818
xuyushun441-sys merged 1 commit into
mainfrom
fix/select-unknown-column-empty

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Problem

SqlDriver.find() swallowed any "no such column" error into an empty array. So a projected $select naming a column the table lacks (e.g. a generic list view auto-requesting status/due_date/image on an object without them) made the whole query return zero rows — reading to the UI as "no records exist" while the data was actually present. Silent data loss.

There is an engine-level filter (engine.ts, "drop unknown select fields") that's meant to prevent this, but it only fires when the object's schema is populated in the registry — which is not the case in the cloud multi-tenant runtime, so the bad projection reached the driver and got swallowed.

Fix

When the failure came from a $select projection, retry once with SELECT * so the real rows still come back (the phantom field is simply absent from each row — it never existed). Non-projection errors (unknown table, etc.) still surface as before, and a query with no explicit fields keeps the old fallback.

Tests

  • New: find with fields: ['id','name','status','due_date','image'] on a table that only has id/name/age returns all rows (the phantom columns absent), instead of [].
  • New: an unknown table still throws (not swallowed to empty).
  • Full sql-driver suite: 11 pass.

🤖 Generated with Claude Code

find() swallowed any "no such column" error into an empty array. A projected
$select naming a column the table lacks (e.g. a generic list view auto-
requesting status/due_date/image on an object without them) then made the
WHOLE query return zero rows — reading to the UI as "no records exist" while
the data was actually there: a silent data-loss footgun.

When the failure came from the projection, retry once with SELECT * so the
real rows still come back (the phantom field is simply absent from each row).
Non-projection errors (unknown table, etc.) still surface as before. The
engine's unknown-field filter is the first line of defense, but it only fires
when the object's schema is populated in the registry; this driver backstop
holds even when it isn't (notably the cloud multi-tenant runtime).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 13, 2026 3:11pm

Request Review

@xuyushun441-sys
xuyushun441-sys merged commit 035d343 into main Jun 13, 2026
12 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the fix/select-unknown-column-empty branch June 13, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants