Skip to content

Commit 739e186

Browse files
committed
test: test for handling of null index terms
1 parent da5072f commit 739e186

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/operators/compare_test.sql

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,45 @@ DO $$
163163
ASSERT eql_v2.compare(c, b) = 1;
164164
ASSERT eql_v2.compare(c, a) = 1;
165165
END;
166-
$$ LANGUAGE plpgsql;
166+
$$ LANGUAGE plpgsql;
167+
168+
169+
--
170+
-- Compare hmac_256 when record has a `null` index of higher precedence
171+
-- TEST COVERAGE FOR BUG FIX
172+
--
173+
-- ORE Block indexes `ob` are used in compare before hmac_256 indexes.
174+
-- If the index term is null `{"ob": null}` it should not be used
175+
-- Comparing two `null` values is evaluated as equality and hilarity ensues
176+
--
177+
178+
DO $$
179+
DECLARE
180+
a eql_v2_encrypted;
181+
b eql_v2_encrypted;
182+
c eql_v2_encrypted;
183+
BEGIN
184+
-- generate with `hm` index
185+
a := create_encrypted_json(1, 'hm');
186+
-- append `null` index
187+
a := '{"ob": null}'::jsonb || a::jsonb;
188+
189+
b := create_encrypted_json(2, 'hm');
190+
b := '{"ob": null}'::jsonb || b::jsonb;
191+
192+
c := create_encrypted_json(3, 'hm');
193+
c := '{"ob": null}'::jsonb || c::jsonb;
194+
195+
ASSERT eql_v2.compare(a, a) = 0;
196+
ASSERT eql_v2.compare(a, b) = -1;
197+
ASSERT eql_v2.compare(a, c) = -1;
198+
199+
ASSERT eql_v2.compare(b, b) = 0;
200+
ASSERT eql_v2.compare(b, a) = 1;
201+
ASSERT eql_v2.compare(b, c) = -1;
202+
203+
ASSERT eql_v2.compare(c, c) = 0;
204+
ASSERT eql_v2.compare(c, b) = 1;
205+
ASSERT eql_v2.compare(c, a) = 1;
206+
END;
207+
$$ LANGUAGE plpgsql;

0 commit comments

Comments
 (0)