Permalink
Browse files

add db expression support to db.search order

  • Loading branch information...
1 parent 2158ad7 commit e09919ac72407d83b68c9bd79136c3f0f8d16459 @artnez committed May 13, 2012
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/faceoff/db.py
View
@@ -216,10 +216,12 @@ def search(self, table, sort=None, order=None, limit=None, **where):
param.append(value)
query += ' WHERE ' + ' AND '.join(fields)
if sort is not None:
- sort = self.clean(sort)
+ if not isinstance(sort, Expr):
+ sort ='"%s"' % self.clean(sort)
+ sort = str(sort)
if order != 'asc':
order = 'desc'
- query += ' ORDER BY "%s" %s' % (sort, order)
+ query += ' ORDER BY %s %s' % (sort, order)
if limit is not None:
query += ' LIMIT %d ' % int(limit)
c = self.execute(query, param)

0 comments on commit e09919a

Please sign in to comment.