Skip to content

Commit 705ecc6

Browse files
authored
Merge pull request #58 from cipherstash/fix/handle-null-jsonb-correctly
Fix: handle NULL `ste_vec` in `cs_ste_vec_(term|terms|value)_v1`
2 parents e9147bb + dd87797 commit 705ecc6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

sql/002-ste-vec.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ DECLARE
195195
i integer;
196196
BEGIN
197197
ste_vec_index := cs_ste_vec_v1(col);
198+
199+
IF ste_vec_index IS NULL THEN
200+
RETURN NULL;
201+
END IF;
202+
198203
target_selector := selector->>'svs';
199204

200205
FOR i IN 1..array_length(ste_vec_index.entries, 1) LOOP
@@ -236,6 +241,11 @@ DECLARE
236241
term_array cs_ste_vec_encrypted_term_v1[];
237242
BEGIN
238243
ste_vec_index := cs_ste_vec_v1(col);
244+
245+
IF ste_vec_index IS NULL THEN
246+
RETURN NULL;
247+
END IF;
248+
239249
target_selector := selector->>'svs';
240250

241251
FOR i IN 1..array_length(ste_vec_index.entries, 1) LOOP
@@ -268,6 +278,11 @@ DECLARE
268278
i integer;
269279
BEGIN
270280
ste_vec_index := cs_ste_vec_v1(col);
281+
282+
IF ste_vec_index IS NULL THEN
283+
RETURN NULL;
284+
END IF;
285+
271286
target_selector := selector->>'svs';
272287

273288
FOR i IN 1..array_length(ste_vec_index.entries, 1) LOOP
@@ -292,6 +307,11 @@ DECLARE
292307
ste_vec_index cs_ste_vec_index_v1;
293308
BEGIN
294309
ste_vec_index := cs_ste_vec_v1(col);
310+
311+
IF ste_vec_index IS NULL THEN
312+
RETURN NULL;
313+
END IF;
314+
295315
RETURN ste_vec_index.entries[1].term;
296316
END;
297317
$$ LANGUAGE plpgsql;

0 commit comments

Comments
 (0)