From 207c41f9632fbbbd99539e407d08f22f85f4e35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=BB=C3=B3=C5=82tak?= Date: Thu, 23 Sep 2021 09:29:37 +0200 Subject: [PATCH] inst/dbfunctions.sql: child_views_func() fixed ordering --- inst/dbfunctions.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/dbfunctions.sql b/inst/dbfunctions.sql index a599c26..91ae023 100644 --- a/inst/dbfunctions.sql +++ b/inst/dbfunctions.sql @@ -322,7 +322,7 @@ AS $func$ WITH t1 AS ( SELECT id, row_number() OVER () AS orderid FROM ( - SELECT id, ordervalue, CASE _orderprop WHEN 'desc' THEN -row_number() OVER () ELSE row_number() OVER () END AS orderid + SELECT id, CASE _orderby WHEN 'desc' THEN -row_number() OVER (ORDER BY ordervalue) ELSE row_number() OVER () END AS ord, ordervalue FROM ( SELECT r1.id, @@ -335,7 +335,7 @@ AS $func$ GROUP BY 1 ORDER BY 2 ) t - ORDER BY orderid + ORDER BY ord ) t LIMIT _limit OFFSET _page @@ -378,6 +378,7 @@ AS $func$ JOIN metadata mr2 ON r2.target_id = mr2.id AND mr2.property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasTitle' GROUP BY 1, 2, 3, 4, 5, 6, 7 ) t + ORDER BY orderid $func$ LANGUAGE 'sql';