Skip to content

Commit 3a3a22b

Browse files
authored
Merge pull request #112 from cipherstash/expand-order-by-testing
Expand ordering test using operator family
2 parents d78a3c1 + e702473 commit 3a3a22b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/operators/order_by_test.sql

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,51 @@ DECLARE
2525
format('SELECT id FROM ore WHERE e < %L ORDER BY eql_v2.order_by(e) ASC LIMIT 1', ore_term),
2626
'1');
2727
END;
28+
$$ LANGUAGE plpgsql;
29+
30+
31+
--
32+
-- ORE - ORDER BY without function
33+
--
34+
DO $$
35+
DECLARE
36+
e eql_v2_encrypted;
37+
ore_term eql_v2_encrypted;
38+
BEGIN
39+
-- Pull a record from the ore table with value of "42"
40+
SELECT ore.e FROM ore WHERE id = 42 INTO ore_term;
41+
42+
-- lt
43+
PERFORM assert_count(
44+
'ORDER BY eql_v2.order_by(e) DESC',
45+
format('SELECT id FROM ore WHERE e < %L ORDER BY e DESC', ore_term),
46+
41);
47+
48+
PERFORM assert_result(
49+
'ORDER BY e DESC returns correct record',
50+
format('SELECT id FROM ore WHERE e < %L ORDER BY e DESC LIMIT 1', ore_term),
51+
'41');
52+
53+
PERFORM assert_result(
54+
'ORDER BY e ASC',
55+
format('SELECT id FROM ore WHERE e < %L ORDER BY e ASC LIMIT 1', ore_term),
56+
'1');
57+
58+
-- gt
59+
PERFORM assert_count(
60+
'ORDER BY eql_v2.order_by(e) DESC',
61+
format('SELECT id FROM ore WHERE e > %L ORDER BY e ASC', ore_term),
62+
57);
63+
64+
PERFORM assert_result(
65+
'ORDER BY e DESC returns correct record',
66+
format('SELECT id FROM ore WHERE e > %L ORDER BY e DESC LIMIT 1', ore_term),
67+
'99');
68+
69+
PERFORM assert_result(
70+
'ORDER BY e ASC',
71+
format('SELECT id FROM ore WHERE e > %L ORDER BY e ASC LIMIT 1', ore_term),
72+
'43');
73+
74+
END;
2875
$$ LANGUAGE plpgsql;

0 commit comments

Comments
 (0)