@@ -152,8 +152,8 @@ def prep_value(k, v):
152
152
return f'{ k } ="{ v } "'
153
153
return f"{ k } ={ v } "
154
154
155
- def join_conditions (negate , restrictions , operator = "AND" ):
156
- return ("NOT (%s) " if negate else "%s" ) % (
155
+ def combine_conditions (negate , restrictions , operator = "AND" ):
156
+ return ("NOT %s " if negate else "%s" ) % (
157
157
f"({ f') { operator } (' .join (restrictions )} )"
158
158
)
159
159
@@ -165,7 +165,7 @@ def join_conditions(negate, restrictions, operator="AND"):
165
165
# restrict by string
166
166
if isinstance (condition , str ):
167
167
columns .update (extract_column_names (condition ))
168
- return join_conditions (
168
+ return combine_conditions (
169
169
negate , restrictions = [condition .strip ().replace ("%" , "%%" )]
170
170
) # escape %, see issue #376
171
171
@@ -183,7 +183,7 @@ def join_conditions(negate, restrictions, operator="AND"):
183
183
return negate # if any item is False, the whole thing is False
184
184
if not items :
185
185
return not negate # and empty AndList is True
186
- return join_conditions (negate , restrictions = items )
186
+ return combine_conditions (negate , restrictions = items )
187
187
188
188
# restriction by dj.U evaluates to True
189
189
if isinstance (condition , U ):
@@ -201,7 +201,7 @@ def join_conditions(negate, restrictions, operator="AND"):
201
201
if not common_attributes :
202
202
return not negate # no matching attributes -> evaluates to True
203
203
columns .update (common_attributes )
204
- return join_conditions (
204
+ return combine_conditions (
205
205
negate ,
206
206
restrictions = [
207
207
prep_value (k , v )
@@ -218,7 +218,7 @@ def join_conditions(negate, restrictions, operator="AND"):
218
218
if not common_attributes :
219
219
return not negate # no matching attributes -> evaluate to True
220
220
columns .update (common_attributes )
221
- return join_conditions (
221
+ return combine_conditions (
222
222
negate ,
223
223
restrictions = [prep_value (k , condition [k ]) for k in common_attributes ],
224
224
)
@@ -269,7 +269,7 @@ def join_conditions(negate, restrictions, operator="AND"):
269
269
if any (item is True for item in or_list ): # if any item is True, entirely True
270
270
return not negate
271
271
return (
272
- join_conditions (negate , restrictions = or_list , operator = "OR" )
272
+ combine_conditions (negate , restrictions = or_list , operator = "OR" )
273
273
if or_list
274
274
else negate
275
275
)
0 commit comments