Skip to content

Commit 9c8b996

Browse files
committed
chore:
1 parent eddaece commit 9c8b996

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/operators/~~.sql

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,23 @@
1515

1616
-- DROP FUNCTION IF EXISTS eql_v1.match(a eql_v1_encrypted, b eql_v1_encrypted);
1717

18-
CREATE FUNCTION eql_v1.match(a eql_v1_encrypted, b eql_v1_encrypted)
18+
CREATE FUNCTION eql_v1.like(a eql_v1_encrypted, b eql_v1_encrypted)
1919
RETURNS boolean AS $$
2020
SELECT eql_v1.match(a) @> eql_v1.match(b);
2121
$$ LANGUAGE SQL;
2222

2323

24+
--
25+
-- Case sensitivity depends on the index term configuration
26+
-- Function preserves the SQL semantics
27+
--
28+
CREATE FUNCTION eql_v1.ilike(a eql_v1_encrypted, b eql_v1_encrypted)
29+
RETURNS boolean AS $$
30+
SELECT eql_v1.match(a) @> eql_v1.match(b);
31+
$$ LANGUAGE SQL;
32+
33+
34+
2435
-- DROP OPERATOR BEFORE FUNCTION
2536
-- DROP OPERATOR IF EXISTS ~~ (eql_v1_encrypted, eql_v1_encrypted);
2637
-- DROP OPERATOR IF EXISTS ~~* (eql_v1_encrypted, eql_v1_encrypted);
@@ -31,7 +42,7 @@ CREATE FUNCTION eql_v1."~~"(a eql_v1_encrypted, b eql_v1_encrypted)
3142
RETURNS boolean
3243
AS $$
3344
BEGIN
34-
RETURN eql_v1.match(a, b);
45+
RETURN eql_v1.like(a, b);
3546
END;
3647
$$ LANGUAGE plpgsql;
3748

@@ -65,7 +76,7 @@ CREATE FUNCTION eql_v1."~~"(a eql_v1_encrypted, b jsonb)
6576
RETURNS boolean
6677
AS $$
6778
BEGIN
68-
RETURN eql_v1.match(a, b::eql_v1_encrypted);
79+
RETURN eql_v1.like(a, b::eql_v1_encrypted);
6980
END;
7081
$$ LANGUAGE plpgsql;
7182

@@ -100,7 +111,7 @@ CREATE FUNCTION eql_v1."~~"(a jsonb, b eql_v1_encrypted)
100111
RETURNS boolean
101112
AS $$
102113
BEGIN
103-
RETURN eql_v1.match(a::eql_v1_encrypted, b);
114+
RETURN eql_v1.like(a::eql_v1_encrypted, b);
104115
END;
105116
$$ LANGUAGE plpgsql;
106117

src/operators/~~_test.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ DECLARE
8787
e := create_encrypted_json(i, 'm');
8888

8989
PERFORM assert_result(
90-
format('eql_v1.match(eql_v1_encrypted, eql_v1_encrypted)', i),
91-
format('SELECT e FROM encrypted WHERE eql_v1.match(e, %L);', e));
90+
format('eql_v1.like(eql_v1_encrypted, eql_v1_encrypted)', i),
91+
format('SELECT e FROM encrypted WHERE eql_v1.like(e, %L);', e));
9292

9393
end loop;
9494

9595
-- Partial match
9696
e := create_encrypted_json('m')::jsonb || '{"m": [10, 11]}';
9797

9898
PERFORM assert_result(
99-
'eql_v1.match(eql_v1_encrypted, eql_v1_encrypted)',
100-
format('SELECT e FROM encrypted WHERE eql_v1.match(e, %L);', e));
99+
'eql_v1.like(eql_v1_encrypted, eql_v1_encrypted)',
100+
format('SELECT e FROM encrypted WHERE eql_v1.like(e, %L);', e));
101101

102102
END;
103103
$$ LANGUAGE plpgsql;

0 commit comments

Comments
 (0)