Skip to content

Expand ordering test using operator family #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/operators/order_by_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;