Show index columns in the correct order in RE-SQL. Fixes #1842

pull/3/head
Murtuza Zabuawala 2016-12-16 11:59:37 +00:00 committed by Dave Page
parent 686237413c
commit 1431dfcb01
2 changed files with 12 additions and 4 deletions

View File

@ -27,4 +27,5 @@ FROM (
LEFT OUTER JOIN pg_operator op ON (op.oid = c.conexclop[i.attnum]) LEFT OUTER JOIN pg_operator op ON (op.oid = c.conexclop[i.attnum])
LEFT JOIN pg_attribute a ON (a.attrelid = i.indexrelid AND a.attnum = i.attnum) LEFT JOIN pg_attribute a ON (a.attrelid = i.indexrelid AND a.attnum = i.attnum)
LEFT OUTER JOIN pg_collation coll ON a.attcollation=coll.oid LEFT OUTER JOIN pg_collation coll ON a.attcollation=coll.oid
LEFT OUTER JOIN pg_namespace nspc ON coll.collnamespace=nspc.oid; LEFT OUTER JOIN pg_namespace nspc ON coll.collnamespace=nspc.oid
ORDER BY i.attnum;

View File

@ -1,7 +1,14 @@
{###
We need outer SELECT & dummy column to preserve the ordering
because we lose ordering when we use UNION
###}
SELECT * FROM (
{% for n in range(colcnt|int) %} {% for n in range(colcnt|int) %}
{% if loop.index != 1 %} {% if loop.index != 1 %}
UNION SELECT pg_get_indexdef({{ cid|string }}, {{ loop.index|string }}, true) AS column UNION SELECT pg_get_indexdef({{ cid|string }}, {{ loop.index|string }}, true) AS column, {{ n }} AS dummy
{% else %} {% else %}
SELECT pg_get_indexdef({{ cid|string }} , {{ loop.index|string }} , true) AS column SELECT pg_get_indexdef({{ cid|string }} , {{ loop.index|string }} , true) AS column, {{ n }} AS dummy
{% endif %} {% endif %}
{% endfor %} {% endfor %}
) tmp
ORDER BY dummy