bito-code-review[bot] commented on code in PR #40980:
URL: https://github.com/apache/superset/pull/40980#discussion_r3398499368
##########
tests/unit_tests/reports/filters_test.py:
##########
@@ -62,3 +62,47 @@ def test_report_schedule_all_text_filter_applies_ilike() ->
None:
f = ReportScheduleAllTextFilter("name", MagicMock())
f.apply(query, "test")
query.filter.assert_called_once()
+
+
+@patch("superset.reports.filters.or_")
+@patch("superset.reports.filters.ReportSchedule")
+def test_report_schedule_all_text_filter_escapes_wildcards(
+ mock_report_schedule: MagicMock, mock_or: MagicMock
+) -> None:
+ """User-supplied wildcards must be escaped so they match literally."""
+ from superset.reports.filters import ReportScheduleAllTextFilter
+
+ query = MagicMock()
+ f = ReportScheduleAllTextFilter("name", MagicMock())
+ # raw input contains every LIKE special character plus a backslash
+ f.apply(query, "50%_off\\promo")
+
+ # %, _ and \ are all escaped, and the literal is wrapped for a "contains"
match
+ expected = "%50\\%\\_off\\\\promo%"
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Test expectation incorrect</b></div>
<div id="fix">
The `_escape_like` function (filters.py:33) doubles each backslash once via
`value.replace("\\", "\\\\")`, so a single `\` in input becomes `\\` in output.
The test expectation has `\\\\` (four backslashes) before `promo` but the
implementation produces `\\` (two backslashes). This test will fail at runtime.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
--- a/tests/unit_tests/reports/filters_test.py
+++ b/tests/unit_tests/reports/filters_test.py
@@ -81 +81 @@
- expected = "%50\\%\\_off\\\\promo%"
+ expected = "%50\\%\\_off\\promo%"
```
</div>
</details>
</div>
<small><i>Code Review Run #27ed6d</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]