perf: avoid coalescing wherever possible (#17920)

This commit is contained in:
Ankush Menat 2022-08-24 10:30:51 +05:30 committed by GitHub
parent 5a0b854700
commit cdb0732646
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -612,6 +612,9 @@ 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)
values = f.value or ""
if isinstance(values, str):
values = values.split(",")

View file

@ -831,6 +831,11 @@ class TestReportview(FrappeTestCase):
self.assertTrue(dashboard_settings)
def test_coalesce_with_in_ops(self):
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))
def add_child_table_to_blog_post():
child_table = frappe.get_doc(