fix(driver-sql): an unknown $select column must not zero the result set#1818
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SqlDriver.find()swallowed any"no such column"error into an empty array. So a projected$selectnaming a column the table lacks (e.g. a generic list view auto-requestingstatus/due_date/imageon 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
$selectprojection, retry once withSELECT *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
findwithfields: ['id','name','status','due_date','image']on a table that only hasid/name/agereturns all rows (the phantom columns absent), instead of[].🤖 Generated with Claude Code