Avoid multiple escapes (#15509)

This commit is contained in:
Suraj Shetty 2018-09-27 15:39:34 +05:30 committed by Nabin Hait
parent 6ea3de9521
commit 4b404c4f1e
6 changed files with 23 additions and 17 deletions

View File

@ -208,9 +208,8 @@ def bom(doctype, txt, searchfield, start, page_len, filters):
limit %(start)s, %(page_len)s """.format(
fcond=get_filters_cond(doctype, filters, conditions),
mcond=get_match_cond(doctype),
key=searchfield),
{
'txt': frappe.db.escape('%' + txt + '%'),
key=searchfield), {
'txt': '%' + txt + '%',
'_txt': txt.replace("%", ""),
'start': start or 0,
'page_len': page_len or 20
@ -353,7 +352,7 @@ def get_income_account(doctype, txt, searchfield, start, page_len, filters):
{condition} {match_condition}
order by idx desc, name"""
.format(condition=condition, match_condition=get_match_cond(doctype), key=searchfield), {
'txt': frappe.db.escape('%' + txt + '%'),
'txt': '%' + txt + '%',
'company': filters.get("company", "")
})
@ -378,7 +377,7 @@ def get_expense_account(doctype, txt, searchfield, start, page_len, filters):
.format(condition=condition, key=searchfield,
match_condition=get_match_cond(doctype)), {
'company': filters.get("company", ""),
'txt': frappe.db.escape('%' + txt + '%')
'txt': '%' + txt + '%'
})

View File

@ -166,10 +166,13 @@ def get_project(doctype, txt, searchfield, start, page_len, filters):
where %(key)s like %(txt)s
%(mcond)s
order by name
limit %(start)s, %(page_len)s """ % {'key': searchfield,
'txt': frappe.db.escape('%' + txt + '%'),
'mcond':get_match_cond(doctype),
'start': start, 'page_len': page_len})
limit %(start)s, %(page_len)s""" % {
'key': searchfield,
'txt': frappe.db.escape('%' + txt + '%'),
'mcond':get_match_cond(doctype),
'start': start,
'page_len': page_len
})
@frappe.whitelist()

View File

@ -223,7 +223,7 @@ def get_timesheet(doctype, txt, searchfield, start, page_len, filters):
and tsd.parent LIKE %(txt)s {condition}
order by tsd.parent limit %(start)s, %(page_len)s"""
.format(condition=condition), {
'txt': frappe.db.escape('%' + txt + '%'),
'txt': '%' + txt + '%',
"start": start, "page_len": page_len, 'project': filters.get("project")
})

View File

@ -60,11 +60,15 @@ def get_items(start, page_length, price_list, item_group, search_value="", pos_p
where
i.disabled = 0 and i.has_variants = 0 and i.is_sales_item = 1
and i.item_group in (select name from `tabItem Group` where lft >= {lft} and rgt <= {rgt})
and {condition} limit {start}, {page_length}""".format(start=start,page_length=page_length,lft=lft, rgt=rgt, condition=condition),
{
'item_code': item_code,
and {condition} limit {start}, {page_length}""".format(
start=start,
page_length=page_length,
lft=lft,
rgt=rgt,
condition=condition
), {
'price_list': price_list
} , as_dict=1)
}, as_dict=1)
res = {
'items': res

View File

@ -20,6 +20,6 @@ def get_party_type(doctype, txt, searchfield, start, page_len, filters):
where `{key}` LIKE %(txt)s {cond}
order by name limit %(start)s, %(page_len)s"""
.format(key=searchfield, cond=cond), {
'txt': frappe.db.escape('%' + txt + '%'),
'txt': '%' + txt + '%',
'start': start, 'page_len': page_len
})

View File

@ -35,6 +35,6 @@ def get_alternative_items(doctype, txt, searchfield, start, page_len, filters):
where alternative_item_code = %(item_code)s and item_code like %(txt)s
and two_way = 1) limit {0}, {1}
""".format(start, page_len), {
"item_code": frappe.db.escape(filters.get('item_code')),
"txt": frappe.db.escape('%' + txt + '%')
"item_code": filters.get('item_code'),
"txt": '%' + txt + '%'
})