pg_search 2.3.6 → 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/workflows/ci.yml +21 -16
- data/.standard.yml +6 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +19 -6
- data/LICENSE +1 -1
- data/README.md +49 -32
- data/Rakefile +4 -7
- 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 +1 -1
- data/lib/pg_search/document.rb +8 -8
- data/lib/pg_search/features/dmetaphone.rb +1 -1
- data/lib/pg_search/features/trigram.rb +4 -4
- data/lib/pg_search/features/tsearch.rb +14 -13
- 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/model.rb +6 -6
- data/lib/pg_search/multisearch.rb +4 -2
- data/lib/pg_search/multisearchable.rb +7 -7
- data/lib/pg_search/normalizer.rb +5 -5
- data/lib/pg_search/scope_options.rb +26 -5
- data/lib/pg_search/tasks.rb +2 -2
- data/lib/pg_search/version.rb +1 -1
- data/lib/pg_search.rb +3 -3
- data/pg_search.gemspec +16 -31
- data/spec/.rubocop.yml +20 -7
- data/spec/integration/.rubocop.yml +2 -2
- data/spec/integration/associations_spec.rb +106 -106
- data/spec/integration/deprecation_spec.rb +7 -8
- data/spec/integration/pg_search_spec.rb +314 -298
- data/spec/integration/single_table_inheritance_spec.rb +5 -5
- data/spec/lib/pg_search/configuration/association_spec.rb +15 -15
- 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 +29 -29
- data/spec/lib/pg_search/features/tsearch_spec.rb +57 -39
- data/spec/lib/pg_search/multisearch/rebuilder_spec.rb +17 -17
- data/spec/lib/pg_search/multisearch_spec.rb +6 -6
- data/spec/lib/pg_search/multisearchable_spec.rb +26 -26
- data/spec/lib/pg_search/normalizer_spec.rb +7 -7
- data/spec/lib/pg_search_spec.rb +18 -18
- data/spec/spec_helper.rb +7 -9
- data/spec/support/database.rb +6 -6
- metadata +10 -214
- data/.codeclimate.yml +0 -17
- data/.rubocop.yml +0 -137
- data/.travis.yml +0 -37
@@ -7,9 +7,11 @@ module PgSearch
|
|
7
7
|
class << self
|
8
8
|
def rebuild(model, deprecated_clean_up = nil, clean_up: true, transactional: true)
|
9
9
|
unless deprecated_clean_up.nil?
|
10
|
-
|
10
|
+
warn(
|
11
11
|
"pg_search 3.0 will no longer accept a boolean second argument to PgSearchMultisearch.rebuild, " \
|
12
|
-
"use keyword argument `clean_up:` instead."
|
12
|
+
"use keyword argument `clean_up:` instead.",
|
13
|
+
category: :deprecated,
|
14
|
+
uplevel: 1
|
13
15
|
)
|
14
16
|
clean_up = deprecated_clean_up
|
15
17
|
end
|
@@ -7,12 +7,12 @@ module PgSearch
|
|
7
7
|
def self.included(mod)
|
8
8
|
mod.class_eval do
|
9
9
|
has_one :pg_search_document,
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
as: :searchable,
|
11
|
+
class_name: "PgSearch::Document",
|
12
|
+
dependent: :delete
|
13
13
|
|
14
14
|
after_save :update_pg_search_document,
|
15
|
-
|
15
|
+
if: -> { PgSearch.multisearch_enabled? }
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -39,7 +39,7 @@ module PgSearch
|
|
39
39
|
conditions.all? { |condition| condition.to_proc.call(self) }
|
40
40
|
end
|
41
41
|
|
42
|
-
def update_pg_search_document
|
42
|
+
def update_pg_search_document
|
43
43
|
if_conditions = Array(pg_search_multisearchable_options[:if])
|
44
44
|
unless_conditions = Array(pg_search_multisearchable_options[:unless])
|
45
45
|
|
@@ -50,7 +50,7 @@ module PgSearch
|
|
50
50
|
if should_have_document
|
51
51
|
create_or_update_pg_search_document
|
52
52
|
else
|
53
|
-
pg_search_document&.destroy
|
53
|
+
pg_search_document&.destroy # standard:disable Rails/SaveBang
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -58,7 +58,7 @@ module PgSearch
|
|
58
58
|
if !pg_search_document
|
59
59
|
create_pg_search_document(pg_search_document_attrs)
|
60
60
|
elsif should_update_pg_search_document?
|
61
|
-
pg_search_document.update(pg_search_document_attrs)
|
61
|
+
pg_search_document.update(pg_search_document_attrs) # standard:disable Rails/SaveBang
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
data/lib/pg_search/normalizer.rb
CHANGED
@@ -10,11 +10,11 @@ module PgSearch
|
|
10
10
|
return sql_expression unless config.ignore.include?(:accents)
|
11
11
|
|
12
12
|
sql_node = case sql_expression
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
when Arel::Nodes::Node
|
14
|
+
sql_expression
|
15
|
+
else
|
16
|
+
Arel.sql(sql_expression)
|
17
|
+
end
|
18
18
|
|
19
19
|
Arel::Nodes::NamedFunction.new(
|
20
20
|
PgSearch.unaccent_function,
|
@@ -90,11 +90,32 @@ module PgSearch
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def conditions
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
expressions =
|
94
|
+
config.features
|
95
|
+
.reject { |_feature_name, feature_options| feature_options && feature_options[:sort_only] }
|
96
|
+
.map { |feature_name, _feature_options| feature_for(feature_name).conditions }
|
97
|
+
|
98
|
+
or_node(expressions)
|
99
|
+
end
|
100
|
+
|
101
|
+
# https://github.com/rails/rails/pull/51492
|
102
|
+
# :nocov:
|
103
|
+
# standard:disable Lint/DuplicateMethods
|
104
|
+
or_arity = Arel::Nodes::Or.instance_method(:initialize).arity
|
105
|
+
case or_arity
|
106
|
+
when 1
|
107
|
+
def or_node(expressions)
|
108
|
+
Arel::Nodes::Or.new(expressions)
|
109
|
+
end
|
110
|
+
when 2
|
111
|
+
def or_node(expressions)
|
112
|
+
expressions.inject { |accumulator, expression| Arel::Nodes::Or.new(accumulator, expression) }
|
113
|
+
end
|
114
|
+
else
|
115
|
+
raise "Unsupported arity #{or_arity} for Arel::Nodes::Or#initialize"
|
97
116
|
end
|
117
|
+
# :nocov:
|
118
|
+
# standard:enable Lint/DuplicateMethods
|
98
119
|
|
99
120
|
def order_within_rank
|
100
121
|
config.order_within_rank || "#{primary_key} ASC"
|
@@ -108,7 +129,7 @@ module PgSearch
|
|
108
129
|
if config.associations.any?
|
109
130
|
config.associations.map do |association|
|
110
131
|
association.join(primary_key)
|
111
|
-
end.join(
|
132
|
+
end.join(" ")
|
112
133
|
end
|
113
134
|
end
|
114
135
|
|
data/lib/pg_search/tasks.rb
CHANGED
data/lib/pg_search/version.rb
CHANGED
data/lib/pg_search.rb
CHANGED
@@ -18,7 +18,7 @@ module PgSearch
|
|
18
18
|
autoload :Document, "pg_search/document"
|
19
19
|
|
20
20
|
def self.included(base)
|
21
|
-
|
21
|
+
warn(<<~MESSAGE, category: :deprecated, uplevel: 1)
|
22
22
|
Directly including `PgSearch` into an Active Record model is deprecated and will be removed in pg_search 3.0.
|
23
23
|
|
24
24
|
Please replace `include PgSearch` with `include PgSearch::Model`.
|
@@ -34,8 +34,8 @@ module PgSearch
|
|
34
34
|
self.unaccent_function = "unaccent"
|
35
35
|
|
36
36
|
class << self
|
37
|
-
def multisearch(
|
38
|
-
PgSearch::Document.search(
|
37
|
+
def multisearch(...)
|
38
|
+
PgSearch::Document.search(...)
|
39
39
|
end
|
40
40
|
|
41
41
|
def disable_multisearch
|
data/pg_search.gemspec
CHANGED
@@ -1,40 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.push File.expand_path(
|
4
|
-
require
|
3
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
4
|
+
require "pg_search/version"
|
5
5
|
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
s.platform
|
10
|
-
s.authors
|
11
|
-
s.email
|
12
|
-
s.homepage
|
13
|
-
s.summary
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "pg_search"
|
8
|
+
s.version = PgSearch::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Grant Hutchins", "Case Commons, LLC"]
|
11
|
+
s.email = %w[gems@nertzy.com casecommons-dev@googlegroups.com]
|
12
|
+
s.homepage = "https://github.com/Casecommons/pg_search"
|
13
|
+
s.summary = "PgSearch builds Active Record named scopes that take advantage of PostgreSQL's full text search"
|
14
14
|
s.description = "PgSearch builds Active Record named scopes that take advantage of PostgreSQL's full text search"
|
15
|
-
s.licenses
|
15
|
+
s.licenses = ["MIT"]
|
16
16
|
s.metadata["rubygems_mfa_required"] = "true"
|
17
17
|
|
18
|
-
s.files
|
19
|
-
s.
|
20
|
-
s.require_paths = ['lib']
|
18
|
+
s.files = `git ls-files -z`.split("\x0")
|
19
|
+
s.require_paths = ["lib"]
|
21
20
|
|
22
|
-
s.add_dependency
|
23
|
-
s.add_dependency
|
21
|
+
s.add_dependency "activerecord", ">= 6.1"
|
22
|
+
s.add_dependency "activesupport", ">= 6.1"
|
24
23
|
|
25
|
-
s.
|
26
|
-
s.add_development_dependency 'rake'
|
27
|
-
s.add_development_dependency 'rspec'
|
28
|
-
s.add_development_dependency 'rubocop'
|
29
|
-
s.add_development_dependency 'rubocop-performance'
|
30
|
-
s.add_development_dependency 'rubocop-rails'
|
31
|
-
s.add_development_dependency 'rubocop-rake'
|
32
|
-
s.add_development_dependency 'rubocop-rspec'
|
33
|
-
s.add_development_dependency 'simplecov'
|
34
|
-
s.add_development_dependency 'simplecov-lcov'
|
35
|
-
s.add_development_dependency 'undercover'
|
36
|
-
s.add_development_dependency 'warning'
|
37
|
-
s.add_development_dependency 'with_model'
|
38
|
-
|
39
|
-
s.required_ruby_version = '>= 2.6'
|
24
|
+
s.required_ruby_version = ">= 3.0"
|
40
25
|
end
|
data/spec/.rubocop.yml
CHANGED
@@ -1,14 +1,27 @@
|
|
1
1
|
inherit_from:
|
2
2
|
- ../.rubocop.yml
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
RSpec/ContextWording:
|
5
|
+
Prefixes:
|
6
|
+
- using
|
7
|
+
- via
|
8
|
+
- when
|
9
|
+
- with
|
10
|
+
- without
|
6
11
|
|
7
|
-
|
8
|
-
Enabled:
|
12
|
+
RSpec/DescribedClass:
|
13
|
+
Enabled: true
|
9
14
|
|
10
|
-
|
11
|
-
|
15
|
+
RSpec/ExampleLength:
|
16
|
+
Max: 15
|
12
17
|
|
13
|
-
|
18
|
+
RSpec/ExpectInHook:
|
14
19
|
Enabled: false
|
20
|
+
|
21
|
+
RSpec/FilePath:
|
22
|
+
CustomTransform:
|
23
|
+
TSearch: "tsearch"
|
24
|
+
DMetaphone: "dmetaphone"
|
25
|
+
|
26
|
+
RSpec/MultipleExpectations:
|
27
|
+
Max: 5
|