-
Notifications
You must be signed in to change notification settings - Fork 1
fix(sql): case-insensitive LIKE operator and normalize operator compa… #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rison - Add case-insensitive flag (?i) to LIKE operator regex pattern - Normalize operator comparison by converting to lowercase - Fix potential case sensitivity issues in operator matching This change ensures consistent behavior when comparing operators regardless of their case (e.g., "LIKE" vs "like") and makes the LIKE operator case-insensitive by default, which is more consistent with standard SQL behavior. Signed-off-by: Avelino <[email protected]>
📝 WalkthroughWalkthroughThis pull request updates the SQL operator handling within the ChrontDB API. The changes convert operator strings to lowercase for both Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Application
participant Eval as evaluate-condition
participant Where as apply-where-conditions
Caller->>Eval: Call function with condition (operator, values)
Eval->>Eval: Convert operator to lowercase
alt operator is "like"
Eval->>Eval: Prepend "(?i)" to regex pattern
else operator is "<>"
Eval->>Eval: Process as inequality check
else
Eval->>Eval: Process standard operator
end
Eval-->>Caller: Return evaluation result
Caller->>Where: Call with a set of conditions
Where->>Where: Normalize all operators to lowercase
Where->>Where: Process each condition (using similar logic)
Where-->>Caller: Return filtered query result
Poem
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/chrondb/api/sql/execution/operators.clj (1)
15-24: Consider documenting the case-insensitivity changesThese changes make the LIKE operator and all operator comparisons case-insensitive, which is a behavior change that might affect existing users. Consider adding a note in the documentation or changelog to highlight this change.
Also applies to: 44-57
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/chrondb/api/sql/execution/operators.clj(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test
- GitHub Check: test
🔇 Additional comments (6)
src/chrondb/api/sql/execution/operators.clj (6)
15-15: Good enhancement: operator case normalizationConverting operator strings to lowercase ensures consistent behavior regardless of the case used in queries, which aligns with standard SQL behavior.
24-24: Great improvement: case-insensitive LIKE operatorAdding the
(?i)flag to the regex pattern makes the LIKE operator case-insensitive by default, which matches standard SQL behavior in most database systems. This change ensures queries will be more intuitive for users familiar with SQL.
44-44: Good consistency: operator normalization in apply-where-conditionsApplying the same operator case normalization here as in evaluate-condition ensures consistent behavior across the codebase.
51-51: Good addition: Support for standard SQL inequality operatorAdding support for the
<>operator as an alternative to!=improves SQL standard compliance, as both notations are commonly used in SQL dialects.
56-57: Consistent implementation of case-insensitive LIKEThe implementation of case-insensitive matching for the LIKE operator here aligns with the changes made in the evaluate-condition function.
59-61: Improved error loggingThe enhanced logging message now clearly indicates that the unsupported operator is in a "where condition," making it easier to debug issues.
…rison
This change ensures consistent behavior when comparing operators regardless of their case (e.g., "LIKE" vs "like") and makes the LIKE operator case-insensitive by default, which is more consistent with standard SQL behavior.
Summary by CodeRabbit