use text() for autocomplete

This commit is contained in:
j 2016-02-26 11:21:16 +05:30
parent 9fd2beb147
commit bdba52185c
2 changed files with 4 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import os
import unicodedata
from sqlalchemy.orm import load_only
from sqlalchemy.sql.expression import text
from sqlalchemy import func
from oxtornado import actions
@ -195,10 +196,10 @@ def autocomplete(data):
if order_by:
for o in order_by:
if o['operator'] != '-': o['operator'] = ''
order_by = ['%(operator)ssort.%(key)s' % o for o in order_by]
order_by = [text('%(operator)ssort.%(key)s' % o) for o in order_by]
add_itemsort = True
else:
order_by = ['-items']
order_by = [text('-items')]
items = query.parse({'query': data.get('query', {})})['qs'].options(load_only('id'))
qs = state.db.session.query(models.Find.value, func.count(models.Find.value).label('items'))

View file

@ -4,6 +4,7 @@
#does not work in sqlite
#from sqlalchemy.sql.expression import nullslast
from sqlalchemy.sql.expression import text
from . import models
import settings
@ -24,7 +25,6 @@ def parse(data):
return query
def order(qs, sort, prefix='sort.'):
from sqlalchemy.sql.expression import text
order_by = []
if len(sort) == 1:
additional_sort = settings.config['user']['ui']['listSort']