fix: Fixed get_values
This commit is contained in:
parent
22876d9803
commit
25277e02da
1 changed files with 11 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ from frappe.query_builder.functions import Count
|
|||
from frappe.query_builder.functions import Min, Max, Avg, Sum
|
||||
from frappe.query_builder.utils import Column
|
||||
from .query import Query
|
||||
from pypika.terms import PseudoColumn
|
||||
|
||||
|
||||
class Database(object):
|
||||
|
|
@ -521,11 +522,19 @@ class Database(object):
|
|||
return self.get_single_value(*args, **kwargs)
|
||||
|
||||
def _get_values_from_table(self, fields, filters, doctype, as_dict, debug, order_by=None, update=None, for_update=False):
|
||||
field_objects = []
|
||||
for field in fields:
|
||||
if "(" in field or " as " in field:
|
||||
field_objects.append(PseudoColumn(field))
|
||||
else:
|
||||
field_objects.append(field)
|
||||
criterion = self.query.build_conditions(table=doctype, filters=filters, orderby=order_by, for_update=for_update)
|
||||
|
||||
if isinstance(fields, (list, tuple)):
|
||||
query = self.query.build_conditions(table=doctype, filters=filters, orderby=order_by, for_update=for_update).select(*fields)
|
||||
query = criterion.select(*field_objects)
|
||||
else:
|
||||
if fields=="*":
|
||||
query = self.query.build_conditions(table=doctype, filters=filters, orderby=order_by, for_update=for_update).select(fields)
|
||||
query = criterion.select(fields)
|
||||
as_dict = True
|
||||
r = self.sql(query, as_dict=as_dict, debug=debug, update=update)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue