full_search 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50bb1c53fe9f326612a2413a441a37acfe48f25bf4730786de3631c7230b2572
4
- data.tar.gz: ab53bbd57f8fd9cb464af29d37aa70cd0efb18a2835eff1b501d61a14d0de43f
3
+ metadata.gz: 866994a5c7f55cea4237fb2edcbf59f1f7c8c32772c6830df737bcbea4a6f1c6
4
+ data.tar.gz: 5a11ccf1c48abd1050288bbb7107b8ade82132e009ac23ed5803ed153675f535
5
5
  SHA512:
6
- metadata.gz: ab98601c786c02808246cf4657ef7c3912e36e0fbc429417c0ff564a3ec1e2575216fda8d64ee2ab22db32c707bcbce0915fcc3d57038059f1dfe05bde48963e
7
- data.tar.gz: 52564a1ce083d5aa0f6cb624f8f9aa4a0bb0ac13a85216f14a857a5c2c2c744d37fa4370272679c3bd13c76eb6ec732814463cfa143bb714654243968c6c800c
6
+ metadata.gz: 35eb2afacd021899e68eb808b65a6f323db3d66770940471aa94d9c3238e41c409c678ac79d82dc609dcafaf3117d937895fa8effc9a8e665790a8625ef1f231
7
+ data.tar.gz: 5f1f25fe9e2c268e4f6b95c988ddb7958c34649fcf53aa941d0b19d1b605a5b4345864bb7206b597fc509b9802a110db6c3900a40fe1ab3d3ce1468db28aef85
@@ -190,12 +190,7 @@ module FullSearch
190
190
  columns = (dsl.fields + dsl.filters.map { |f| FilterColumnPlaceholder.new(name: f.name) })
191
191
  column_list = columns.map { |c| (c.respond_to?(:unindexed?) && c.unindexed?) ? "#{qc(c.name)} UNINDEXED" : qc(c.name) }.join(", ")
192
192
 
193
- <<~SQL
194
- CREATE VIRTUAL TABLE #{qt(fts_table_name(model))} USING fts5(
195
- #{column_list},
196
- tokenize='#{dsl.tokenize}'
197
- );
198
- SQL
193
+ "CREATE VIRTUAL TABLE #{qt(fts_table_name(model))} USING fts5(#{column_list}, tokenize='#{dsl.tokenize}');"
199
194
  end
200
195
 
201
196
  def backfill_sql(model)
@@ -327,12 +322,7 @@ module FullSearch
327
322
  columns = (dsl.fields + dsl.filters.map { |f| FilterColumnPlaceholder.new(name: f.name) })
328
323
  column_list = columns.map { |c| (c.respond_to?(:unindexed?) && c.unindexed?) ? "#{qc(c.name)} UNINDEXED" : qc(c.name) }.join(", ")
329
324
 
330
- <<~SQL
331
- CREATE VIRTUAL TABLE #{qt(trigram_table_name(model))} USING fts5(
332
- #{column_list},
333
- tokenize='trigram'
334
- );
335
- SQL
325
+ "CREATE VIRTUAL TABLE #{qt(trigram_table_name(model))} USING fts5(#{column_list}, tokenize='trigram');"
336
326
  end
337
327
 
338
328
  def backfill_trigram_sql(model)
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FullSearch
4
+ module VirtualTablesPatch
5
+ def virtual_tables
6
+ super.reject { |_, options| options.first.nil? }
7
+ end
8
+ end
9
+
10
+ module SchemaDumperPatch
11
+ private
12
+
13
+ def virtual_tables(stream)
14
+ virtual_tables = @connection.virtual_tables.reject { |name, _| ignored?(name) }
15
+
16
+ if virtual_tables.any?
17
+ stream.puts
18
+ stream.puts " # Virtual tables defined in this database."
19
+ stream.puts " # Note that virtual tables may not work with other database engines. Be careful if changing database."
20
+ virtual_tables.sort.each do |table_name, options|
21
+ module_name, arguments = options
22
+ next if module_name.nil? || arguments.nil?
23
+
24
+ stream.puts " create_virtual_table #{table_name.inspect}, #{module_name.inspect}, #{arguments.split(", ").inspect}"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
31
+ ActiveSupport.on_load(:active_record) do
32
+ begin
33
+ require "active_record/connection_adapters/sqlite3_adapter"
34
+ rescue LoadError
35
+ next
36
+ end
37
+
38
+ if defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
39
+ ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend(FullSearch::VirtualTablesPatch)
40
+ end
41
+
42
+ if defined?(ActiveRecord::ConnectionAdapters::SQLite3::SchemaDumper)
43
+ ActiveRecord::ConnectionAdapters::SQLite3::SchemaDumper.prepend(FullSearch::SchemaDumperPatch)
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FullSearch
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
data/lib/full_search.rb CHANGED
@@ -24,6 +24,7 @@ require "full_search/reindex_job"
24
24
  require "full_search/optimize_job"
25
25
  require "full_search/test_helpers"
26
26
  require "full_search/multi_search"
27
+ require "full_search/schema_dumper_patch"
27
28
 
28
29
  ActiveSupport.on_load(:active_record) do
29
30
  include FullSearch::Model
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: full_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben D'Angelo
@@ -155,6 +155,7 @@ files:
155
155
  - lib/full_search/quoting.rb
156
156
  - lib/full_search/railtie.rb
157
157
  - lib/full_search/reindex_job.rb
158
+ - lib/full_search/schema_dumper_patch.rb
158
159
  - lib/full_search/search.rb
159
160
  - lib/full_search/soft_delete.rb
160
161
  - lib/full_search/test_helpers.rb