fix(query): don't allow using Document as a filter value (#34823)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-11-24 11:13:43 +05:30 committed by GitHub
parent 5fecde5a6a
commit bd044e520c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ from frappe.database.utils import (
)
from frappe.model import get_permitted_fields
from frappe.model.base_document import DOCTYPES_FOR_DOCTYPE
from frappe.model.document import Document
from frappe.query_builder import Criterion, Field, Order, functions
from frappe.query_builder.custom import Month, MonthName, Quarter
from frappe.query_builder.utils import PseudoColumnMapper
@ -454,6 +455,9 @@ class Engine:
else:
# Regular value processing for literal comparisons like: table.field = 'value'
_value = convert_to_value(value)
if isinstance(value, Document):
frappe.throw(_("Document cannot be used as a filter value"))
_operator = operator
# For Date fields with datetime values, convert to date to match db_query behavior