pg_search 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 253c1319e785dfac16b15e9ffc72d7d37b60eda5
4
- data.tar.gz: 78931e1fac31befac51f12b5ae2c26c13a11994a
3
+ metadata.gz: 39a86d998120bf6ec9643f8f8b549b08956576ff
4
+ data.tar.gz: fd3a0e7c1aea025553e4c1747d009a9911628d37
5
5
  SHA512:
6
- metadata.gz: 53f22f8135d1992271bae14aa8b77cc76fd75d625b60c01075157383f9716c3aee9e1bf6e404e79b21cdbb0a7e611c9b820e3553a05485ba485f3b404a2afa28
7
- data.tar.gz: 768c5c7a66b4875cce05f12b4e0bbe50ddd8dc8a6bd3afdcb2acf9db2334ffe1ad1d04d99814a0bf38876a7829320faeda5227886a13b5c81720a33d7438223b
6
+ metadata.gz: 84aa3f0816a2aca1523b9bd418abb4445b2290eb5a3177870e43a52e1ca341271e9211042496198b8e2d9ba7c39c6b53afd2f10bc272544478976bafde763265
7
+ data.tar.gz: e4657a3efc304b264cb0640c1755be9f9cbbc01afb1804f5625dfea24498f5ab21b1e707801cf3c22df63e462bb7add5e737060a6f9b67ddbfbae600d53a3a5c
@@ -45,3 +45,8 @@ Bundler/DuplicatedGem:
45
45
 
46
46
  Style/EmptyMethod:
47
47
  EnforcedStyle: expanded
48
+
49
+ # Waiting on false positives to go away with:
50
+ # https://github.com/bbatsov/rubocop/pull/5230
51
+ Style/FormatStringToken:
52
+ Enabled: false
@@ -6,13 +6,14 @@ rvm:
6
6
  - "2.3.4"
7
7
  - "2.2.7"
8
8
  - "2.1.10"
9
- - jruby-9.1.9.0
9
+ - jruby-9.1.14.0
10
10
 
11
11
  env:
12
12
  - ACTIVE_RECORD_BRANCH="master"
13
13
  - ACTIVE_RECORD_BRANCH="5-1-stable"
14
14
  - ACTIVE_RECORD_BRANCH="5-0-stable"
15
15
  - ACTIVE_RECORD_BRANCH="4-2-stable"
16
+ - ACTIVE_RECORD_VERSION="~> 5.2.0.beta2"
16
17
  - ACTIVE_RECORD_VERSION="~> 5.1.0"
17
18
  - ACTIVE_RECORD_VERSION="~> 5.0.0"
18
19
  - ACTIVE_RECORD_VERSION="~> 4.2.9"
@@ -23,6 +24,7 @@ matrix:
23
24
  - env: ACTIVE_RECORD_BRANCH="5-1-stable"
24
25
  - env: ACTIVE_RECORD_BRANCH="5-0-stable"
25
26
  - env: ACTIVE_RECORD_BRANCH="4-2-stable"
27
+ - rvm: jruby-9.1.14.0
26
28
  exclude:
27
29
  - rvm: "2.1.10"
28
30
  env: ACTIVE_RECORD_BRANCH="master"
@@ -34,15 +36,17 @@ matrix:
34
36
  env: ACTIVE_RECORD_VERSION="~> 5.1.0"
35
37
  - rvm: "2.1.10"
36
38
  env: ACTIVE_RECORD_VERSION="~> 5.0.0"
37
- - rvm: jruby-9.1.9.0
39
+ - rvm: jruby-9.1.14.0
38
40
  env: ACTIVE_RECORD_BRANCH="master"
39
- - rvm: jruby-9.1.9.0
41
+ - rvm: jruby-9.1.14.0
40
42
  env: ACTIVE_RECORD_BRANCH="5-1-stable"
41
- - rvm: jruby-9.1.9.0
43
+ - rvm: jruby-9.1.14.0
42
44
  env: ACTIVE_RECORD_BRANCH="5-0-stable"
43
- - rvm: jruby-9.1.9.0
45
+ - rvm: jruby-9.1.14.0
46
+ env: ACTIVE_RECORD_VERSION="~> 5.2.0.beta2"
47
+ - rvm: jruby-9.1.14.0
44
48
  env: ACTIVE_RECORD_VERSION="~> 5.1.0"
45
- - rvm: jruby-9.1.9.0
49
+ - rvm: jruby-9.1.14.0
46
50
  env: ACTIVE_RECORD_VERSION="~> 5.0.0"
47
51
 
48
52
  before_script:
@@ -1,5 +1,9 @@
1
1
  # pg_search changelog
2
2
 
3
+ ## 2.1.2
4
+
5
+ * Silence warnings in Rails 5.2.0.beta2 (Kevin Deisz)
6
+
3
7
  ## 2.1.1
4
8
 
5
9
  * Support snake_case ts_headline options again (with deprecation warning)
@@ -25,9 +25,7 @@ module PgSearch
25
25
  options_proc = if options.respond_to?(:call)
26
26
  options
27
27
  else
28
- unless options.respond_to?(:merge)
29
- raise ArgumentError, "pg_search_scope expects a Hash or Proc"
30
- end
28
+ raise ArgumentError, "pg_search_scope expects a Hash or Proc" unless options.respond_to?(:merge)
31
29
  ->(query) { {:query => query}.merge(options) }
32
30
  end
33
31
 
@@ -39,7 +37,7 @@ module PgSearch
39
37
  end
40
38
 
41
39
  def multisearchable(options = {})
42
- include PgSearch::Multisearchable
40
+ include PgSearch::Multisearchable # rubocop:disable Style/MixinUsage
43
41
  class_attribute :pg_search_multisearchable_options
44
42
  self.pg_search_multisearchable_options = options
45
43
  end
@@ -92,14 +90,15 @@ module PgSearch
92
90
 
93
91
  class PgSearchRankNotSelected < StandardError
94
92
  def message
95
- "You must chain .with_pg_search_rank after the pg_search_scope to access the pg_search_rank attribute on returned records" # rubocop:disable Metrics/LineLength
93
+ "You must chain .with_pg_search_rank after the pg_search_scope " \
94
+ "to access the pg_search_rank attribute on returned records"
96
95
  end
97
96
  end
98
97
 
99
98
  class PgSearchHighlightNotSelected < StandardError
100
- # rubocop:disable Metrics/LineLength
101
99
  def message
102
- "You must chain .with_pg_search_highlight after the pg_search_scope to access the pg_search_highlight attribute on returned records"
100
+ "You must chain .with_pg_search_highlight after the pg_search_scope " \
101
+ "to access the pg_search_highlight attribute on returned records"
103
102
  end
104
103
  end
105
104
  end
@@ -96,9 +96,7 @@ module PgSearch
96
96
 
97
97
  VALID_VALUES.each do |key, values_for_key|
98
98
  Array(options[key]).each do |value|
99
- unless values_for_key.include?(value)
100
- raise ArgumentError, ":#{key} cannot accept #{value}"
101
- end
99
+ raise ArgumentError, ":#{key} cannot accept #{value}" unless values_for_key.include?(value)
102
100
  end
103
101
  end
104
102
  end
@@ -2,9 +2,7 @@ module PgSearch
2
2
  module Multisearch
3
3
  class Rebuilder
4
4
  def initialize(model, time_source = Time.method(:now))
5
- unless model.respond_to?(:pg_search_multisearchable_options)
6
- raise ModelNotMultisearchable.new(model)
7
- end
5
+ raise ModelNotMultisearchable.new(model) unless model.respond_to?(:pg_search_multisearchable_options)
8
6
 
9
7
  @model = model
10
8
  @time_source = time_source
@@ -65,9 +63,7 @@ module PgSearch
65
63
  clause = ""
66
64
  if model.column_names.include? model.inheritance_column
67
65
  clause = "WHERE"
68
- if model.base_class == model
69
- clause = "#{clause} #{model.inheritance_column} IS NULL OR"
70
- end
66
+ clause = "#{clause} #{model.inheritance_column} IS NULL OR" if model.base_class == model
71
67
  clause = "#{clause} #{model.inheritance_column} = #{model_name}"
72
68
  end
73
69
  clause
@@ -16,7 +16,7 @@ module PgSearch
16
16
 
17
17
  scope
18
18
  .joins(rank_join(rank_table_alias))
19
- .order("#{rank_table_alias}.rank DESC, #{order_within_rank}")
19
+ .order(Arel.sql("#{rank_table_alias}.rank DESC, #{order_within_rank}"))
20
20
  .extend(DisableEagerLoading)
21
21
  .extend(WithPgSearchRank)
22
22
  .extend(WithPgSearchHighlight[feature_for(:tsearch)])
@@ -1,3 +1,3 @@
1
1
  module PgSearch
2
- VERSION = "2.1.1".freeze
2
+ VERSION = "2.1.2".freeze
3
3
  end
@@ -20,13 +20,13 @@ Gem::Specification.new do |s|
20
20
  s.add_dependency 'activesupport', '>= 4.2'
21
21
  s.add_dependency 'arel', '>= 6'
22
22
 
23
- s.add_development_dependency 'rake'
23
+ s.add_development_dependency 'codeclimate-test-reporter'
24
24
  s.add_development_dependency 'pry'
25
+ s.add_development_dependency 'rake'
25
26
  s.add_development_dependency 'rspec', '>= 3.3'
26
- s.add_development_dependency 'with_model', '>= 1.2'
27
27
  s.add_development_dependency 'rubocop'
28
- s.add_development_dependency 'codeclimate-test-reporter'
29
28
  s.add_development_dependency 'simplecov'
29
+ s.add_development_dependency 'with_model', '>= 1.2'
30
30
 
31
31
  s.required_ruby_version = '>= 2.1'
32
32
  end
@@ -131,7 +131,7 @@ describe PgSearch do
131
131
 
132
132
  results = ModelWithHasMany
133
133
  .limit(1)
134
- .order("#{ModelWithHasMany.quoted_table_name}.id ASC")
134
+ .order(Arel.sql("#{ModelWithHasMany.quoted_table_name}.id ASC"))
135
135
  .with_associated('foo bar')
136
136
 
137
137
  expect(results.map(&:title)).to match_array(included.map(&:title))
@@ -100,10 +100,10 @@ describe PgSearch::Multisearch::Rebuilder do
100
100
  end
101
101
 
102
102
  it "should execute the default SQL" do
103
- time = DateTime.parse("2001-01-01")
103
+ time = Time.utc(2001, 1, 1, 0, 0, 0)
104
104
  rebuilder = PgSearch::Multisearch::Rebuilder.new(Model, -> { time })
105
105
 
106
- # Handle change in precision of DateTime objects in SQL in Active Record 4.0.1
106
+ # Handle change in precision of Time objects in SQL in Active Record 4.0.1
107
107
  # https://github.com/rails/rails/commit/17f5d8e062909f1fcae25351834d8e89967b645e
108
108
  expected_timestamp = has_microsecond_precision? ? "2001-01-01 00:00:00.000000" : "2001-01-01 00:00:00"
109
109
 
@@ -145,10 +145,10 @@ describe PgSearch::Multisearch::Rebuilder do
145
145
  end
146
146
 
147
147
  it "generates SQL with the correct primary key" do
148
- time = DateTime.parse("2001-01-01")
148
+ time = Time.utc(2001, 1, 1, 0, 0, 0)
149
149
  rebuilder = PgSearch::Multisearch::Rebuilder.new(ModelWithNonStandardPrimaryKey, -> { time })
150
150
 
151
- # Handle change in precision of DateTime objects in SQL in Active Record 4.0.1
151
+ # Handle change in precision of Time objects in SQL in Active Record 4.0.1
152
152
  # https://github.com/rails/rails/commit/17f5d8e062909f1fcae25351834d8e89967b645e
153
153
  expected_timestamp = has_microsecond_precision? ? "2001-01-01 00:00:00.000000" : "2001-01-01 00:00:00"
154
154
 
@@ -1,5 +1,18 @@
1
1
  require "spec_helper"
2
2
 
3
+ # For AR 5 and greater, the association reflection's cache needs be cleared
4
+ # because we're stubbing the related constants.
5
+ class << PgSearch::Document
6
+ if ActiveRecord::VERSION::MAJOR >= 5
7
+ def clear_searchable_cache
8
+ reflect_on_association(:searchable).clear_association_scope_cache
9
+ end
10
+ else
11
+ def clear_searchable_cache
12
+ end
13
+ end
14
+ end
15
+
3
16
  describe PgSearch do
4
17
  describe ".multisearch" do
5
18
  with_table "pg_search_documents", {}, &DOCUMENTS_SCHEMA
@@ -18,7 +31,10 @@ describe PgSearch do
18
31
 
19
32
  context "with PgSearch.multisearch_options set to a Hash" do
20
33
  before { allow(PgSearch).to receive(:multisearch_options).and_return(:using => :dmetaphone) }
21
- subject { PgSearch.multisearch(query).map(&:searchable) }
34
+ subject do
35
+ PgSearch::Document.clear_searchable_cache
36
+ PgSearch.multisearch(query).map(&:searchable)
37
+ end
22
38
 
23
39
  with_model :MultisearchableModel do
24
40
  table do |t|
@@ -36,7 +52,10 @@ describe PgSearch do
36
52
  end
37
53
 
38
54
  context "with PgSearch.multisearch_options set to a Proc" do
39
- subject { PgSearch.multisearch(query, soundalike).map(&:searchable) }
55
+ subject do
56
+ PgSearch::Document.clear_searchable_cache
57
+ PgSearch.multisearch(query, soundalike).map(&:searchable)
58
+ end
40
59
 
41
60
  before do
42
61
  allow(PgSearch).to receive(:multisearch_options) do
@@ -140,6 +159,7 @@ describe PgSearch do
140
159
 
141
160
  PgSearch::Multisearch.rebuild(SearchableSubclassModel)
142
161
 
162
+ PgSearch::Document.clear_searchable_cache
143
163
  expect(PgSearch::Document.count).to be 1
144
164
  expect(PgSearch::Document.first.searchable.class).to be SearchableSubclassModel
145
165
  expect(PgSearch::Document.first.searchable).to eq expected
@@ -153,6 +173,7 @@ describe PgSearch do
153
173
  PgSearch::Multisearch.rebuild(SearchableSubclassModel)
154
174
  expect(PgSearch::Document.count).to be 2
155
175
 
176
+ PgSearch::Document.clear_searchable_cache
156
177
  classes = PgSearch::Document.all.collect {|d| d.searchable.class }
157
178
  expect(classes).to include SearchableSubclassModel
158
179
  expect(classes).to include AnotherSearchableSubclassModel
@@ -223,7 +244,7 @@ describe PgSearch do
223
244
  @multisearch_enabled_inside = PgSearch.multisearch_enabled?
224
245
  raise
225
246
  end
226
- rescue # rubocop:disable Lint/RescueWithoutErrorClass
247
+ rescue StandardError
227
248
  end
228
249
 
229
250
  @multisearch_enabled_after = PgSearch.multisearch_enabled?
@@ -42,7 +42,7 @@ def install_extension(name)
42
42
  extension = connection.execute "SELECT * FROM pg_catalog.pg_extension WHERE extname = '#{name}';"
43
43
  return unless extension.none?
44
44
  connection.execute "CREATE EXTENSION #{name};"
45
- rescue => exception # rubocop:disable Lint/RescueWithoutErrorClass
45
+ rescue StandardError => exception
46
46
  at_exit do
47
47
  puts "-" * 80
48
48
  puts "Please install the #{name} extension"
@@ -54,7 +54,7 @@ end
54
54
  def install_extension_if_missing(name, query, expected_result)
55
55
  result = ActiveRecord::Base.connection.select_value(query)
56
56
  raise "Unexpected output for #{query}: #{result.inspect}" unless result.downcase == expected_result.downcase
57
- rescue # rubocop:disable Lint/RescueWithoutErrorClass
57
+ rescue StandardError
58
58
  install_extension(name)
59
59
  end
60
60
 
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.1.1
4
+ version: 2.1.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: 2017-09-20 00:00:00.000000000 Z
12
+ date: 2017-12-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -54,7 +54,7 @@ dependencies:
54
54
  - !ruby/object:Gem::Version
55
55
  version: '6'
56
56
  - !ruby/object:Gem::Dependency
57
- name: rake
57
+ name: codeclimate-test-reporter
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
@@ -82,33 +82,33 @@ dependencies:
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
- name: rspec
85
+ name: rake
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: '3.3'
90
+ version: '0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
- version: '3.3'
97
+ version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
- name: with_model
99
+ name: rspec
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: '1.2'
104
+ version: '3.3'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: '1.2'
111
+ version: '3.3'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rubocop
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -124,7 +124,7 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
- name: codeclimate-test-reporter
127
+ name: simplecov
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
@@ -138,19 +138,19 @@ dependencies:
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
- name: simplecov
141
+ name: with_model
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - ">="
145
145
  - !ruby/object:Gem::Version
146
- version: '0'
146
+ version: '1.2'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
- version: '0'
153
+ version: '1.2'
154
154
  description: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's
155
155
  full text search
156
156
  email:
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  requirements: []
243
243
  rubyforge_project:
244
- rubygems_version: 2.5.1
244
+ rubygems_version: 2.6.13
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: PgSearch builds Active Record named scopes that take advantage of PostgreSQL's