Skip to content

Commit

Permalink
fix: Change in condition builder
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSaiyyamChhetri authored and IamSaiyyamChhetri committed Oct 22, 2024
1 parent 198f7bf commit 96f2765
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions frappe/model/db_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,16 +840,20 @@ def prepare_filter_condition(self, f):

elif f.operator.lower() == "is":
if f.value == "set":
f.operator = "!="
f.operator = "IS NOT NULL" if frappe.conf.db_type == "postgres" else "!="
# Value can technically be null, but comparing with null will always be falsy
# Not using coalesce here is faster because indexes can be used.
# null != '' -> null ~ falsy
# '' != '' -> false
can_be_null = False
elif f.value == "not set":
f.operator = "="
fallback = "''"
can_be_null = True
elif f.value == "not set":
if frappe.conf.db_type == "postgres":
f.operator = "IS NULL"
can_be_null = False
else:
f.operator = "="
fallback = "''"
can_be_null = True

value = ""

Expand Down Expand Up @@ -897,7 +901,7 @@ def prepare_filter_condition(self, f):
value = f"{tname}.{quote}{f.value.name}{quote}"

# escape value
elif escape and isinstance(value, str):
elif escape and isinstance(value, str) and frappe.conf.db_type != "postgres":
value = f"{frappe.db.escape(value, percent=False)}"

if (
Expand Down

0 comments on commit 96f2765

Please sign in to comment.