Skip to content

Comments

fix: make odata search case insensitive#225

Merged
vizsatiz merged 2 commits intodevelopfrom
fix/odata-search
Feb 21, 2026
Merged

fix: make odata search case insensitive#225
vizsatiz merged 2 commits intodevelopfrom
fix/odata-search

Conversation

@vishnurk6247
Copy link
Member

@vishnurk6247 vishnurk6247 commented Feb 21, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed the "contains" filter operator to be case-insensitive, allowing searches to match regardless of character case.

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

📝 Walkthrough

Walkthrough

The contains operator in the OData parser's SQL filter builder now performs case-insensitive string matching by wrapping both the database field and comparison parameter with the LOWER() function, changing from direct LIKE comparison to LOWER(field) LIKE LOWER(@param).

Changes

Cohort / File(s) Summary
OData Parser Case-Insensitive Contains
wavefront/server/plugins/datasource/datasource/odata_parser.py
Modified SQLFilterParser.build_comparison method to apply LOWER() function to both operands in contains operator comparisons, enabling case-insensitive string matching for LIKE operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A contains that's gentle, no case does it mind,
LOWER wraps both sides, harmony we find,
From strict to forgiving, the strings now align,
Case-insensitive searching, a fix so fine! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: make odata search case insensitive' directly and clearly summarizes the main change: modifying the OData parser to perform case-insensitive searches by wrapping field comparisons with LOWER() function.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/odata-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
wavefront/server/plugins/datasource/datasource/odata_parser.py (1)

352-353: Consider pre-lowercasing the bound parameter value in Python instead of wrapping with LOWER() in SQL.

The current approach is correct — LOWER(@param) on a constant bound value is evaluated once per query, not per row. However, pre-computing the lowercase in Python simplifies the generated SQL fragment and makes the stored parameter value immediately inspectable/loggable in its final form.

♻️ Proposed simplification
 if operator == 'contains':
     parsed_value = self.parse_value(value)
-    self.params[param_key] = f'%{parsed_value}%'
-    return f'LOWER({field}) {sql_op} LOWER({self.dynamic_var_char}{param_key})'
+    self.params[param_key] = f'%{str(parsed_value).lower()}%'
+    return f'LOWER({field}) {sql_op} {self.dynamic_var_char}{param_key}'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@wavefront/server/plugins/datasource/datasource/odata_parser.py` around lines
352 - 353, The code currently sets self.params[param_key] = f'%{parsed_value}%'
and generates SQL using LOWER({field}) {sql_op}
LOWER({self.dynamic_var_char}{param_key}); change this so the parameter value is
lowercased in Python (e.g., set self.params[param_key] =
f'%{parsed_value.lower()}%') and remove the LOWER() wrapper around the bound
parameter in the returned fragment (leave LOWER({field}) {sql_op}
{self.dynamic_var_char}{param_key}); update the logic in the method that assigns
self.params and returns the SQL fragment (refer to self.params, param_key,
parsed_value, dynamic_var_char, field, sql_op) so stored parameters are
pre-lowercased and the generated SQL is simplified.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@wavefront/server/plugins/datasource/datasource/odata_parser.py`:
- Around line 352-353: The code currently sets self.params[param_key] =
f'%{parsed_value}%' and generates SQL using LOWER({field}) {sql_op}
LOWER({self.dynamic_var_char}{param_key}); change this so the parameter value is
lowercased in Python (e.g., set self.params[param_key] =
f'%{parsed_value.lower()}%') and remove the LOWER() wrapper around the bound
parameter in the returned fragment (leave LOWER({field}) {sql_op}
{self.dynamic_var_char}{param_key}); update the logic in the method that assigns
self.params and returns the SQL fragment (refer to self.params, param_key,
parsed_value, dynamic_var_char, field, sql_op) so stored parameters are
pre-lowercased and the generated SQL is simplified.

@vizsatiz vizsatiz merged commit 818e517 into develop Feb 21, 2026
10 checks passed
@vizsatiz vizsatiz deleted the fix/odata-search branch February 21, 2026 16:10
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.

2 participants