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 SELECT
{countResultF} AS total_result_set, {countResultF} AS total_result_set,
pg_catalog.count(t) AS page_total, pg_catalog.count(t) AS page_total,
case when pg_catalog.count(1) > 1 case
then {bodyF} when pg_catalog.count(1) > 1 then
else ( {bodyF}
select case when ((array_agg(row_to_json(t)))[1]->{_procName}) is not null else
then ((array_agg(row_to_json(t)))[1]->{_procName})::character varying coalesce(((array_agg(row_to_json(t)))[1]->{_procName})::character varying, {bodyF})
else {bodyF}
end end as body
)
end as body
FROM ({selectQuery}) t; FROM ({selectQuery}) t;
|] |]
-- FROM (select * from {sourceCTEName} {limitF range}) t; -- FROM (select * from {sourceCTEName} {limitF range}) t;