本文整理匯總了Python中frappe.model.db_query.DatabaseQuery.filters方法的典型用法代碼示例。如果您正苦於以下問題:Python DatabaseQuery.filters方法的具體用法?Python DatabaseQuery.filters怎麽用?Python DatabaseQuery.filters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類frappe.model.db_query.DatabaseQuery
的用法示例。
在下文中一共展示了DatabaseQuery.filters方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_filters_cond
# 需要導入模塊: from frappe.model.db_query import DatabaseQuery [as 別名]
# 或者: from frappe.model.db_query.DatabaseQuery import filters [as 別名]
def get_filters_cond(doctype, filters, conditions, ignore_permissions=None, with_match_conditions=False):
if isinstance(filters, string_types):
filters = json.loads(filters)
if filters:
flt = filters
if isinstance(filters, dict):
filters = filters.items()
flt = []
for f in filters:
if isinstance(f[1], string_types) and f[1][0] == '!':
flt.append([doctype, f[0], '!=', f[1][1:]])
elif isinstance(f[1], (list, tuple)) and \
f[1][0] in (">", "<", ">=", "<=", "like", "not like", "in", "not in", "between"):
flt.append([doctype, f[0], f[1][0], f[1][1]])
else:
flt.append([doctype, f[0], '=', f[1]])
query = DatabaseQuery(doctype)
query.filters = flt
query.conditions = conditions
if with_match_conditions:
query.build_match_conditions()
query.build_filter_conditions(flt, conditions, ignore_permissions)
cond = ' and ' + ' and '.join(query.conditions)
else:
cond = ''
return cond
示例2: get_filters_cond
# 需要導入模塊: from frappe.model.db_query import DatabaseQuery [as 別名]
# 或者: from frappe.model.db_query.DatabaseQuery import filters [as 別名]
def get_filters_cond(doctype, filters, conditions):
if filters:
if isinstance(filters, dict):
filters = filters.items()
flt = []
for f in filters:
if isinstance(f[1], basestring) and f[1][0] == '!':
flt.append([doctype, f[0], '!=', f[1][1:]])
else:
flt.append([doctype, f[0], '=', f[1]])
query = DatabaseQuery(doctype)
query.filters = flt
query.conditions = conditions
query.build_filter_conditions(flt, conditions)
cond = ' and ' + ' and '.join(query.conditions)
else:
cond = ''
return cond
示例3: get_filters_cond
# 需要導入模塊: from frappe.model.db_query import DatabaseQuery [as 別名]
# 或者: from frappe.model.db_query.DatabaseQuery import filters [as 別名]
def get_filters_cond(doctype, filters, conditions):
if filters:
flt = filters
if isinstance(filters, dict):
filters = filters.items()
flt = []
for f in filters:
if isinstance(f[1], basestring) and f[1][0] == "!":
flt.append([doctype, f[0], "!=", f[1][1:]])
else:
flt.append([doctype, f[0], "=", f[1]])
query = DatabaseQuery(doctype)
query.filters = flt
query.conditions = conditions
query.build_filter_conditions(flt, conditions)
cond = " and " + " and ".join(query.conditions)
else:
cond = ""
return cond