Repository navigation
fix(parser): reject write clauses as unsupported features - #189
Merged
Merged
Conversation
A write clause such as CREATE or SET failed with an opaque parse error. After a parse failure, look for a write clause outside strings, comments and quoted names and report it as UnsupportedFeature with its position.
Deploying lance-csr with
|
| Latest commit: |
1fe308a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://71eab526.lance-csr.pages.dev |
| Branch Preview URL: | https://fix-reject-write-clauses.lance-csr.pages.dev |
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.
Why
lance-csr runs read-only Cypher, but a write clause such as
CREATEorSETfailed with the same opaque parse error as a typo. Callers couldn't tell "valid Cypher this engine doesn't run" from "invalid Cypher". Closes #183.What changed
When a query fails to parse, the parser now looks for a write clause (
CREATE,MERGE,SET,DELETE,DETACH DELETE,REMOVE,FOREACH,LOAD CSV) and, if it finds one, returnsGraphError::UnsupportedFeatureinstead ofParseError. Python raisesNotImplementedErrorand TypeScript aNotImplementederror, through the existing mappings.The message names the clause and where it starts:
Keywords inside strings, comments and backtick-quoted names are ignored, as are words used as a property (
p.set), parameter ($delete), label (:Merge) or map key ({remove: 1}). The check only runs after a parse failure, so a query that parses today is never rejected by it.The Cypher and TypeScript guides list the full set of write clauses and say they raise
NotImplementedError.Validation
cargo test -p lance-csr: all pass, including new parser tests for each clause, multi-line positions, non-ASCII text before the clause, and keywords in names, literals and comments staying parse errors.cargo clippy -p lance-csr --all-targets -- -D warnings,uvx typos@1.52.0 .and the strict Zensical docs build pass.🤖 Generated with Claude Code