pg_search 2.3.1 → 2.3.2
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/.travis.yml +1 -0
- data/CHANGELOG.md +5 -0
- data/lib/pg_search.rb +2 -4
- data/lib/pg_search/multisearch/rebuilder.rb +5 -1
- data/lib/pg_search/version.rb +1 -1
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +28 -1
- data/spec/lib/pg_search/multisearch_spec.rb +1 -1
- data/spec/lib/pg_search/multisearchable_spec.rb +1 -1
- data/spec/lib/pg_search_spec.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c16f0c4421b4d6d6f4c247f556c4eb2fdb01242617a1e960fdd15785be84dbf
|
4
|
+
data.tar.gz: f580e760db34c55abf2401176681f8053500e3d249dd51edf8dce0dfb251f641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f649091265d7b174c6b826a38e1f80f5eb57851184d2af4720926982d42c41ee1a4bc9399ca0cb1031c31f9a40313215cced168cb99d0a1cf65000fd7c4c6be9
|
7
|
+
data.tar.gz: 42c651d0689300bd1328089814562fe575a43d3cf522365b51f2de828eb33cc55d7eab69d242d525228e62d46bc99f74391e0569c4ef4cd39f27bbaec5deb073
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# pg_search changelog
|
2
2
|
|
3
|
+
## 2.3.2
|
4
|
+
|
5
|
+
* Autoload PgSearch::Document to prevent it from being loaded in projects that are not using multi-search.
|
6
|
+
* Rebuilder should use update_pg_search_document if additional_attributes is set (David Ramalho)
|
7
|
+
|
3
8
|
## 2.3.1
|
4
9
|
|
5
10
|
* Drop support for Active Record < 5.2
|
data/lib/pg_search.rb
CHANGED
@@ -15,6 +15,8 @@ require "pg_search/scope_options"
|
|
15
15
|
require "pg_search/version"
|
16
16
|
|
17
17
|
module PgSearch
|
18
|
+
autoload :Document, "pg_search/document"
|
19
|
+
|
18
20
|
def self.included(base)
|
19
21
|
ActiveSupport::Deprecation.warn <<-MESSAGE.strip_heredoc
|
20
22
|
Directly including `PgSearch` into an Active Record model is deprecated and will be removed in pg_search 3.0.
|
@@ -67,8 +69,4 @@ module PgSearch
|
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
70
|
-
ActiveSupport.on_load(:active_record) do
|
71
|
-
require "pg_search/document"
|
72
|
-
end
|
73
|
-
|
74
72
|
require "pg_search/railtie" if defined?(Rails::Railtie)
|
@@ -13,7 +13,7 @@ module PgSearch
|
|
13
13
|
def rebuild
|
14
14
|
if model.respond_to?(:rebuild_pg_search_documents)
|
15
15
|
model.rebuild_pg_search_documents
|
16
|
-
elsif conditional? || dynamic?
|
16
|
+
elsif conditional? || dynamic? || additional_attributes?
|
17
17
|
model.find_each(&:update_pg_search_document)
|
18
18
|
else
|
19
19
|
model.connection.execute(rebuild_sql)
|
@@ -33,6 +33,10 @@ module PgSearch
|
|
33
33
|
columns.any? { |column| !column_names.include?(column.to_s) }
|
34
34
|
end
|
35
35
|
|
36
|
+
def additional_attributes?
|
37
|
+
model.pg_search_multisearchable_options.key?(:additional_attributes)
|
38
|
+
end
|
39
|
+
|
36
40
|
def connection
|
37
41
|
model.connection
|
38
42
|
end
|
data/lib/pg_search/version.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe PgSearch::Multisearch::Rebuilder do
|
6
|
-
with_table "pg_search_documents",
|
6
|
+
with_table "pg_search_documents", &DOCUMENTS_SCHEMA
|
7
7
|
|
8
8
|
describe 'when initialized with a model that is not multisearchable' do
|
9
9
|
with_model :not_multisearchable
|
@@ -223,6 +223,33 @@ describe PgSearch::Multisearch::Rebuilder do
|
|
223
223
|
expect(record.pg_search_document).to be_present
|
224
224
|
end
|
225
225
|
end
|
226
|
+
|
227
|
+
context "when only additional_attributes is set" do
|
228
|
+
with_model :Model do
|
229
|
+
table do |t|
|
230
|
+
t.string :name
|
231
|
+
end
|
232
|
+
|
233
|
+
model do
|
234
|
+
include PgSearch::Model
|
235
|
+
multisearchable against: :name,
|
236
|
+
additional_attributes: ->(obj) { { additional_attribute_column: "#{obj.class}::#{obj.id}" } }
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
it "calls update_pg_search_document on each record" do
|
241
|
+
record_1 = Model.create!(name: "record_1", id: 1)
|
242
|
+
record_2 = Model.create!(name: "record_2", id: 2)
|
243
|
+
|
244
|
+
PgSearch::Document.delete_all
|
245
|
+
|
246
|
+
rebuilder = PgSearch::Multisearch::Rebuilder.new(Model)
|
247
|
+
rebuilder.rebuild
|
248
|
+
|
249
|
+
expect(record_1.reload.pg_search_document.additional_attribute_column).to eq("Model::1")
|
250
|
+
expect(record_2.reload.pg_search_document.additional_attribute_column).to eq("Model::2")
|
251
|
+
end
|
252
|
+
end
|
226
253
|
end
|
227
254
|
|
228
255
|
context "and multisearchable is conditional" do
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
5
|
describe PgSearch::Multisearchable do
|
6
|
-
with_table "pg_search_documents",
|
6
|
+
with_table "pg_search_documents", &DOCUMENTS_SCHEMA
|
7
7
|
|
8
8
|
describe "a model that is multisearchable" do
|
9
9
|
with_model :ModelThatIsMultisearchable do
|
data/spec/lib/pg_search_spec.rb
CHANGED
@@ -17,7 +17,7 @@ end
|
|
17
17
|
|
18
18
|
describe PgSearch do
|
19
19
|
describe ".multisearch" do
|
20
|
-
with_table "pg_search_documents",
|
20
|
+
with_table "pg_search_documents", &DOCUMENTS_SCHEMA
|
21
21
|
|
22
22
|
describe "delegation to PgSearch::Document.search" do
|
23
23
|
subject { PgSearch.multisearch(query) }
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grant Hutchins
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
230
|
+
rubygems_version: 3.1.2
|
231
231
|
signing_key:
|
232
232
|
specification_version: 4
|
233
233
|
summary: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
|