pg_search 2.3.2 → 2.3.7
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 +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +80 -0
- data/.jrubyrc +1 -0
- data/.standard.yml +6 -0
- data/CHANGELOG.md +55 -20
- data/CODE_OF_CONDUCT.md +76 -0
- data/Gemfile +19 -6
- data/LICENSE +1 -1
- data/README.md +106 -43
- data/Rakefile +9 -6
- data/lib/pg_search/configuration/column.rb +6 -4
- data/lib/pg_search/configuration/foreign_column.rb +1 -1
- data/lib/pg_search/configuration.rb +13 -3
- data/lib/pg_search/document.rb +9 -9
- data/lib/pg_search/features/dmetaphone.rb +5 -7
- data/lib/pg_search/features/feature.rb +1 -1
- data/lib/pg_search/features/trigram.rb +4 -4
- data/lib/pg_search/features/tsearch.rb +26 -24
- data/lib/pg_search/migration/dmetaphone_generator.rb +2 -2
- data/lib/pg_search/migration/generator.rb +5 -5
- data/lib/pg_search/migration/multisearch_generator.rb +2 -2
- data/lib/pg_search/migration/templates/add_pg_search_dmetaphone_support_functions.rb.erb +6 -6
- data/lib/pg_search/migration/templates/create_pg_search_documents.rb.erb +2 -2
- data/lib/pg_search/model.rb +6 -6
- data/lib/pg_search/multisearch/rebuilder.rb +2 -2
- data/lib/pg_search/multisearch.rb +23 -4
- data/lib/pg_search/multisearchable.rb +7 -7
- data/lib/pg_search/normalizer.rb +5 -5
- data/lib/pg_search/scope_options.rb +31 -13
- data/lib/pg_search/tasks.rb +3 -3
- data/lib/pg_search/version.rb +1 -1
- data/lib/pg_search.rb +5 -5
- data/pg_search.gemspec +16 -24
- data/spec/.rubocop.yml +20 -7
- data/spec/integration/.rubocop.yml +11 -0
- data/spec/integration/associations_spec.rb +121 -160
- data/spec/integration/deprecation_spec.rb +7 -8
- data/spec/integration/pg_search_spec.rb +390 -332
- data/spec/integration/single_table_inheritance_spec.rb +5 -5
- data/spec/lib/pg_search/configuration/association_spec.rb +21 -19
- data/spec/lib/pg_search/configuration/column_spec.rb +13 -1
- data/spec/lib/pg_search/configuration/foreign_column_spec.rb +4 -4
- data/spec/lib/pg_search/features/dmetaphone_spec.rb +4 -4
- data/spec/lib/pg_search/features/trigram_spec.rb +32 -28
- data/spec/lib/pg_search/features/tsearch_spec.rb +57 -33
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +94 -63
- data/spec/lib/pg_search/multisearch_spec.rb +57 -29
- data/spec/lib/pg_search/multisearchable_spec.rb +160 -107
- data/spec/lib/pg_search/normalizer_spec.rb +12 -10
- data/spec/lib/pg_search_spec.rb +75 -64
- data/spec/spec_helper.rb +21 -9
- data/spec/support/database.rb +10 -8
- metadata +20 -134
- data/.autotest +0 -5
- data/.codeclimate.yml +0 -17
- data/.rubocop.yml +0 -56
- data/.travis.yml +0 -50
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
|
+
# standard:disable RSpec/NestedGroups
|
|
5
6
|
describe PgSearch::Normalizer do
|
|
6
7
|
describe "#add_normalization" do
|
|
7
8
|
context "when config[:ignore] includes :accents" do
|
|
8
9
|
context "when passed an Arel node" do
|
|
9
10
|
it "wraps the expression in unaccent()" do
|
|
10
|
-
config =
|
|
11
|
+
config = instance_double(PgSearch::Configuration, "config", ignore: [:accents])
|
|
11
12
|
node = Arel::Nodes::NamedFunction.new("foo", [Arel::Nodes.build_quoted("bar")])
|
|
12
13
|
|
|
13
|
-
normalizer =
|
|
14
|
+
normalizer = described_class.new(config)
|
|
14
15
|
expect(normalizer.add_normalization(node)).to eq("unaccent(foo('bar'))")
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -19,9 +20,9 @@ describe PgSearch::Normalizer do
|
|
|
19
20
|
allow(PgSearch).to receive(:unaccent_function).and_return("my_unaccent")
|
|
20
21
|
node = Arel::Nodes::NamedFunction.new("foo", [Arel::Nodes.build_quoted("bar")])
|
|
21
22
|
|
|
22
|
-
config =
|
|
23
|
+
config = instance_double(PgSearch::Configuration, "config", ignore: [:accents])
|
|
23
24
|
|
|
24
|
-
normalizer =
|
|
25
|
+
normalizer = described_class.new(config)
|
|
25
26
|
expect(normalizer.add_normalization(node)).to eq("my_unaccent(foo('bar'))")
|
|
26
27
|
end
|
|
27
28
|
end
|
|
@@ -29,9 +30,9 @@ describe PgSearch::Normalizer do
|
|
|
29
30
|
|
|
30
31
|
context "when passed a String" do
|
|
31
32
|
it "wraps the expression in unaccent()" do
|
|
32
|
-
config =
|
|
33
|
+
config = instance_double(PgSearch::Configuration, "config", ignore: [:accents])
|
|
33
34
|
|
|
34
|
-
normalizer =
|
|
35
|
+
normalizer = described_class.new(config)
|
|
35
36
|
expect(normalizer.add_normalization("foo")).to eq("unaccent(foo)")
|
|
36
37
|
end
|
|
37
38
|
|
|
@@ -39,9 +40,9 @@ describe PgSearch::Normalizer do
|
|
|
39
40
|
it "wraps the expression in that function" do
|
|
40
41
|
allow(PgSearch).to receive(:unaccent_function).and_return("my_unaccent")
|
|
41
42
|
|
|
42
|
-
config =
|
|
43
|
+
config = instance_double(PgSearch::Configuration, "config", ignore: [:accents])
|
|
43
44
|
|
|
44
|
-
normalizer =
|
|
45
|
+
normalizer = described_class.new(config)
|
|
45
46
|
expect(normalizer.add_normalization("foo")).to eq("my_unaccent(foo)")
|
|
46
47
|
end
|
|
47
48
|
end
|
|
@@ -50,11 +51,12 @@ describe PgSearch::Normalizer do
|
|
|
50
51
|
|
|
51
52
|
context "when config[:ignore] does not include :accents" do
|
|
52
53
|
it "passes the expression through" do
|
|
53
|
-
config =
|
|
54
|
+
config = instance_double(PgSearch::Configuration, "config", ignore: [])
|
|
54
55
|
|
|
55
|
-
normalizer =
|
|
56
|
+
normalizer = described_class.new(config)
|
|
56
57
|
expect(normalizer.add_normalization("foo")).to eq("foo")
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
end
|
|
60
61
|
end
|
|
62
|
+
# standard:enable RSpec/NestedGroups
|
data/spec/lib/pg_search_spec.rb
CHANGED
|
@@ -2,42 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
require "spec_helper"
|
|
4
4
|
|
|
5
|
-
# For
|
|
5
|
+
# For Active Record 5.x, the association reflection's cache needs be cleared
|
|
6
6
|
# because we're stubbing the related constants.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def clear_searchable_cache
|
|
14
|
-
end
|
|
7
|
+
if ActiveRecord::VERSION::MAJOR == 5
|
|
8
|
+
def clear_searchable_cache
|
|
9
|
+
PgSearch::Document.reflect_on_association(:searchable).clear_association_scope_cache
|
|
10
|
+
end
|
|
11
|
+
else
|
|
12
|
+
def clear_searchable_cache
|
|
15
13
|
end
|
|
16
14
|
end
|
|
17
15
|
|
|
16
|
+
# standard:disable RSpec/NestedGroups
|
|
18
17
|
describe PgSearch do
|
|
19
18
|
describe ".multisearch" do
|
|
20
19
|
with_table "pg_search_documents", &DOCUMENTS_SCHEMA
|
|
21
20
|
|
|
22
21
|
describe "delegation to PgSearch::Document.search" do
|
|
23
|
-
subject {
|
|
22
|
+
subject { described_class.multisearch(query) }
|
|
23
|
+
|
|
24
|
+
let(:query) { instance_double(String, "query") }
|
|
25
|
+
let(:relation) { instance_double(ActiveRecord::Relation, "relation") }
|
|
24
26
|
|
|
25
|
-
let(:query) { double(:query) }
|
|
26
|
-
let(:relation) { double(:relation) }
|
|
27
27
|
before do
|
|
28
|
-
|
|
28
|
+
allow(PgSearch::Document).to receive(:search).with(query).and_return(relation)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it { is_expected.to eq(relation) }
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
context "with PgSearch.multisearch_options set to a Hash" do
|
|
35
|
-
before { allow(PgSearch).to receive(:multisearch_options).and_return(using: :dmetaphone) }
|
|
36
35
|
subject do
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
clear_searchable_cache
|
|
37
|
+
described_class.multisearch(query).map(&:searchable)
|
|
39
38
|
end
|
|
40
39
|
|
|
40
|
+
before { allow(described_class).to receive(:multisearch_options).and_return(using: :dmetaphone) }
|
|
41
|
+
|
|
41
42
|
with_model :MultisearchableModel do
|
|
42
43
|
table do |t|
|
|
43
44
|
t.string :title
|
|
@@ -48,24 +49,25 @@ describe PgSearch do
|
|
|
48
49
|
end
|
|
49
50
|
end
|
|
50
51
|
|
|
51
|
-
let!(:soundalike_record) { MultisearchableModel.create!(title:
|
|
52
|
+
let!(:soundalike_record) { MultisearchableModel.create!(title: "foning") }
|
|
52
53
|
let(:query) { "Phoning" }
|
|
54
|
+
|
|
53
55
|
it { is_expected.to include(soundalike_record) }
|
|
54
56
|
end
|
|
55
57
|
|
|
56
58
|
context "with PgSearch.multisearch_options set to a Proc" do
|
|
57
59
|
subject do
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
clear_searchable_cache
|
|
61
|
+
described_class.multisearch(query, soundalike).map(&:searchable)
|
|
60
62
|
end
|
|
61
63
|
|
|
62
64
|
before do
|
|
63
|
-
allow(
|
|
65
|
+
allow(described_class).to receive(:multisearch_options) do
|
|
64
66
|
lambda do |query, soundalike|
|
|
65
67
|
if soundalike
|
|
66
|
-
{
|
|
68
|
+
{using: :dmetaphone, query: query}
|
|
67
69
|
else
|
|
68
|
-
{
|
|
70
|
+
{query: query}
|
|
69
71
|
end
|
|
70
72
|
end
|
|
71
73
|
end
|
|
@@ -81,26 +83,28 @@ describe PgSearch do
|
|
|
81
83
|
end
|
|
82
84
|
end
|
|
83
85
|
|
|
84
|
-
let!(:soundalike_record) { MultisearchableModel.create!(title:
|
|
86
|
+
let!(:soundalike_record) { MultisearchableModel.create!(title: "foning") }
|
|
85
87
|
let(:query) { "Phoning" }
|
|
86
88
|
|
|
87
89
|
context "with soundalike true" do
|
|
88
90
|
let(:soundalike) { true }
|
|
91
|
+
|
|
89
92
|
it { is_expected.to include(soundalike_record) }
|
|
90
93
|
end
|
|
91
94
|
|
|
92
95
|
context "with soundalike false" do
|
|
93
96
|
let(:soundalike) { false }
|
|
97
|
+
|
|
94
98
|
it { is_expected.not_to include(soundalike_record) }
|
|
95
99
|
end
|
|
96
100
|
end
|
|
97
101
|
|
|
98
|
-
context "on an STI subclass" do
|
|
102
|
+
context "when on an STI subclass" do
|
|
99
103
|
context "with standard type column" do
|
|
100
104
|
with_model :SuperclassModel do
|
|
101
105
|
table do |t|
|
|
102
|
-
t.text
|
|
103
|
-
t.string
|
|
106
|
+
t.text "content"
|
|
107
|
+
t.string "type"
|
|
104
108
|
end
|
|
105
109
|
end
|
|
106
110
|
|
|
@@ -128,7 +132,7 @@ describe PgSearch do
|
|
|
128
132
|
|
|
129
133
|
expect(PgSearch::Document.count).to be 2
|
|
130
134
|
|
|
131
|
-
results =
|
|
135
|
+
results = described_class.multisearch("foo bar")
|
|
132
136
|
|
|
133
137
|
expect(results).to eq [included.pg_search_document]
|
|
134
138
|
end
|
|
@@ -141,11 +145,12 @@ describe PgSearch do
|
|
|
141
145
|
model = SearchableSubclassModel.find(model.id)
|
|
142
146
|
model.content = "foo"
|
|
143
147
|
model.save!
|
|
144
|
-
results =
|
|
148
|
+
results = described_class.multisearch("foo")
|
|
145
149
|
expect(results.size).to eq(SearchableSubclassModel.count)
|
|
146
150
|
end
|
|
147
151
|
|
|
148
|
-
|
|
152
|
+
# standard:disable RSpec/MultipleExpectations
|
|
153
|
+
specify "reindexing works" do
|
|
149
154
|
NonSearchableSubclassModel.create!(content: "foo bar")
|
|
150
155
|
NonSearchableSubclassModel.create!(content: "baz")
|
|
151
156
|
expected = SearchableSubclassModel.create!(content: "baz")
|
|
@@ -161,11 +166,12 @@ describe PgSearch do
|
|
|
161
166
|
|
|
162
167
|
PgSearch::Multisearch.rebuild(SearchableSubclassModel)
|
|
163
168
|
|
|
164
|
-
|
|
169
|
+
clear_searchable_cache
|
|
165
170
|
expect(PgSearch::Document.count).to be 1
|
|
166
171
|
expect(PgSearch::Document.first.searchable.class).to be SearchableSubclassModel
|
|
167
172
|
expect(PgSearch::Document.first.searchable).to eq expected
|
|
168
173
|
end
|
|
174
|
+
# standard:enable RSpec/MultipleExpectations
|
|
169
175
|
|
|
170
176
|
it "reindexing searchable STI doesn't clobber other related STI models" do
|
|
171
177
|
SearchableSubclassModel.create!(content: "baz")
|
|
@@ -175,7 +181,7 @@ describe PgSearch do
|
|
|
175
181
|
PgSearch::Multisearch.rebuild(SearchableSubclassModel)
|
|
176
182
|
expect(PgSearch::Document.count).to be 2
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
clear_searchable_cache
|
|
179
185
|
classes = PgSearch::Document.all.collect { |d| d.searchable.class }
|
|
180
186
|
expect(classes).to include SearchableSubclassModel
|
|
181
187
|
expect(classes).to include AnotherSearchableSubclassModel
|
|
@@ -185,12 +191,12 @@ describe PgSearch do
|
|
|
185
191
|
context "with custom type column" do
|
|
186
192
|
with_model :SuperclassModel do
|
|
187
193
|
table do |t|
|
|
188
|
-
t.text
|
|
189
|
-
t.string
|
|
194
|
+
t.text "content"
|
|
195
|
+
t.string "inherit"
|
|
190
196
|
end
|
|
191
197
|
|
|
192
198
|
model do
|
|
193
|
-
self.inheritance_column =
|
|
199
|
+
self.inheritance_column = "inherit"
|
|
194
200
|
end
|
|
195
201
|
end
|
|
196
202
|
|
|
@@ -218,7 +224,7 @@ describe PgSearch do
|
|
|
218
224
|
|
|
219
225
|
expect(PgSearch::Document.count).to be 2
|
|
220
226
|
|
|
221
|
-
results =
|
|
227
|
+
results = described_class.multisearch("foo bar")
|
|
222
228
|
|
|
223
229
|
expect(results).to eq [included.pg_search_document]
|
|
224
230
|
end
|
|
@@ -227,57 +233,62 @@ describe PgSearch do
|
|
|
227
233
|
end
|
|
228
234
|
|
|
229
235
|
describe ".disable_multisearch" do
|
|
230
|
-
it "
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
236
|
+
it "disables multisearch temporarily" do
|
|
237
|
+
multisearch_enabled_before = described_class.multisearch_enabled?
|
|
238
|
+
multisearch_enabled_inside = nil
|
|
239
|
+
described_class.disable_multisearch do
|
|
240
|
+
multisearch_enabled_inside = described_class.multisearch_enabled?
|
|
234
241
|
end
|
|
235
|
-
|
|
242
|
+
multisearch_enabled_after = described_class.multisearch_enabled?
|
|
236
243
|
|
|
237
|
-
expect(
|
|
238
|
-
expect(
|
|
239
|
-
expect(
|
|
244
|
+
expect(multisearch_enabled_before).to be(true)
|
|
245
|
+
expect(multisearch_enabled_inside).to be(false)
|
|
246
|
+
expect(multisearch_enabled_after).to be(true)
|
|
240
247
|
end
|
|
241
248
|
|
|
242
|
-
it "
|
|
243
|
-
|
|
249
|
+
it "reenables multisearch after an error" do
|
|
250
|
+
multisearch_enabled_before = described_class.multisearch_enabled?
|
|
251
|
+
multisearch_enabled_inside = nil
|
|
244
252
|
begin
|
|
245
|
-
|
|
246
|
-
|
|
253
|
+
described_class.disable_multisearch do
|
|
254
|
+
multisearch_enabled_inside = described_class.multisearch_enabled?
|
|
247
255
|
raise
|
|
248
256
|
end
|
|
249
|
-
rescue
|
|
257
|
+
rescue
|
|
250
258
|
end
|
|
259
|
+
multisearch_enabled_after = described_class.multisearch_enabled?
|
|
251
260
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
expect(
|
|
255
|
-
expect(@multisearch_enabled_inside).to be(false)
|
|
256
|
-
expect(@multisearch_enabled_after).to be(true)
|
|
261
|
+
expect(multisearch_enabled_before).to be(true)
|
|
262
|
+
expect(multisearch_enabled_inside).to be(false)
|
|
263
|
+
expect(multisearch_enabled_after).to be(true)
|
|
257
264
|
end
|
|
258
265
|
|
|
259
|
-
|
|
266
|
+
# standard:disable RSpec/ExampleLength
|
|
267
|
+
it "does not disable multisearch on other threads" do
|
|
260
268
|
values = Queue.new
|
|
261
269
|
sync = Queue.new
|
|
262
270
|
Thread.new do
|
|
263
|
-
values.push
|
|
271
|
+
values.push described_class.multisearch_enabled?
|
|
264
272
|
sync.pop # wait
|
|
265
|
-
values.push
|
|
273
|
+
values.push described_class.multisearch_enabled?
|
|
266
274
|
sync.pop # wait
|
|
267
|
-
values.push
|
|
275
|
+
values.push described_class.multisearch_enabled?
|
|
268
276
|
end
|
|
269
277
|
|
|
270
|
-
|
|
271
|
-
|
|
278
|
+
multisearch_enabled_before = values.pop
|
|
279
|
+
multisearch_enabled_inside = nil
|
|
280
|
+
described_class.disable_multisearch do
|
|
272
281
|
sync.push :go
|
|
273
|
-
|
|
282
|
+
multisearch_enabled_inside = values.pop
|
|
274
283
|
end
|
|
275
284
|
sync.push :go
|
|
276
|
-
|
|
285
|
+
multisearch_enabled_after = values.pop
|
|
277
286
|
|
|
278
|
-
expect(
|
|
279
|
-
expect(
|
|
280
|
-
expect(
|
|
287
|
+
expect(multisearch_enabled_before).to be(true)
|
|
288
|
+
expect(multisearch_enabled_inside).to be(true)
|
|
289
|
+
expect(multisearch_enabled_after).to be(true)
|
|
281
290
|
end
|
|
291
|
+
# standard:enable RSpec/ExampleLength
|
|
282
292
|
end
|
|
283
293
|
end
|
|
294
|
+
# standard:enable RSpec/NestedGroups
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
|
|
3
|
+
require "warning"
|
|
4
|
+
|
|
5
|
+
# https://github.com/grodowski/undercover#setting-up-required-lcov-reporting
|
|
6
|
+
require "simplecov"
|
|
7
|
+
require "simplecov-lcov"
|
|
8
|
+
SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true
|
|
9
|
+
SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter
|
|
10
|
+
SimpleCov.start do
|
|
11
|
+
add_filter(%r{^/spec/})
|
|
12
|
+
enable_coverage(:branch)
|
|
13
|
+
end
|
|
14
|
+
require "undercover"
|
|
5
15
|
|
|
6
16
|
require "bundler/setup"
|
|
7
17
|
require "pg_search"
|
|
8
18
|
|
|
9
19
|
RSpec.configure do |config|
|
|
10
|
-
config.expect_with :rspec do |
|
|
11
|
-
|
|
20
|
+
config.expect_with :rspec do |expects|
|
|
21
|
+
expects.syntax = :expect
|
|
12
22
|
end
|
|
13
23
|
|
|
14
|
-
config.mock_with :rspec do |
|
|
15
|
-
|
|
24
|
+
config.mock_with :rspec do |mocks|
|
|
25
|
+
mocks.syntax = :expect
|
|
26
|
+
mocks.verify_doubled_constant_names = true
|
|
27
|
+
mocks.verify_partial_doubles = true
|
|
16
28
|
end
|
|
17
29
|
|
|
18
|
-
config.example_status_persistence_file_path =
|
|
30
|
+
config.example_status_persistence_file_path = "tmp/examples.txt"
|
|
19
31
|
end
|
|
20
32
|
|
|
21
|
-
require
|
|
22
|
-
require
|
|
33
|
+
require "support/database"
|
|
34
|
+
require "support/with_model"
|
|
23
35
|
|
|
24
36
|
DOCUMENTS_SCHEMA = lambda do |t|
|
|
25
37
|
t.belongs_to :searchable, polymorphic: true, index: true
|
data/spec/support/database.rb
CHANGED
|
@@ -10,10 +10,12 @@ else
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
begin
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
connection_options = {adapter: "postgresql", database: "pg_search_test", min_messages: "warning"}
|
|
14
|
+
if ENV["CI"]
|
|
15
|
+
connection_options[:username] = "postgres"
|
|
16
|
+
connection_options[:password] = "postgres"
|
|
17
|
+
end
|
|
18
|
+
ActiveRecord::Base.establish_connection(connection_options)
|
|
17
19
|
connection = ActiveRecord::Base.connection
|
|
18
20
|
connection.execute("SELECT 1")
|
|
19
21
|
rescue ERROR_CLASS, ActiveRecord::NoDatabaseError => e
|
|
@@ -29,7 +31,7 @@ end
|
|
|
29
31
|
|
|
30
32
|
if ENV["LOGGER"]
|
|
31
33
|
require "logger"
|
|
32
|
-
ActiveRecord::Base.logger = Logger.new(
|
|
34
|
+
ActiveRecord::Base.logger = Logger.new($stdout)
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
def install_extension(name)
|
|
@@ -38,7 +40,7 @@ def install_extension(name)
|
|
|
38
40
|
return unless extension.none?
|
|
39
41
|
|
|
40
42
|
connection.execute "CREATE EXTENSION #{name};"
|
|
41
|
-
rescue
|
|
43
|
+
rescue => e
|
|
42
44
|
at_exit do
|
|
43
45
|
puts "-" * 80
|
|
44
46
|
puts "Please install the #{name} extension"
|
|
@@ -50,7 +52,7 @@ end
|
|
|
50
52
|
def install_extension_if_missing(name, query, expected_result)
|
|
51
53
|
result = ActiveRecord::Base.connection.select_value(query)
|
|
52
54
|
raise "Unexpected output for #{query}: #{result.inspect}" unless result.casecmp(expected_result).zero?
|
|
53
|
-
rescue
|
|
55
|
+
rescue
|
|
54
56
|
install_extension(name)
|
|
55
57
|
end
|
|
56
58
|
|
|
@@ -60,7 +62,7 @@ install_extension_if_missing("fuzzystrmatch", "SELECT dmetaphone('foo')", "f")
|
|
|
60
62
|
|
|
61
63
|
def load_sql(filename)
|
|
62
64
|
connection = ActiveRecord::Base.connection
|
|
63
|
-
file_contents = File.read(File.join(File.dirname(__FILE__),
|
|
65
|
+
file_contents = File.read(File.join(File.dirname(__FILE__), "..", "..", "sql", filename))
|
|
64
66
|
connection.execute(file_contents)
|
|
65
67
|
end
|
|
66
68
|
|
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pg_search
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.3.
|
|
4
|
+
version: 2.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Grant Hutchins
|
|
8
8
|
- Case Commons, LLC
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2024-08-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activerecord
|
|
@@ -17,126 +17,28 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
20
|
+
version: '6.1'
|
|
21
21
|
type: :runtime
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
25
|
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
27
|
+
version: '6.1'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: activesupport
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
32
|
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
34
|
+
version: '6.1'
|
|
35
35
|
type: :runtime
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
39
|
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
42
|
-
- !ruby/object:Gem::Dependency
|
|
43
|
-
name: pry
|
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
|
45
|
-
requirements:
|
|
46
|
-
- - ">="
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '0'
|
|
49
|
-
type: :development
|
|
50
|
-
prerelease: false
|
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
-
requirements:
|
|
53
|
-
- - ">="
|
|
54
|
-
- !ruby/object:Gem::Version
|
|
55
|
-
version: '0'
|
|
56
|
-
- !ruby/object:Gem::Dependency
|
|
57
|
-
name: rake
|
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
|
59
|
-
requirements:
|
|
60
|
-
- - ">="
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
version: '0'
|
|
63
|
-
type: :development
|
|
64
|
-
prerelease: false
|
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
66
|
-
requirements:
|
|
67
|
-
- - ">="
|
|
68
|
-
- !ruby/object:Gem::Version
|
|
69
|
-
version: '0'
|
|
70
|
-
- !ruby/object:Gem::Dependency
|
|
71
|
-
name: rspec
|
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
|
73
|
-
requirements:
|
|
74
|
-
- - ">="
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '3.3'
|
|
77
|
-
type: :development
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
-
requirements:
|
|
81
|
-
- - ">="
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: '3.3'
|
|
84
|
-
- !ruby/object:Gem::Dependency
|
|
85
|
-
name: rubocop
|
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
|
87
|
-
requirements:
|
|
88
|
-
- - ">="
|
|
89
|
-
- !ruby/object:Gem::Version
|
|
90
|
-
version: 0.78.0
|
|
91
|
-
type: :development
|
|
92
|
-
prerelease: false
|
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
94
|
-
requirements:
|
|
95
|
-
- - ">="
|
|
96
|
-
- !ruby/object:Gem::Version
|
|
97
|
-
version: 0.78.0
|
|
98
|
-
- !ruby/object:Gem::Dependency
|
|
99
|
-
name: rubocop-performance
|
|
100
|
-
requirement: !ruby/object:Gem::Requirement
|
|
101
|
-
requirements:
|
|
102
|
-
- - ">="
|
|
103
|
-
- !ruby/object:Gem::Version
|
|
104
|
-
version: '0'
|
|
105
|
-
type: :development
|
|
106
|
-
prerelease: false
|
|
107
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
108
|
-
requirements:
|
|
109
|
-
- - ">="
|
|
110
|
-
- !ruby/object:Gem::Version
|
|
111
|
-
version: '0'
|
|
112
|
-
- !ruby/object:Gem::Dependency
|
|
113
|
-
name: simplecov
|
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
|
115
|
-
requirements:
|
|
116
|
-
- - ">="
|
|
117
|
-
- !ruby/object:Gem::Version
|
|
118
|
-
version: '0'
|
|
119
|
-
type: :development
|
|
120
|
-
prerelease: false
|
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
122
|
-
requirements:
|
|
123
|
-
- - ">="
|
|
124
|
-
- !ruby/object:Gem::Version
|
|
125
|
-
version: '0'
|
|
126
|
-
- !ruby/object:Gem::Dependency
|
|
127
|
-
name: with_model
|
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
|
129
|
-
requirements:
|
|
130
|
-
- - ">="
|
|
131
|
-
- !ruby/object:Gem::Version
|
|
132
|
-
version: '1.2'
|
|
133
|
-
type: :development
|
|
134
|
-
prerelease: false
|
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
136
|
-
requirements:
|
|
137
|
-
- - ">="
|
|
138
|
-
- !ruby/object:Gem::Version
|
|
139
|
-
version: '1.2'
|
|
41
|
+
version: '6.1'
|
|
140
42
|
description: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
|
|
141
43
|
full text search
|
|
142
44
|
email:
|
|
@@ -146,15 +48,16 @@ executables: []
|
|
|
146
48
|
extensions: []
|
|
147
49
|
extra_rdoc_files: []
|
|
148
50
|
files:
|
|
149
|
-
- ".autotest"
|
|
150
51
|
- ".bundle/config"
|
|
151
|
-
- ".codeclimate.yml"
|
|
152
52
|
- ".editorconfig"
|
|
53
|
+
- ".github/dependabot.yml"
|
|
54
|
+
- ".github/workflows/ci.yml"
|
|
153
55
|
- ".gitignore"
|
|
56
|
+
- ".jrubyrc"
|
|
154
57
|
- ".rspec"
|
|
155
|
-
- ".
|
|
156
|
-
- ".travis.yml"
|
|
58
|
+
- ".standard.yml"
|
|
157
59
|
- CHANGELOG.md
|
|
60
|
+
- CODE_OF_CONDUCT.md
|
|
158
61
|
- CONTRIBUTING.md
|
|
159
62
|
- Gemfile
|
|
160
63
|
- LICENSE
|
|
@@ -187,6 +90,7 @@ files:
|
|
|
187
90
|
- lib/pg_search/version.rb
|
|
188
91
|
- pg_search.gemspec
|
|
189
92
|
- spec/.rubocop.yml
|
|
93
|
+
- spec/integration/.rubocop.yml
|
|
190
94
|
- spec/integration/associations_spec.rb
|
|
191
95
|
- spec/integration/deprecation_spec.rb
|
|
192
96
|
- spec/integration/pagination_spec.rb
|
|
@@ -211,8 +115,9 @@ files:
|
|
|
211
115
|
homepage: https://github.com/Casecommons/pg_search
|
|
212
116
|
licenses:
|
|
213
117
|
- MIT
|
|
214
|
-
metadata:
|
|
215
|
-
|
|
118
|
+
metadata:
|
|
119
|
+
rubygems_mfa_required: 'true'
|
|
120
|
+
post_install_message:
|
|
216
121
|
rdoc_options: []
|
|
217
122
|
require_paths:
|
|
218
123
|
- lib
|
|
@@ -220,35 +125,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
220
125
|
requirements:
|
|
221
126
|
- - ">="
|
|
222
127
|
- !ruby/object:Gem::Version
|
|
223
|
-
version: '
|
|
128
|
+
version: '3.0'
|
|
224
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
130
|
requirements:
|
|
226
131
|
- - ">="
|
|
227
132
|
- !ruby/object:Gem::Version
|
|
228
133
|
version: '0'
|
|
229
134
|
requirements: []
|
|
230
|
-
rubygems_version: 3.
|
|
231
|
-
signing_key:
|
|
135
|
+
rubygems_version: 3.5.11
|
|
136
|
+
signing_key:
|
|
232
137
|
specification_version: 4
|
|
233
138
|
summary: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
|
|
234
139
|
full text search
|
|
235
|
-
test_files:
|
|
236
|
-
- spec/integration/associations_spec.rb
|
|
237
|
-
- spec/integration/deprecation_spec.rb
|
|
238
|
-
- spec/integration/pagination_spec.rb
|
|
239
|
-
- spec/integration/pg_search_spec.rb
|
|
240
|
-
- spec/integration/single_table_inheritance_spec.rb
|
|
241
|
-
- spec/lib/pg_search/configuration/association_spec.rb
|
|
242
|
-
- spec/lib/pg_search/configuration/column_spec.rb
|
|
243
|
-
- spec/lib/pg_search/configuration/foreign_column_spec.rb
|
|
244
|
-
- spec/lib/pg_search/features/dmetaphone_spec.rb
|
|
245
|
-
- spec/lib/pg_search/features/trigram_spec.rb
|
|
246
|
-
- spec/lib/pg_search/features/tsearch_spec.rb
|
|
247
|
-
- spec/lib/pg_search/multisearch/rebuilder_spec.rb
|
|
248
|
-
- spec/lib/pg_search/multisearch_spec.rb
|
|
249
|
-
- spec/lib/pg_search/multisearchable_spec.rb
|
|
250
|
-
- spec/lib/pg_search/normalizer_spec.rb
|
|
251
|
-
- spec/lib/pg_search_spec.rb
|
|
252
|
-
- spec/spec_helper.rb
|
|
253
|
-
- spec/support/database.rb
|
|
254
|
-
- spec/support/with_model.rb
|
|
140
|
+
test_files: []
|