Conversation
7db9a67 to
3acf7ad
Compare
Adds a `Visitor<'a>` trait with associated types `T: Default` and `E`, with four `visit_*` methods that default to walking all children. Public `walk_statement`, `walk_expression`, `walk_select`, and `walk_table_reference` free functions are also exported so callers can delegate back to the default traversal from within a custom visitor.
Store the closing ')' span in all AST structs where it was previously parsed and discarded. This ensures that Spanned::span() for an expression or definition covers the full source text including any trailing delimiter. Affected structs: - expression.rs: InExpression, MemberOfExpression, CastExpression, ConvertExpression, GroupConcatExpression, TrimExpression, ExtractExpression, TimestampAddExpression, TimestampDiffExpression, MatchAgainstExpression, ExistsExpression, QuantifierExpression - function_expression.rs: WindowSpec - alter_table.rs: AddIndex (cols_r_paren) - create_table.rs: CreateDefinition index/foreign key variants - insert_replace.rs: InsertReplace (columns span) - operator.rs: CreateOperatorFamily (full span) - select.rs: Select (locking clause span)
3acf7ad to
3775f24
Compare
There was a problem hiding this comment.
Pull request overview
Adds a reusable AST visitor/walker API to qusql-parse and improves Span accuracy across many AST nodes by capturing closing-paren spans, then bumps qusql-parse to 0.7.0 and updates downstream dependency.
Changes:
- Introduce
Visitor+walk_*traversal functions forStatement,Expression,Select, andTableReference(qusql-parse/src/visit.rs) and re-export them fromlib.rs. - Improve
Spannedaccuracy by tracking closing)spans across expressions/functions/window specs and several DDL/ALTER constructs. - Bump
qusql-parsecrate version to0.7.0and updatequsql-typeto depend on it.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| qusql-type/Cargo.toml | Updates dependency on qusql-parse to 0.7.0. |
| qusql-parse/Cargo.toml | Bumps crate version to 0.7.0. |
| qusql-parse/src/lib.rs | Adds visit module + re-exports visitor/walk APIs. |
| qusql-parse/src/visit.rs | New visitor/walker implementation for AST traversal. |
| qusql-parse/src/select.rs | Ensures Select::span() includes locking clause span. |
| qusql-parse/src/operator.rs | Expands CreateOperatorFamily::span() to include child spans. |
| qusql-parse/src/insert_replace.rs | Ensures InsertReplace::span() includes column list span. |
| qusql-parse/src/function_expression.rs | Adds r_paren_span to function/window nodes and updates parsing + spans. |
| qusql-parse/src/expression.rs | Adds closing-paren spans to multiple expression nodes and updates parsing + spans. |
| qusql-parse/src/create_table.rs | Adds closing-paren spans for column/definition lists and updates parsing + spans. |
| qusql-parse/src/alter_table.rs | Returns closing-paren spans from column-list parsers and threads them into AST + spans. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+401
to
+482
| // -- Leaf statements (DDL, TCL, SHOW, ...) ------------------------------------- | ||
| // These have no child expressions or statements to recurse into. | ||
| Statement::AlterSchema(_) | ||
| | Statement::AlterTable(_) | ||
| | Statement::AlterRole(_) | ||
| | Statement::AlterType(_) | ||
| | Statement::AlterOperator(_) | ||
| | Statement::AlterOperatorClass(_) | ||
| | Statement::AlterOperatorFamily(_) | ||
| | Statement::CreateIndex(_) | ||
| | Statement::CreateTable(_) | ||
| | Statement::CreateView(_) | ||
| | Statement::CreateTrigger(_) | ||
| | Statement::CreateFunction(_) | ||
| | Statement::CreateProcedure(_) | ||
| | Statement::CreateDatabase(_) | ||
| | Statement::CreateSchema(_) | ||
| | Statement::CreateSequence(_) | ||
| | Statement::CreateServer(_) | ||
| | Statement::CreateRole(_) | ||
| | Statement::CreateOperator(_) | ||
| | Statement::CreateTypeEnum(_) | ||
| | Statement::CreateOperatorClass(_) | ||
| | Statement::CreateOperatorFamily(_) | ||
| | Statement::CreateExtension(_) | ||
| | Statement::CreateDomain(_) | ||
| | Statement::CreateConstraintTrigger(_) | ||
| | Statement::CreateTablePartitionOf(_) | ||
| | Statement::DropIndex(_) | ||
| | Statement::DropTable(_) | ||
| | Statement::DropFunction(_) | ||
| | Statement::DropProcedure(_) | ||
| | Statement::DropSequence(_) | ||
| | Statement::DropEvent(_) | ||
| | Statement::DropDatabase(_) | ||
| | Statement::DropServer(_) | ||
| | Statement::DropTrigger(_) | ||
| | Statement::DropView(_) | ||
| | Statement::DropExtension(_) | ||
| | Statement::DropOperator(_) | ||
| | Statement::DropOperatorFamily(_) | ||
| | Statement::DropOperatorClass(_) | ||
| | Statement::DropDomain(_) | ||
| | Statement::DropType(_) | ||
| | Statement::RenameTable(_) | ||
| | Statement::TruncateTable(_) | ||
| | Statement::RefreshMaterializedView(_) | ||
| | Statement::CommentOn(_) | ||
| | Statement::Signal(_) | ||
| | Statement::Kill(_) | ||
| | Statement::ShowTables(_) | ||
| | Statement::ShowDatabases(_) | ||
| | Statement::ShowProcessList(_) | ||
| | Statement::ShowVariables(_) | ||
| | Statement::ShowStatus(_) | ||
| | Statement::ShowColumns(_) | ||
| | Statement::ShowCreateTable(_) | ||
| | Statement::ShowCreateDatabase(_) | ||
| | Statement::ShowCreateView(_) | ||
| | Statement::ShowCharacterSet(_) | ||
| | Statement::ShowCollation(_) | ||
| | Statement::ShowEngines(_) | ||
| | Statement::Flush(_) | ||
| | Statement::Unlock(_) | ||
| | Statement::Lock(_) | ||
| | Statement::Begin(_) | ||
| | Statement::End(_) | ||
| | Statement::Commit(_) | ||
| | Statement::StartTransaction(_) | ||
| | Statement::CopyFrom(_) | ||
| | Statement::CopyTo(_) | ||
| | Statement::Stdin(_) | ||
| | Statement::OpenCursor(_) | ||
| | Statement::CloseCursor(_) | ||
| | Statement::FetchCursor(_) | ||
| | Statement::Leave(_) | ||
| | Statement::Iterate(_) | ||
| | Statement::Grant(_) | ||
| | Statement::ExecuteFunction(_) | ||
| | Statement::Analyze(_) | ||
| | Statement::Invalid(_) => Ok(V::T::default()), | ||
| } |
| walk_table_reference(self, tr) | ||
| } | ||
| } | ||
|
|
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.
No description provided.