Merge pull request #67 from michele-comitini/master
avoid ordering on limitby
This commit is contained in:
+3
-2
@@ -200,7 +200,7 @@ TABLE_ARGS = set(
|
|||||||
|
|
||||||
SELECT_ARGS = set(
|
SELECT_ARGS = set(
|
||||||
('orderby', 'groupby', 'limitby','required', 'cache', 'left',
|
('orderby', 'groupby', 'limitby','required', 'cache', 'left',
|
||||||
'distinct', 'having', 'join','for_update', 'processor','cacheable'))
|
'distinct', 'having', 'join','for_update', 'processor','cacheable', 'orderby_on_limitby'))
|
||||||
|
|
||||||
ogetattr = object.__getattribute__
|
ogetattr = object.__getattribute__
|
||||||
osetattr = object.__setattr__
|
osetattr = object.__setattr__
|
||||||
@@ -1530,6 +1530,7 @@ class BaseAdapter(ConnectionPool):
|
|||||||
orderby = args_get('orderby', False)
|
orderby = args_get('orderby', False)
|
||||||
having = args_get('having', False)
|
having = args_get('having', False)
|
||||||
limitby = args_get('limitby', False)
|
limitby = args_get('limitby', False)
|
||||||
|
orderby_on_limitby = args_get('orderby_on_limitby', True)
|
||||||
for_update = args_get('for_update', False)
|
for_update = args_get('for_update', False)
|
||||||
if self.can_select_for_update is False and for_update is True:
|
if self.can_select_for_update is False and for_update is True:
|
||||||
raise SyntaxError('invalid select attribute: for_update')
|
raise SyntaxError('invalid select attribute: for_update')
|
||||||
@@ -1623,7 +1624,7 @@ class BaseAdapter(ConnectionPool):
|
|||||||
else:
|
else:
|
||||||
sql_o += ' ORDER BY %s' % self.expand(orderby)
|
sql_o += ' ORDER BY %s' % self.expand(orderby)
|
||||||
if limitby:
|
if limitby:
|
||||||
if not orderby and tablenames:
|
if orderby_on_limitby and not orderby and tablenames:
|
||||||
sql_o += ' ORDER BY %s' % ', '.join(['%s.%s'%(t,x) for t in tablenames for x in (hasattr(self.db[t],'_primarykey') and self.db[t]._primarykey or [self.db[t]._id.name])])
|
sql_o += ' ORDER BY %s' % ', '.join(['%s.%s'%(t,x) for t in tablenames for x in (hasattr(self.db[t],'_primarykey') and self.db[t]._primarykey or [self.db[t]._id.name])])
|
||||||
# oracle does not support limitby
|
# oracle does not support limitby
|
||||||
sql = self.select_limitby(sql_s, sql_f, sql_t, sql_w, sql_o, limitby)
|
sql = self.select_limitby(sql_s, sql_f, sql_t, sql_w, sql_o, limitby)
|
||||||
|
|||||||
Reference in New Issue
Block a user