Skip to content

fix(query): reject unbound :find variables and unknown :find functions up front (#406, #414) - #483

Merged
adityamukho merged 1 commit into
v3from
fix/406-414-query-validation
Oct 8, 2026
Merged

adityamukho merged 1 commit into
v3from
fix/406-414-query-validation

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Summary

Two v3.0.0 behavior breaks that turn silent empty results into errors.

#406 — unbound :find variable → PRS-080 (parse time, execute()/query()/prepare())

  • Uses the same outer_bound set as the existing aggregate (PRS-023) and :with (PRS-022) checks: pattern positions, rule-call args, expression bindings, or-join join vars, vars in every or branch.
  • Also covers window functions' argument, :partition-by and :order-by variables, which were unchecked.
  • Vars only inside not/not-join and ?_ wildcards are not bound. Bind slots are values, so they are unaffected.

#414 — unknown aggregate / window function → QRY-010 / QRY-011

  • check_find_functions resolves every :find aggregate and window function against the FunctionRegistry at the top of execute_query, before the rules branch, so the plain, rules, prepared and cursor paths all get it and the result no longer depends on the data.
  • INT-029/INT-030 stay registered (codes are never removed); ERROR_REFERENCE notes they now signal only an internal inconsistency.

The PreparedQuery rustdoc example had the #406 bug (:find ?name never bound) and is fixed.

Not in this PR

  • Wiki Tutorial-10-UDFs.md shows the old INT-029 output. Left for the v3.0.0 doc sync, like the other v3 wiki changes (the live wiki documents v2.x).

Test plan

  • tests/error_codes_prs_test.rs: PRS-080 cases via execute() and prepare(), message names the variable, accepted binding forms
  • tests/error_codes_qry_test.rs: QRY-010/QRY-011 on empty DB, no matching rows, matching rows, rule query, prepared query; registered UDF on empty DB returns empty
  • cargo test: 1372 tests (1363 passing, 9 ignored)
  • cargo clippy --all-features -- -D warnings, cargo fmt
  • demos and examples produce no PRS-080/QRY-010/QRY-011

Refs #406, #414

🤖 Generated with Claude Code

https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn

…s up front (#406, #414)

A :find variable that no :where clause binds (plain, or a window
function's argument, :partition-by or :order-by variable) is now a
parse error, PRS-080, instead of an empty result. Aggregate and window
function names are resolved against the function registry before the
query runs, so an unknown one is QRY-010 / QRY-011 whether or not any
row matches; INT-029 / INT-030 stay registered for internal
inconsistencies only.

The PreparedQuery doc example had exactly the #406 bug (?name never
bound) and is fixed.

Refs #406, #414

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015GgLEs8YozJjYhwPEYgTUn
@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 1eeb33b into v3 Oct 8, 2026
24 checks passed
@adityamukho
adityamukho deleted the fix/406-414-query-validation branch October 8, 2026 05:36
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.

1 participant