While examining the get_value()
code, I noticed that if filters
is a list, it calls get_list()
, and if filters
is a string, dictionary, or integer, it calls engine.get_query()
. However, engine.get_query()
also has handling logic for filters
as a list. Why is that?
It seems that database/query
and model/db_query
have similar functionality, both dealing with doctype
. Why is one using pypika
and the other is not, and why are they written in two different places?
if isinstance(filters, list):
out = self._get_value_for_many_names(
doctype=doctype,
names=filters,
field=fieldname,
order_by=order_by,
debug=debug,
run=run,
pluck=pluck,
distinct=distinct,
limit=limit,
as_dict=as_dict,
)
else:
fields = fieldname
if fieldname != "*":
if isinstance(fieldname, str):
fields = [fieldname]
if (filters is not None) and (filters != doctype or doctype == "DocType"):
try:
if order_by:
order_by = "modified" if order_by == DefaultOrderBy else order_by
out = self._get_values_from_table(
fields=fields,
filters=filters,
doctype=doctype,
as_dict=as_dict,
debug=debug,
order_by=order_by,
update=update,
for_update=for_update,
run=run,
pluck=pluck,
distinct=distinct,
limit=limit,
)