query simplification by @diogob

This commit is contained in:
Ruslan Talpa
2016-06-28 12:18:12 +03:00
parent 430baf23b9
commit 1372de6f43
+7 -9
View File
@@ -212,15 +212,13 @@ callProc qi params selectQuery countQuery _ countTotal isSingle =
SELECT
{countResultF} AS total_result_set,
pg_catalog.count(t) AS page_total,
case when pg_catalog.count(1) > 1
then {bodyF}
else (
select case when ((array_agg(row_to_json(t)))[1]->{_procName}) is not null
then ((array_agg(row_to_json(t)))[1]->{_procName})::character varying
else {bodyF}
end
)
end as body
case
when pg_catalog.count(1) > 1 then
{bodyF}
else
coalesce(((array_agg(row_to_json(t)))[1]->{_procName})::character varying, {bodyF})
end as body
FROM ({selectQuery}) t;
|]
-- FROM (select * from {sourceCTEName} {limitF range}) t;