當前位置: 首頁>>代碼示例>>Python>>正文


Python DatabaseQuery.conditions方法代碼示例

本文整理匯總了Python中frappe.model.db_query.DatabaseQuery.conditions方法的典型用法代碼示例。如果您正苦於以下問題:Python DatabaseQuery.conditions方法的具體用法?Python DatabaseQuery.conditions怎麽用?Python DatabaseQuery.conditions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在frappe.model.db_query.DatabaseQuery的用法示例。


在下文中一共展示了DatabaseQuery.conditions方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_filters_cond

# 需要導入模塊: from frappe.model.db_query import DatabaseQuery [as 別名]
# 或者: from frappe.model.db_query.DatabaseQuery import conditions [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
開發者ID:saurabh6790,項目名稱:frappe,代碼行數:34,代碼來源:reportview.py

示例2: get_filters_cond

# 需要導入模塊: from frappe.model.db_query import DatabaseQuery [as 別名]
# 或者: from frappe.model.db_query.DatabaseQuery import conditions [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
開發者ID:David-Duarte,項目名稱:erpnext,代碼行數:22,代碼來源:queries.py

示例3: get_filters_cond

# 需要導入模塊: from frappe.model.db_query import DatabaseQuery [as 別名]
# 或者: from frappe.model.db_query.DatabaseQuery import conditions [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
開發者ID:RicardoJohann,項目名稱:erpnext,代碼行數:23,代碼來源:queries.py


注:本文中的frappe.model.db_query.DatabaseQuery.conditions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。