From 69e655d08b89ee02772b63a4a29a33b2a046dbd5 Mon Sep 17 00:00:00 2001 From: Prathamesh Kurunkar <59260326+prathameshkurunkar7@users.noreply.github.com> Date: Mon, 16 Feb 2026 20:28:38 +0530 Subject: [PATCH] fix(db): support list of fields in get_value method when cache is True (#37050) * fix(db): support list of fields in get_value method when cache is True * test(db): ensure cache hit does not execute db query --- frappe/database/database.py | 3 +++ frappe/tests/test_db.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/frappe/database/database.py b/frappe/database/database.py index 14f2a40c8e..2b3e43422f 100644 --- a/frappe/database/database.py +++ b/frappe/database/database.py @@ -634,6 +634,9 @@ class Database: from frappe.model.utils import is_single_doctype out = None + if isinstance(fieldname, list): + fieldname = tuple(fieldname) + if cache and isinstance(filters, str) and fieldname in self.value_cache[doctype][filters]: return self.value_cache[doctype][filters][fieldname] diff --git a/frappe/tests/test_db.py b/frappe/tests/test_db.py index 0f057a36a9..94b112eb31 100644 --- a/frappe/tests/test_db.py +++ b/frappe/tests/test_db.py @@ -138,6 +138,14 @@ class TestDB(IntegrationTestCase): frappe.db.get_value("DocType", "DocField", order_by="creation desc, modified asc, name", run=0), ) + # Test with list of fields and cache=True + result = frappe.db.get_value("User", "Administrator", ["name", "email"], cache=True) + self.assertEqual(result, ("Administrator", "admin@example.com")) + # Verify cache hit - second call should not execute any queries + with self.assertQueryCount(0): + cached_result = frappe.db.get_value("User", "Administrator", ["name", "email"], cache=True) + self.assertEqual(result, cached_result) + def test_escape(self): frappe.db.escape("香港濟生堂製藥有限公司 - IT".encode())