Change order args are created for datatable query

* Make sure search filter args are created after custom_where
This commit is contained in:
Jonathan Wong 2015-10-18 13:29:29 -07:00
parent be753983fe
commit c4dc81e8fb

View file

@ -70,6 +70,39 @@ class DataTables(object):
else: else:
grouping = False grouping = False
# Build join parameters
if join_types:
counter = 0
for join_type in join_types:
if join_type.upper() == 'LEFT OUTER JOIN':
join_item = 'LEFT OUTER JOIN %s ON %s = %s ' % \
(join_tables[counter], join_evals[counter][0], join_evals[counter][1])
elif join_type.upper() == 'JOIN' or join_type.upper() == 'INNER JOIN':
join_item = 'JOIN %s ON %s = %s ' % \
(join_tables[counter], join_evals[counter][0], join_evals[counter][1])
else:
join_item = ''
counter += 1
join += join_item
# Build custom where parameters
if custom_where:
for w in custom_where:
c_where += w[0] + ' = ? AND '
# The order of our args changes if we are grouping
#if grouping:
# args.insert(0, w[1])
#else:
# args.append(w[1])
# My testing shows that order of args doesn't change
args.append(w[1])
if c_where:
c_where = 'WHERE ' + c_where.rstrip(' AND ')
# Build ordering # Build ordering
for o in parameters['order']: for o in parameters['order']:
sort_order = ' COLLATE NOCASE' sort_order = ' COLLATE NOCASE'
@ -119,39 +152,6 @@ class DataTables(object):
if where: if where:
where = 'WHERE ' + where.rstrip(' OR ') where = 'WHERE ' + where.rstrip(' OR ')
# Build join parameters
if join_types:
counter = 0
for join_type in join_types:
if join_type.upper() == 'LEFT OUTER JOIN':
join_item = 'LEFT OUTER JOIN %s ON %s = %s ' % \
(join_tables[counter], join_evals[counter][0], join_evals[counter][1])
elif join_type.upper() == 'JOIN' or join_type.upper() == 'INNER JOIN':
join_item = 'JOIN %s ON %s = %s ' % \
(join_tables[counter], join_evals[counter][0], join_evals[counter][1])
else:
join_item = ''
counter += 1
join += join_item
# Build custom where parameters
if custom_where:
for w in custom_where:
c_where += w[0] + ' = ? AND '
# The order of our args changes if we are grouping
#if grouping:
# args.insert(0, w[1])
#else:
# args.append(w[1])
# My testing shows that order of args doesn't change
args.append(w[1])
if c_where:
c_where = 'WHERE ' + c_where.rstrip(' AND ')
# Build our queries # Build our queries
if grouping: if grouping:
if c_where == '': if c_where == '':