@@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json | |||||
from .exceptions import * | from .exceptions import * | ||||
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template | from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template | ||||
__version__ = '8.6.6' | |||||
__version__ = '8.6.7' | |||||
__title__ = "Frappe Framework" | __title__ = "Frappe Framework" | ||||
local = Local() | local = Local() | ||||
@@ -600,8 +600,9 @@ class Database: | |||||
order_by = ("order by " + order_by) if order_by else "" | order_by = ("order by " + order_by) if order_by else "" | ||||
r = self.sql("select {0} from `tab{1}` where {2} {3}".format(fl, doctype, | |||||
conditions, order_by), values, as_dict=as_dict, debug=debug, update=update) | |||||
r = self.sql("select {0} from `tab{1}` {2} {3} {4}" | |||||
.format(fl, doctype, "where" if conditions else "", conditions, order_by), values, | |||||
as_dict=as_dict, debug=debug, update=update) | |||||
return r | return r | ||||
@@ -241,7 +241,12 @@ def get_stats(stats, doctype, filters=[]): | |||||
filters = json.loads(filters) | filters = json.loads(filters) | ||||
stats = {} | stats = {} | ||||
columns = frappe.db.get_table_columns(doctype) | |||||
try: | |||||
columns = frappe.db.get_table_columns(doctype) | |||||
except MySQLdb.OperationalError: | |||||
# raised when _user_tags column is added on the fly | |||||
columns = [] | |||||
for tag in tags: | for tag in tags: | ||||
if not tag in columns: continue | if not tag in columns: continue | ||||
try: | try: | ||||
@@ -8,19 +8,21 @@ import frappe | |||||
# For example Journal Entry should be validated before GL Entry (which is an internal doctype) | # For example Journal Entry should be validated before GL Entry (which is an internal doctype) | ||||
dynamic_link_queries = [ | dynamic_link_queries = [ | ||||
"""select parent, | |||||
(select read_only from `tabDocType` where name=tabDocField.parent) as read_only, | |||||
fieldname, options | |||||
from tabDocField | |||||
where fieldtype='Dynamic Link' | |||||
order by read_only""", | |||||
"""select dt as parent, | |||||
(select read_only from `tabDocType` where name=`tabCustom Field`.dt) as read_only, | |||||
fieldname, options | |||||
from `tabCustom Field` | |||||
where fieldtype='Dynamic Link' | |||||
order by read_only""", | |||||
"""select tabDocField.parent, | |||||
`tabDocType`.read_only, `tabDocType`.in_create, | |||||
tabDocField.fieldname, tabDocField.options | |||||
from tabDocField, `tabDocType` | |||||
where `tabDocField`.fieldtype='Dynamic Link' and | |||||
`tabDocType`.name=`tabDocField`.parent | |||||
order by `tabDocType`.read_only, `tabDocType`.in_create""", | |||||
"""select `tabCustom Field`.dt as parent, | |||||
`tabDocType`.read_only, `tabDocType`.in_create, | |||||
`tabCustom Field`.fieldname, `tabCustom Field`.options | |||||
from `tabCustom Field`, `tabDocType` | |||||
where `tabCustom Field`.fieldtype='Dynamic Link' and | |||||
`tabDocType`.name=`tabCustom Field`.dt | |||||
order by `tabDocType`.read_only, `tabDocType`.in_create""", | |||||
] | ] | ||||
def get_dynamic_link_map(for_delete=False): | def get_dynamic_link_map(for_delete=False): | ||||