Skip to content

Commit

Permalink
Add primary keys back to order by clause for sorting, refs #216
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 17, 2018
1 parent 59a3aa8 commit db23da7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,11 @@ async def data(self, request, name, hash, table):
if use_rowid:
select = 'rowid, *'
order_by = 'rowid'
order_by_pks = 'rowid'
else:
select = '*'
order_by = ', '.join(pks)
order_by_pks = ', '.join([escape_sqlite(pk) for pk in pks])
order_by = order_by_pks

if is_view:
order_by = ''
Expand Down Expand Up @@ -792,6 +794,9 @@ async def data(self, request, name, hash, table):
)
)
params['p{}'.format(len(params))] = sort_value
order_by = '{}, {}'.format(
order_by, order_by_pks
)
else:
where_clauses.extend(next_by_pk_clauses)

Expand Down

0 comments on commit db23da7

Please sign in to comment.