From e70247387f2b0bf2e688a804669af69018244dfd Mon Sep 17 00:00:00 2001 From: Toby Hede Date: Tue, 27 May 2025 10:56:59 +1000 Subject: [PATCH] test: Expand ordering test using operator family --- src/operators/order_by_test.sql | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/operators/order_by_test.sql b/src/operators/order_by_test.sql index 49e16f4..32ee978 100644 --- a/src/operators/order_by_test.sql +++ b/src/operators/order_by_test.sql @@ -25,4 +25,51 @@ DECLARE format('SELECT id FROM ore WHERE e < %L ORDER BY eql_v2.order_by(e) ASC LIMIT 1', ore_term), '1'); END; +$$ LANGUAGE plpgsql; + + +-- +-- ORE - ORDER BY without function +-- +DO $$ +DECLARE + e eql_v2_encrypted; + ore_term eql_v2_encrypted; + BEGIN + -- Pull a record from the ore table with value of "42" + SELECT ore.e FROM ore WHERE id = 42 INTO ore_term; + + -- lt + PERFORM assert_count( + 'ORDER BY eql_v2.order_by(e) DESC', + format('SELECT id FROM ore WHERE e < %L ORDER BY e DESC', ore_term), + 41); + + PERFORM assert_result( + 'ORDER BY e DESC returns correct record', + format('SELECT id FROM ore WHERE e < %L ORDER BY e DESC LIMIT 1', ore_term), + '41'); + + PERFORM assert_result( + 'ORDER BY e ASC', + format('SELECT id FROM ore WHERE e < %L ORDER BY e ASC LIMIT 1', ore_term), + '1'); + + -- gt + PERFORM assert_count( + 'ORDER BY eql_v2.order_by(e) DESC', + format('SELECT id FROM ore WHERE e > %L ORDER BY e ASC', ore_term), + 57); + + PERFORM assert_result( + 'ORDER BY e DESC returns correct record', + format('SELECT id FROM ore WHERE e > %L ORDER BY e DESC LIMIT 1', ore_term), + '99'); + + PERFORM assert_result( + 'ORDER BY e ASC', + format('SELECT id FROM ore WHERE e > %L ORDER BY e ASC LIMIT 1', ore_term), + '43'); + + END; $$ LANGUAGE plpgsql; \ No newline at end of file