thinking-sphinx 5.2.1 → 5.3.0

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: 174a0193bd92fcdca5e1af880b893ddf5ae94e477e53c03f7684d48470042a89
4
- data.tar.gz: fe6b9df85b827b0ffec5a60ae9c691b4b50efa3774bd83854124e3639ecea93d
3
+ metadata.gz: 55eace64045aea4431c8a86005e70485efacfb15cc6768098c19fa89c4098d8c
4
+ data.tar.gz: e13db8a3a331535dd73aed4ffb965a130fdf8ae57df4241cafb4c6e1b421305f
5
5
  SHA512:
6
- metadata.gz: 7eac5ba48a5f23b6e142a33065c27490df0036abd94899dba580e2c1f738904f46f203657e2b34549028b9c7f64dda6a5642c80e4bea6acc989a66f6b0bebade
7
- data.tar.gz: 9b8a4875deeb1b6a38fe3127162e77e0e8a8879ae6e7aa4da7d457cc00869c0e77d4d2a95c691ff1d12eab0c9f20d06be8abc024b911f15819fef03890d1f5f8
6
+ metadata.gz: 7a9d79a7a86ca0c6f9968bae9c980049174626d12d44b8cafa73139be5bf24c66d3675a5e16a3a104d5b04ce76b1a0e136e2cc788338c142107af9354eca8e7d
7
+ data.tar.gz: be890cb3de5d4a5885c6bcc213349bfb656567f2b4cc63decabbd608bf7004126358fd13b42e6b3a6271e25db19f85c2dc061ed2c1b862e7f968276fa7632377
data/CHANGELOG.markdown CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project (at least, from v3.0.0 onwards) are documented in this file.
4
4
 
5
+ ## 5.3.0 - 2021-08-19
6
+
7
+ [Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.3.0)
8
+
9
+ ### Changed
10
+
11
+ * StaleIdsExceptions now include a URL in their error message with recommendations on how to resolve the problem.
12
+ * Fire real-time callbacks on `after_commit` (including deletions) to ensure data is fully persisted to the database before updating Sphinx. More details in [#1204](https://github.com/pat/thinking-sphinx/pull/1204).
13
+
14
+ ### Fixed
15
+
16
+ * Ensure Thinking Sphinx's ActiveRecord components are loaded by either Rails' after_initialise hook or ActiveSupport's on_load notification, because the order of these two events are not consistent.
17
+ * Remove `app/indices` from eager_load_paths in Rails 4.2 and 5, to match the behaviour in 6.
18
+
5
19
  ## 5.2.1 - 2021-08-09
6
20
 
7
21
  [Release Notes](https://github.com/pat/thinking-sphinx/releases/tag/v5.2.1)
data/README.textile CHANGED
@@ -1,6 +1,6 @@
1
1
  h1. Thinking Sphinx
2
2
 
3
- Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v5.2.1.
3
+ Thinking Sphinx is a library for connecting ActiveRecord to the Sphinx full-text search tool, and integrates closely with Rails (but also works with other Ruby web frameworks). The current release is v5.3.0.
4
4
 
5
5
  h2. Upgrading
6
6
 
@@ -14,7 +14,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp
14
14
 
15
15
  <pre><code>gem 'mysql2', '~> 0.4', :platform => :ruby
16
16
  gem 'jdbc-mysql', '~> 5.1.35', :platform => :jruby
17
- gem 'thinking-sphinx', '~> 5.2'</code></pre>
17
+ gem 'thinking-sphinx', '~> 5.3'</code></pre>
18
18
 
19
19
  The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.
20
20
 
@@ -101,10 +101,6 @@ require 'thinking_sphinx/distributed'
101
101
  require 'thinking_sphinx/logger'
102
102
  require 'thinking_sphinx/real_time'
103
103
 
104
- if defined?(Rails::Railtie)
105
- require 'thinking_sphinx/railtie'
106
- else
107
- require 'thinking_sphinx/active_record'
108
- end
104
+ require 'thinking_sphinx/railtie' if defined?(Rails::Railtie)
109
105
 
110
106
  ThinkingSphinx.before_index_hooks << ThinkingSphinx::Hooks::GuardPresence
@@ -40,3 +40,5 @@ require 'thinking_sphinx/active_record/depolymorph/conditions_reflection'
40
40
  require 'thinking_sphinx/active_record/depolymorph/overridden_reflection'
41
41
  require 'thinking_sphinx/active_record/depolymorph/scoped_reflection'
42
42
  require 'thinking_sphinx/active_record/filter_reflection'
43
+
44
+ ActiveRecord::Base.include ThinkingSphinx::ActiveRecord::Base
@@ -3,7 +3,11 @@
3
3
  class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
4
4
  ThinkingSphinx::Callbacks
5
5
 
6
- callbacks :after_destroy, :after_rollback
6
+ callbacks :after_commit, :after_destroy, :after_rollback
7
+
8
+ def after_commit
9
+ delete_from_sphinx
10
+ end
7
11
 
8
12
  def after_destroy
9
13
  delete_from_sphinx
@@ -24,7 +24,10 @@ class ThinkingSphinx::Callbacks::Appender
24
24
  attr_reader :model, :reference, :options, :block
25
25
 
26
26
  def add_core_callbacks
27
- model.after_destroy ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks
27
+ model.after_commit(
28
+ ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks,
29
+ on: :destroy
30
+ )
28
31
  end
29
32
 
30
33
  def add_delta_callbacks
@@ -40,8 +43,9 @@ class ThinkingSphinx::Callbacks::Appender
40
43
  end
41
44
 
42
45
  def add_real_time_callbacks
43
- model.after_save ThinkingSphinx::RealTime.callback_for(
44
- reference, path, &block
46
+ model.after_commit(
47
+ ThinkingSphinx::RealTime.callback_for(reference, path, &block),
48
+ on: [:create, :update]
45
49
  )
46
50
  end
47
51
 
@@ -7,21 +7,23 @@ class ThinkingSphinx::Railtie < Rails::Railtie
7
7
 
8
8
  config.after_initialize do
9
9
  require 'thinking_sphinx/active_record'
10
- ActiveRecord::Base.include ThinkingSphinx::ActiveRecord::Base
11
10
  end
12
11
 
13
12
  initializer 'thinking_sphinx.initialisation' do
14
- if ActiveSupport::VERSION::MAJOR > 5
15
- if Rails.application.config.autoloader == :zeitwerk
16
- ActiveSupport::Dependencies.autoload_paths.delete(
17
- Rails.root.join("app", "indices").to_s
18
- )
19
- end
13
+ ActiveSupport.on_load(:active_record) do
14
+ require 'thinking_sphinx/active_record'
15
+ end
20
16
 
21
- Rails.application.config.eager_load_paths -=
22
- ThinkingSphinx::Configuration.instance.index_paths
23
- Rails.application.config.eager_load_paths.freeze
17
+ if ActiveSupport::VERSION::MAJOR > 5 &&
18
+ Rails.application.config.autoloader == :zeitwerk
19
+ ActiveSupport::Dependencies.autoload_paths.delete(
20
+ Rails.root.join("app", "indices").to_s
21
+ )
24
22
  end
23
+
24
+ Rails.application.config.eager_load_paths -=
25
+ ThinkingSphinx::Configuration.instance.index_paths
26
+ Rails.application.config.eager_load_paths.freeze
25
27
  end
26
28
 
27
29
  rake_tasks do
@@ -9,6 +9,7 @@ class ThinkingSphinx::Search::StaleIdsException < StandardError
9
9
  end
10
10
 
11
11
  def message
12
- "Record IDs found by Sphinx but not by ActiveRecord : #{ids.join(', ')}"
12
+ "Record IDs found by Sphinx but not by ActiveRecord : #{ids.join(', ')}\n" \
13
+ "https://freelancing-gods.com/thinking-sphinx/v5/common_issues.html#record-ids"
13
14
  end
14
15
  end
@@ -3,5 +3,5 @@
3
3
  require 'thinking_sphinx'
4
4
 
5
5
  ActiveSupport.on_load :active_record do
6
- include ThinkingSphinx::ActiveRecord::Base
6
+ require 'thinking_sphinx/active_record'
7
7
  end
@@ -16,7 +16,7 @@ describe 'SQL delta indexing', :live => true do
16
16
  )
17
17
  sleep 0.25
18
18
 
19
- expect(Book.search('Terry Pratchett').to_a).to eq([guards, men])
19
+ expect(Book.search('Terry Pratchett').to_a).to match_array([guards, men])
20
20
  end
21
21
 
22
22
  it "automatically indexes updated records" do
@@ -5,7 +5,9 @@ require 'spec_helper'
5
5
  describe ThinkingSphinx::ActiveRecord::Index do
6
6
  let(:index) { ThinkingSphinx::ActiveRecord::Index.new :user }
7
7
  let(:config) { double('config', :settings => {},
8
- :indices_location => 'location', :next_offset => 8) }
8
+ :indices_location => 'location', :next_offset => 8,
9
+ :index_set_class => index_set_class) }
10
+ let(:index_set_class) { double :reference_name => :user }
9
11
 
10
12
  before :each do
11
13
  allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
@@ -5,7 +5,7 @@ $:.push File.expand_path('../lib', __FILE__)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'thinking-sphinx'
8
- s.version = '5.2.1'
8
+ s.version = '5.3.0'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Pat Allan"]
11
11
  s.email = ["pat@freelancing-gods.com"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.1
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-09 00:00:00.000000000 Z
11
+ date: 2021-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord