Ordering of results in query templates involving UNION
От | Edmund Horner |
---|---|
Тема | Ordering of results in query templates involving UNION |
Дата | |
Msg-id | CAMyN-kBD-RiZU9OeMT1u2q5Zg6mZiBCXbYNMBdaxQFjdzy9czw@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Ordering of results in query templates
involving UNION
|
Список | pgadmin-hackers |
Hi,
I was trying out the beta download and noticed that the SQL definition for some of my constraints had the columns in the wrong order. I traced this to https://git.postgresql.org/gitweb/?p=pgadmin4.git;a=blob;f=web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/index_constraint/sql/get_constraint_cols.sql;hb=702609517f23be7c14e2f9d655f66ea8ac43dd9c which has the form of a SELECT ... UNION SELECT ... for each column in the constraint. I was able to fix this one case by appending the loop index as a new column and ordering by that:{% for n in range(colcnt|int) %}
{% if loop.index != 1 %}
UNION SELECT pg_get_indexdef({{ cid|string }}, {{ loop.index|string }}, true) AS column, {{ loop.index|string }} AS idx
{% else %}
SELECT pg_get_indexdef({{ cid|string }} , {{ loop.index|string }} , true) AS column, {{ loop.index|string }} AS idx
{% endif %}
{% endfor %}
ORDER BY idx
В списке pgadmin-hackers по дате отправления: