Skip to content

Commit b8acb7a

Browse files
*Fix issues with != (#42)
1 parent 023dc77 commit b8acb7a

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

sqlalchemy_kusto/dialect_kql.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,13 @@ def _sql_to_kql_where(where_clause: str) -> str:
521521
where_clause,
522522
flags=re.IGNORECASE,
523523
)
524+
525+
where_clause = re.sub(
526+
r"!=\s*=",
527+
"!=",
528+
where_clause,
529+
flags=re.IGNORECASE,
530+
)
524531
# Handle logical operators 'AND' and 'OR' to ensure the conditions are preserved
525532
# Replace AND with 'and' in KQL
526533
where_clause = re.sub(r"\s+AND\s+", r" and ", where_clause, flags=re.IGNORECASE)

tests/unit/test_dialect_kql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def test_select_from_text():
113113
pytest.param(text('Field1 ILIKE "%123"'), 'Field1 endswith "123"'),
114114
pytest.param(text("Field1 NOT ILIKE '%123'"), """Field1 !endswith '123'"""),
115115
pytest.param(text('Field1 NOT ILIKE "%123"'), 'Field1 !endswith "123"'),
116+
pytest.param(text("Field1 != '1'"), """Field1 != '1'"""),
116117
pytest.param(
117118
Column("Field2", Integer).ilike("abc%"),
118119
"""tolower(["Field2"]) startswith_cs tolower('abc')""",

0 commit comments

Comments
 (0)