diff --git a/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/default/objectquery.sql b/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/default/objectquery.sql index 2c55e25a3..2c6ba580d 100644 --- a/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/default/objectquery.sql +++ b/web/pgadmin/tools/sqleditor/templates/sqleditor/sql/default/objectquery.sql @@ -4,7 +4,7 @@ SELECT * FROM {{ conn|qtIdent(nsp_name, object_name) }} WHERE {{ sql_filter }} {% 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 %} +ORDER BY {% for p in primary_keys %}{{conn|qtIdent(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 %}