Properly sort rows by the pkey when viewing first/last 100. Fixes #2007

This commit is contained in:
Khushboo Vashi 2016-12-12 10:06:34 +00:00 committed by Dave Page
parent dbff4f7977
commit 53481023fa
2 changed files with 5 additions and 5 deletions

View File

@ -353,11 +353,11 @@ class TableCommand(GridCommand):
if sql_filter is None:
sql = render_template("/".join([self.sql_path, 'objectquery.sql']), object_name=self.object_name,
nsp_name=self.nsp_name, pk_names=pk_names, cmd_type=self.cmd_type,
limit=self.limit)
limit=self.limit, primary_keys=primary_keys)
else:
sql = render_template("/".join([self.sql_path, 'objectquery.sql']), object_name=self.object_name,
nsp_name=self.nsp_name, pk_names=pk_names, cmd_type=self.cmd_type,
sql_filter=sql_filter, limit=self.limit)
sql_filter=sql_filter, limit=self.limit, primary_keys=primary_keys)
return sql

View File

@ -3,9 +3,9 @@ SELECT * FROM {{ conn|qtIdent(nsp_name, object_name) }}
{% if sql_filter %}
WHERE {{ sql_filter }}
{% endif %}
{% if pk_names %}
ORDER BY {{ pk_names }}
{% if cmd_type == 1 or cmd_type == 3 %}ASC {% elif cmd_type == 2 %}DESC {% endif %}
{% if primary_keys %}
ORDER BY {% for p in primary_keys %}{{p}}{% if cmd_type == 1 or cmd_type == 3 %} ASC{% elif cmd_type == 2 %} DESC{% endif %}
{% if not loop.last %}, {% else %} {% endif %}{% endfor %}
{% endif %}
{% if limit > 0 %}
LIMIT {{ limit }}