fix(db_query): double-escaped value (#32376)

This commit is contained in:
Ankush Menat 2025-05-02 11:09:11 +05:30 committed by GitHub
parent 479c304eae
commit 42f1d1b460
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View file

@ -882,11 +882,11 @@ class DatabaseQuery:
value = value.replace("\\", "\\\\").replace("%", "%%")
elif f.operator == "=" and df and df.fieldtype in ("Link", "Data", "Dynamic Link"):
value = cstr(f.value) or "''"
value = cstr(f.value)
fallback = "''"
elif f.fieldname == "name":
value = f.value or "''"
value = f.value
fallback = "''"
else:

View file

@ -1196,6 +1196,11 @@ class TestDBQuery(IntegrationTestCase):
self.assertEqual(count[0], frappe.db.count("Language"))
self.assertEqual(count[1], frappe.db.count("Language"))
def test_ifnull_none(self):
query = frappe.get_all("DocField", {"fieldname": None}, run=0)
self.assertIn("''", query)
self.assertNotIn("\\'", query)
class TestReportView(IntegrationTestCase):
@run_only_if(db_type_is.MARIADB) # TODO: postgres name casting is messed up