Skip to content

Commit a0db1e9

Browse files
NOT IN query updated
1 parent 5484af8 commit a0db1e9

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/sql_data_guard/restriction_verification.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,8 @@ def _verify_restriction(
110110
Returns:
111111
bool: True if the restriction is satisfied, False otherwise.
112112
"""
113-
if isinstance(exp, expr.Not) and isinstance(exp.this, expr.In):
114-
expr_values = [int(val.this) for val in exp.this.expressions] # Convert to int
115-
restriction_values = [
116-
int(val) for val in restriction["values"]
117-
] # Convert to int
118-
119-
# NOT IN should be valid if it only excludes values in the restriction
120-
return all(val in restriction_values for val in expr_values)
113+
if isinstance(exp, expr.Not):
114+
return False
121115

122116
if isinstance(exp, expr.Paren):
123117
return _verify_restriction(restriction, from_table, exp.this)

test/test_sql_guard_updates_unit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,12 @@ def test_not_in_operator(self, config, cnn):
728728
verify_sql_test(
729729
"""SELECT id FROM products1 WHERE id NOT IN (324, 224)""",
730730
config,
731+
errors={
732+
"Missing restriction for table: products1 column: id value: [324, 224]"
733+
},
734+
fix="SELECT id FROM products1 WHERE (NOT id IN (324, 224)) AND id IN (324, 224)",
731735
cnn=cnn,
732-
data=[("325",), ("435",), ("445",)],
736+
data=[],
733737
)
734738

735739
def test_in_operator_with_numeric_values(self, config, cnn):

0 commit comments

Comments
 (0)