fix: coalesce not in queries (#18099)
* fix: get workspaces with empty module fields * Revert "fix: get workspaces with empty module fields" This reverts commit 1f194be2c3642e31ebe2165e461b2f24be8cda4c. * fix: always coalesce `not in` queries Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
parent
931e91be3d
commit
235171796d
2 changed files with 8 additions and 1 deletions
|
|
@ -613,7 +613,10 @@ class DatabaseQuery:
|
|||
|
||||
elif f.operator.lower() in ("in", "not in"):
|
||||
# if values contain '' or falsy values then only coalesce column
|
||||
can_be_null = not f.value or any(v is None or v == "" for v in f.value)
|
||||
# for `in` query this is only required if values contain '' or values are empty.
|
||||
# for `not in` queries we can't be sure as column values might contain null.
|
||||
if f.operator.lower() == "in":
|
||||
can_be_null = not f.value or any(v is None or v == "" for v in f.value)
|
||||
|
||||
values = f.value or ""
|
||||
if isinstance(values, str):
|
||||
|
|
|
|||
|
|
@ -835,6 +835,10 @@ class TestReportview(FrappeTestCase):
|
|||
self.assertNotIn("ifnull", frappe.get_all("User", {"name": ("in", ["a", "b"])}, run=0))
|
||||
self.assertIn("ifnull", frappe.get_all("User", {"name": ("in", ["a", None])}, run=0))
|
||||
self.assertIn("ifnull", frappe.get_all("User", {"name": ("in", ["a", ""])}, run=0))
|
||||
self.assertIn("ifnull", frappe.get_all("User", {"name": ("in", [])}, run=0))
|
||||
self.assertIn("ifnull", frappe.get_all("User", {"name": ("not in", ["a"])}, run=0))
|
||||
self.assertIn("ifnull", frappe.get_all("User", {"name": ("not in", [])}, run=0))
|
||||
self.assertIn("ifnull", frappe.get_all("User", {"name": ("not in", [""])}, run=0))
|
||||
|
||||
|
||||
def add_child_table_to_blog_post():
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue