Fix index out of bounds panic in ST09 for non-standard comparison ope…#2427
Open
Fix index out of bounds panic in ST09 for non-standard comparison ope…#2427
Conversation
…rators The `&&` (overlap) operator in PostgreSQL is parsed as a ComparisonOperator but contains AmpersandSegment children instead of RawComparisonOperator children. ST09 assumed raw_comparison_operators was non-empty when swapping column order, causing a panic on index 0 of an empty vec. Add an emptiness check before accessing raw_comparison_operators[0]. Fixes #2426 https://claude.ai/code/session_01QzckwNiRjStjnS9c7BZRHQ
Collaborator
Author
|
The problem is in fact the fact that we are not parsing the thing correctly. |
Contributor
Benchmark for f8adaf3Click to view benchmark
|
Instead of just guarding against the empty index, properly handle non-standard comparison operators like && (overlap), &> etc. by extracting the operator string and checking it against a whitelist of reorderable operators. This matches SQLFluff's _REORDERABLE_OPERATORS approach in their ST09 rule. https://claude.ai/code/session_01QzckwNiRjStjnS9c7BZRHQ
Contributor
Benchmark for c36594bClick to view benchmark
|
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.
…rators
The
&&(overlap) operator in PostgreSQL is parsed as a ComparisonOperator but contains AmpersandSegment children instead of RawComparisonOperator children. ST09 assumed raw_comparison_operators was non-empty when swapping column order, causing a panic on index 0 of an empty vec.Add an emptiness check before accessing raw_comparison_operators[0].
Fixes #2426
https://claude.ai/code/session_01QzckwNiRjStjnS9c7BZRHQ