perf: avoid coalescing wherever possible (#17920)
This commit is contained in:
parent
5a0b854700
commit
cdb0732646
2 changed files with 8 additions and 0 deletions
|
|
@ -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(",")
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue