-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: Translating ILIKE and NOT ILIKE operators to LIKE and NOT LIKE * test: Testing ILIKE and NOT ILIKE translation
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from sqlalchemy import select | ||
from tests.setup import prepare_orm | ||
|
||
|
||
class TestOperatorTranslation: | ||
|
||
def test_ilike_operator_translation(self, settings): | ||
engine, t = prepare_orm(settings) | ||
|
||
select_statement_1 = ( | ||
"SELECT sales_test_.`CITY_s` \nFROM sales_test_ " | ||
"\nWHERE sales_test_.`CITY_s` LIKE ?\n LIMIT ?" | ||
) | ||
|
||
qry = (select(t.c.CITY_s).where(t.c.CITY_s.ilike("%york%"))).limit( | ||
1 | ||
) # pylint: disable=unsubscriptable-object | ||
|
||
with engine.connect() as connection: | ||
result = connection.execute(qry) | ||
|
||
assert result.context.statement == select_statement_1 | ||
|
||
def test_not_ilike_operator_translation(self, settings): | ||
engine, t = prepare_orm(settings) | ||
|
||
select_statement_1 = ( | ||
"SELECT sales_test_.`CITY_s` \nFROM sales_test_ " | ||
"\nWHERE sales_test_.`CITY_s` NOT LIKE ?\n LIMIT ?" | ||
) | ||
|
||
qry = (select(t.c.CITY_s).where(t.c.CITY_s.notilike("%york%"))).limit( | ||
1 | ||
) # pylint: disable=unsubscriptable-object | ||
|
||
with engine.connect() as connection: | ||
result = connection.execute(qry) | ||
|
||
assert result.context.statement == select_statement_1 |