diff --git a/frappe/database.py b/frappe/database.py index b568842ffc..2b1737138a 100644 --- a/frappe/database.py +++ b/frappe/database.py @@ -15,6 +15,7 @@ import frappe.model.meta from frappe.utils import now, get_datetime, cstr, cast_fieldtype from frappe import _ from frappe.model.utils.link_count import flush_local_link_count +from frappe.model.utils import STANDARD_FIELD_CONVERSION_MAP from frappe.utils.background_jobs import execute_job, get_queue from frappe import as_unicode import six @@ -44,6 +45,9 @@ def _cast_result(doctype, result): df = frappe.get_meta(doctype).get_field(field) if df: value = cast_fieldtype(df.fieldtype, value) + else: + if field in STANDARD_FIELD_CONVERSION_MAP: + value = cast_fieldtype(STANDARD_FIELD_CONVERSION_MAP[field], value) batch.append(tuple([field, value])) except frappe.exceptions.DoesNotExistError: diff --git a/frappe/model/utils/__init__.py b/frappe/model/utils/__init__.py index a148ff2f4b..1bb517c2f2 100644 --- a/frappe/model/utils/__init__.py +++ b/frappe/model/utils/__init__.py @@ -11,6 +11,19 @@ from six import text_type import io +STANDARD_FIELD_CONVERSION_MAP = { + 'name': 'Link', + 'owner': 'Data', + 'idx': 'Int', + 'creation': 'Date', + 'modified': 'Date', + 'modified_by': 'Data', + '_user_tags': 'Data', + '_liked_by': 'Data', + '_comments': 'Text', + '_assign': 'Text', + 'docstatus': 'Int' +} """ Model utilities, unclassified functions