Skip to content

test: verify LIKE filter in update queries uses parameterized values#2124

Open
Br1an67 wants to merge 1 commit intotortoise:developfrom
Br1an67:fix/like-percent-escape
Open

test: verify LIKE filter in update queries uses parameterized values#2124
Br1an67 wants to merge 1 commit intotortoise:developfrom
Br1an67:fix/like-percent-escape

Conversation

@Br1an67
Copy link
Contributor

@Br1an67 Br1an67 commented Mar 1, 2026

Summary

Adds a regression test for #1225.

The LIKE pattern generated by contains() / startswith() / endswith() filters is passed as a parameterized query value (not rendered inline in the SQL template). This means the % wildcards in the LIKE pattern never conflict with the MySQL driver's %s parameter substitution.

The test verifies the correct parameterized SQL for all four backends:

  • MySQL: LIKE %s
  • PostgreSQL asyncpg: LIKE $2 ESCAPE '\\'
  • PostgreSQL psycopg: LIKE %s ESCAPE '\\'
  • SQLite: LIKE ? ESCAPE '\\'

Fixes #1225

@codspeed-hq
Copy link

codspeed-hq bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing Br1an67:fix/like-percent-escape (f91bb39) with develop (f566e97)

Open in CodSpeed

@abondar
Copy link
Member

abondar commented Mar 3, 2026

Test seems to be failing

Add a regression test for issue tortoise#1225. The LIKE pattern from contains()
filter is passed as a parameterized query value (not rendered inline),
so the % wildcards never conflict with MySQL driver's %s parameter
substitution.

Fixes tortoise#1225
@Br1an67 Br1an67 force-pushed the fix/like-percent-escape branch from 67b7310 to f91bb39 Compare March 3, 2026 15:32
@Br1an67 Br1an67 changed the title fix: escape % in MySQL StrWrapper to prevent conflict with %s parameter placeholders test: verify LIKE filter in update queries uses parameterized values Mar 3, 2026
@abondar
Copy link
Member

abondar commented Mar 3, 2026

I lost track of this PR's sense - it now just adds test? Logic that it should have fixed actually works properly? Or why issue originally arised?

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.

Fuzzy filter function translation to sql not escaping "%" in LIKE clause for update operations

2 participants