fix: add permission conditions to where clause instead of join

This commit is contained in:
Sagar Vora 2026-01-05 19:02:04 +05:30 committed by GitHub
parent 27f104bba6
commit 9a774de21e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1833,13 +1833,11 @@ class LinkTableField(DynamicTableField):
table = frappe.qb.DocType(self.doctype)
main_table = frappe.qb.DocType(self.parent_doctype)
if not query.is_joined(table):
clause = table.name == getattr(main_table, self.link_fieldname)
query = query.left_join(table).on(table.name == getattr(main_table, self.link_fieldname))
if engine and engine.apply_permissions:
if condition := engine.get_permission_conditions(self.doctype, table):
clause &= condition
query = query.where(condition)
query = query.left_join(table).on(clause)
return query