fix: Standard field falsy comparisons in db_query (#32791)

Extends the fix to standard fields. e0f63a928f
This commit is contained in:
Ankush Menat 2025-06-05 09:55:05 +05:30 committed by GitHub
parent 30c5376653
commit ddbaf09125
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View file

@ -885,7 +885,7 @@ from {tables}
df
and (db_type := cstr(frappe.db.type_map.get(df.fieldtype, " ")[0]))
and db_type in ("varchar", "text", "longtext", "smalltext", "json")
):
) or f.fieldname in ("owner", "modified_by", "parent", "parentfield", "parenttype"):
value = cstr(f.value)
fallback = "''"

View file

@ -1202,6 +1202,8 @@ class TestDBQuery(IntegrationTestCase):
self.assertNotIn("\\'", query)
self.assertNotIn("ifnull", query)
self.assertFalse(frappe.get_all("DocField", {"name": None}))
self.assertFalse(frappe.get_all("DocField", {"parent": None}))
self.assertNotIn("0", frappe.get_all("DocField", {"parent": None}, run=0))
def test_ifnull_fallback_types(self):
query = frappe.get_all("DocField", {"fieldname": ("!=", None)}, run=0)