|
40 | 40 |
|
41 | 41 | assert_equal "archived_at IS NULL", compiled.where |
42 | 42 | sql = ActiveRecord::Base.connection.send(:build_create_sql, compiled, if_not_exists: false) |
43 | | - assert_includes sql, "WHERE archived_at IS NULL" |
| 43 | + assert_sql_equal <<~SQL, sql |
| 44 | + CREATE INDEX products_bm25_idx ON products |
| 45 | + USING bm25 (id, (description::pdb.simple)) |
| 46 | + WITH (key_field='id') |
| 47 | + WHERE archived_at IS NULL |
| 48 | + SQL |
44 | 49 | end |
45 | 50 |
|
46 | 51 | it "renders concurrent create index SQL" do |
|
54 | 59 | end |
55 | 60 |
|
56 | 61 | sql = ActiveRecord::Base.connection.send(:build_create_sql, klass.compiled_definition, if_not_exists: true, concurrently: true) |
57 | | - assert_includes sql, "CREATE INDEX CONCURRENTLY IF NOT EXISTS" |
| 62 | + assert_sql_equal <<~SQL, sql |
| 63 | + CREATE INDEX CONCURRENTLY IF NOT EXISTS products_bm25_idx ON products |
| 64 | + USING bm25 (id, (description::pdb.simple)) |
| 65 | + WITH (key_field='id') |
| 66 | + SQL |
58 | 67 | end |
59 | 68 |
|
60 | 69 | it "rejects mixing tokenizers with single tokenizer keys" do |
|
170 | 179 | end |
171 | 180 |
|
172 | 181 | sql = ActiveRecord::Base.connection.send(:build_create_sql, klass.compiled_definition, if_not_exists: false) |
173 | | - assert_includes sql, "pdb.ngram(2, 5)" |
| 182 | + assert_sql_equal <<~SQL, sql |
| 183 | + CREATE INDEX products_bm25_idx ON products |
| 184 | + USING bm25 (id, (description::pdb.ngram(2, 5))) |
| 185 | + WITH (key_field='id') |
| 186 | + SQL |
174 | 187 | end |
175 | 188 |
|
176 | 189 | it "rejects partial ngram bounds in named_args" do |
|
217 | 230 | end |
218 | 231 |
|
219 | 232 | sql = ActiveRecord::Base.connection.send(:build_create_sql, klass.compiled_definition, if_not_exists: false) |
220 | | - assert_includes sql, "::pdb::xyz" |
221 | | - assert_includes sql, "::pdb::abc(12, \"fafda\")" |
| 233 | + assert_sql_equal <<~SQL, sql |
| 234 | + CREATE INDEX products_bm25_idx ON products |
| 235 | + USING bm25 (id, (description::pdb::xyz), ((metadata->>'title')::pdb::abc(12, "fafda"))) |
| 236 | + WITH (key_field='id') |
| 237 | + SQL |
222 | 238 | end |
223 | 239 |
|
224 | 240 | it "prefixes unqualified inline tokenizers with pdb namespace" do |
|
232 | 248 | end |
233 | 249 |
|
234 | 250 | sql = ActiveRecord::Base.connection.send(:build_create_sql, klass.compiled_definition, if_not_exists: false) |
235 | | - assert_includes sql, "::pdb.ngram(2, 5)" |
| 251 | + assert_sql_equal <<~SQL, sql |
| 252 | + CREATE INDEX products_bm25_idx ON products |
| 253 | + USING bm25 (id, (description::pdb.ngram(2, 5))) |
| 254 | + WITH (key_field='id') |
| 255 | + SQL |
236 | 256 | end |
237 | 257 |
|
238 | 258 | it "round-trips tokenizer args through schema ruby" do |
|
0 commit comments