Skip to content

Reject SELECT columns that no document has - #41

Merged
rathboma merged 1 commit into
mainfrom
rathboma/exciting-rubin-9i3xa3
Oct 14, 2026
Merged

rathboma merged 1 commit into
mainfrom
rathboma/exciting-rubin-9i3xa3

Conversation

@rathboma

@rathboma rathboma commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

MongoDB returns an empty document for each match when a projected field
doesn't exist, so SELECT invalid_lmao FROM users returned one blank row
per document instead of an error.

Fix #7

  • The compiler records the fields a SELECT list reads on FIND and
    AGGREGATE commands (selectedFields). Table qualifiers are dropped,
    paths stop at the first array index, and JOINs are skipped.
  • The executor throws 'Column "x" does not exist in collection "y"' when
    no document in the collection has a selected field. execute() only
    looks up fields that none of the returned rows have a value for;
    executeCursor() checks before returning the cursor. Fields that only
    some documents have, and empty collections, are still allowed.
  • DummyCollection gets a findOne, which the executor already needed for
    ObjectId detection.

Claude-Session: https://claude.ai/code/session_013yzyAbpCE94cknaLBFAtZ7

MongoDB returns an empty document for each match when a projected field
doesn't exist, so SELECT invalid_lmao FROM users returned one blank row
per document instead of an error (#7).

- The compiler records the fields a SELECT list reads on FIND and
  AGGREGATE commands (selectedFields). Table qualifiers are dropped,
  paths stop at the first array index, and JOINs are skipped.
- The executor throws 'Column "x" does not exist in collection "y"' when
  no document in the collection has a selected field. execute() only
  looks up fields that none of the returned rows have a value for;
  executeCursor() checks before returning the cursor. Fields that only
  some documents have, and empty collections, are still allowed.
- DummyCollection gets a findOne, which the executor already needed for
  ObjectId detection.

Claude-Session: https://claude.ai/code/session_013yzyAbpCE94cknaLBFAtZ7
@rathboma
rathboma merged commit 9bb753e into main Oct 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selects still return records if selecting an invalid field.

1 participant