[fix] ignore ifnull for filter queries
This commit is contained in:
parent
f632d674ac
commit
11f2e4293b
2 changed files with 10 additions and 6 deletions
|
|
@ -89,7 +89,7 @@ def get_notifications_for_doctypes(config, notification_count):
|
|||
try:
|
||||
if isinstance(condition, dict):
|
||||
result = len(frappe.get_list(d, fields=["name"],
|
||||
filters=condition, limit_page_length = 21, as_list=True))
|
||||
filters=condition, limit_page_length = 21, as_list=True, ignore_ifnull=True))
|
||||
else:
|
||||
result = frappe.get_attr(condition)()
|
||||
|
||||
|
|
@ -195,11 +195,11 @@ def get_open_count(doctype, name):
|
|||
# we only need open documents related to the current document
|
||||
filters[fieldname] = name
|
||||
total = len(frappe.get_all(doctype, fields='name',
|
||||
filters=filters, limit_page_length=6, distinct=True))
|
||||
filters=filters, limit=6, distinct=True, ignore_ifnull=True))
|
||||
data['open_count'] = total
|
||||
|
||||
total = len(frappe.get_all(doctype, fields='name',
|
||||
filters={fieldname: name}, limit_page_length=10, distinct=True))
|
||||
filters={fieldname: name}, limit=10, distinct=True, ignore_ifnull=True))
|
||||
data['count'] = total
|
||||
out.append(data)
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class DatabaseQuery(object):
|
|||
docstatus=None, group_by=None, order_by=None, limit_start=False,
|
||||
limit_page_length=None, as_list=False, with_childnames=False, debug=False,
|
||||
ignore_permissions=False, user=None, with_comment_count=False,
|
||||
join='left join', distinct=False, start=None, page_length=None, limit=None):
|
||||
join='left join', distinct=False, start=None, page_length=None, limit=None, ignore_ifnull=False):
|
||||
if not ignore_permissions and not frappe.has_permission(self.doctype, "read", user=user):
|
||||
raise frappe.PermissionError, self.doctype
|
||||
|
||||
|
|
@ -265,8 +265,12 @@ class DatabaseQuery(object):
|
|||
values = (frappe.db.escape(v.strip(), percent=False) for v in values)
|
||||
values = '("{0}")'.format('", "'.join(values))
|
||||
|
||||
condition = 'ifnull({tname}.{fname}, "") {operator} {value}'.format(
|
||||
tname=tname, fname=f.fieldname, operator=f.operator, value=values)
|
||||
if self.ignore_ifnull:
|
||||
condition = '{tname}.{fname} {operator} {value}'.format(
|
||||
tname=tname, fname=f.fieldname, operator=f.operator, value=values)
|
||||
else:
|
||||
condition = 'ifnull({tname}.{fname}, "") {operator} {value}'.format(
|
||||
tname=tname, fname=f.fieldname, operator=f.operator, value=values)
|
||||
|
||||
else:
|
||||
df = frappe.get_meta(f.doctype).get("fields", {"fieldname": f.fieldname})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue