Skip to content

Commit 566c84f

Browse files
committed
fix: improvements
1 parent 5bab31b commit 566c84f

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "query-farm-sql-manipulation"
3-
version = "0.1.5"
3+
version = "0.1.6"
44
description = "A Python library for intelligent SQL predicate manipulation using SQLGlot. This library provides tools to safely remove specific predicates from `SQL WHERE` clauses and filter SQL statements based on column availability."
55
authors = [
66
{ name = "Rusty Conover", email = "rusty@query.farm" }

src/query_farm_sql_manipulation/test_transforms.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ def test_where_clause_extract(sql: str, expected: str) -> None:
159159
"sql, expected",
160160
[
161161
("""v1 >= v1 + 5 and z = 5""", "z = 5"),
162+
("v1 in ('foobar') and z = 5", "v1 IN ('foobar') AND z = 5"),
162163
("""((v1 >= v1 + 5) or t1 = 5) and z = 5""", "(t1 = 5) AND z = 5"),
163164
],
164165
)

src/query_farm_sql_manipulation/transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ def filter_predicates_with_right_side_column_references(
9797

9898
for predicate in where_clause.find_all(sqlglot.expressions.Predicate):
9999
assert predicate is not None
100-
if predicate.right.find(sqlglot.expressions.Column):
100+
if isinstance(predicate, sqlglot.expressions.Binary) and predicate.right.find(
101+
sqlglot.expressions.Column
102+
):
101103
remove_expression_part(predicate)
102104

103105
return statement

0 commit comments

Comments
 (0)