Show index columns in the correct order in RE-SQL. Fixes #1842
parent
686237413c
commit
1431dfcb01
|
@ -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;
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue