44--
55-- Helper function for assertions
66--
7- DROP FUNCTION IF EXISTS _index_exists (text , text , text , text );
8- CREATE FUNCTION _index_exists (table_name text , column_name text , index_name text , state text DEFAULT ' pending' )
7+ DROP FUNCTION IF EXISTS _search_config_exists (text , text , text , text );
8+ CREATE FUNCTION _search_config_exists (table_name text , column_name text , index_name text , state text DEFAULT ' pending' )
99 RETURNS boolean
1010LANGUAGE sql STRICT PARALLEL SAFE
1111BEGIN ATOMIC
@@ -25,23 +25,23 @@ DO $$
2525 BEGIN
2626
2727 -- Add indexes
28- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
29- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
28+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
29+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
3030
3131 -- Add index with cast
32- PERFORM eql_v2 .add_index (' users' , ' name' , ' unique' , ' int' );
33- ASSERT (SELECT _index_exists (' users' , ' name' , ' unique' ));
32+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' unique' , ' int' );
33+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' unique' ));
3434
3535 ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
3636 WHERE c .state = ' pending' AND
3737 c .data # > array['tables', 'users', 'name'] ? 'cast_as'));
3838
3939 -- Match index removed
40- PERFORM eql_v2 .remove_index (' users' , ' name' , ' match' );
41- ASSERT NOT (SELECT _index_exists (' users' , ' name' , ' match' ));
40+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' match' );
41+ ASSERT NOT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
4242
4343 -- All indexes removed, delete the emtpty pending config
44- PERFORM eql_v2 .remove_index (' users' , ' name' , ' unique' );
44+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' unique' );
4545 ASSERT (SELECT NOT EXISTS (SELECT FROM eql_v2_configuration c WHERE c .state = ' pending' ));
4646
4747 END;
@@ -60,16 +60,16 @@ DO $$
6060 BEGIN
6161
6262 -- Add indexes
63- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
64- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
63+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
64+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
6565
6666 ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
6767 WHERE c .state = ' pending' AND
6868 c .data # > array['tables', 'users', 'name', 'indexes'] ? 'match'));
6969
7070 -- Add index with cast
71- PERFORM eql_v2 .add_index (' blah' , ' vtha' , ' unique' , ' int' );
72- ASSERT (SELECT _index_exists (' blah' , ' vtha' , ' unique' ));
71+ PERFORM eql_v2 .add_search_config (' blah' , ' vtha' , ' unique' , ' int' );
72+ ASSERT (SELECT _search_config_exists (' blah' , ' vtha' , ' unique' ));
7373
7474 ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
7575 WHERE c .state = ' pending' AND
@@ -82,12 +82,12 @@ DO $$
8282
8383
8484 -- Match index removed
85- PERFORM eql_v2 .remove_index (' users' , ' name' , ' match' );
86- ASSERT NOT (SELECT _index_exists (' users' , ' name' , ' match' ));
85+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' match' );
86+ ASSERT NOT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
8787
8888 -- Match index removed
89- PERFORM eql_v2 .remove_index (' blah' , ' vtha' , ' unique' );
90- ASSERT NOT (SELECT _index_exists (' users' , ' vtha' , ' unique' ));
89+ PERFORM eql_v2 .remove_search_config (' blah' , ' vtha' , ' unique' );
90+ ASSERT NOT (SELECT _search_config_exists (' users' , ' vtha' , ' unique' ));
9191
9292 -- All indexes removed, delete the emtpty pending config
9393 ASSERT (SELECT NOT EXISTS (SELECT FROM eql_v2_configuration c WHERE c .state = ' pending' ));
@@ -107,12 +107,12 @@ $$ LANGUAGE plpgsql;
107107
108108DO $$
109109 BEGIN
110- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
111- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
110+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
111+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
112112
113113 -- Pending configuration contains the path `user/name.match.option`
114- PERFORM eql_v2 .modify_index (' users' , ' name' , ' match' , ' int' , ' {"option": "value"}' ::jsonb);
115- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
114+ PERFORM eql_v2 .modify_search_config (' users' , ' name' , ' match' , ' int' , ' {"option": "value"}' ::jsonb);
115+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
116116
117117 ASSERT (SELECT EXISTS (SELECT id FROM eql_v2_configuration c
118118 WHERE c .state = ' pending' AND
@@ -123,7 +123,7 @@ DO $$
123123 c .data # > array['tables', 'users', 'name'] ? 'cast_as'));
124124
125125 -- All indexes removed, delete the emtpty pending config
126- PERFORM eql_v2 .remove_index (' users' , ' name' , ' match' );
126+ PERFORM eql_v2 .remove_search_config (' users' , ' name' , ' match' );
127127 ASSERT (SELECT NOT EXISTS (SELECT FROM eql_v2_configuration c WHERE c .state = ' pending' ));
128128 END;
129129$$ LANGUAGE plpgsql;
@@ -160,16 +160,16 @@ INSERT INTO eql_v2_configuration (state, data) VALUES (
160160-- An encrypting config should exist
161161DO $$
162162 BEGIN
163- ASSERT (SELECT _index_exists (' users' , ' blah' , ' match' , ' active' ));
163+ ASSERT (SELECT _search_config_exists (' users' , ' blah' , ' match' , ' active' ));
164164
165- PERFORM eql_v2 .add_index (' users' , ' name' , ' match' );
165+ PERFORM eql_v2 .add_search_config (' users' , ' name' , ' match' );
166166
167167 -- index added to name
168- ASSERT (SELECT _index_exists (' users' , ' name' , ' match' ));
168+ ASSERT (SELECT _search_config_exists (' users' , ' name' , ' match' ));
169169
170170 -- pending is a copy of the active config
171171 -- and the active index still exists
172- ASSERT (SELECT _index_exists (' users' , ' blah' , ' match' ));
172+ ASSERT (SELECT _search_config_exists (' users' , ' blah' , ' match' ));
173173
174174 END;
175175$$ LANGUAGE plpgsql;
0 commit comments