diff --git a/HISTORY b/HISTORY index dddfed695..803bcd0d1 100644 --- a/HISTORY +++ b/HISTORY @@ -1,3 +1,7 @@ +2017-08-29: 3.4.1 +* [CHANGE] Treat "Lost connection to MySQL server" as a connection error (Manuel Schnitzer). +* [FIX] Index normalisation will now work even when index model tables don't exist. + 2017-08-28: 3.4.0 * [CHANGE] Delta callback logic now prioritises checking for high level settings rather than model changes. * [FIX] Index normalisation now occurs consistently, and removes unneccesary sphinx_internal_class_name fields from real-time indices. diff --git a/README.textile b/README.textile index 3568f429b..dbf8a3968 100644 --- a/README.textile +++ b/README.textile @@ -1,11 +1,12 @@ h1. Thinking Sphinx -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 v3.4.0. +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 v3.4.1. h2. Upgrading Please refer to the release notes for any changes you need to make when upgrading: +* "v3.4.1":https://github.com/pat/thinking-sphinx/releases/tag/v3.4.1 * "v3.4.0":https://github.com/pat/thinking-sphinx/releases/tag/v3.4.0 * "v3.3.0":https://github.com/pat/thinking-sphinx/releases/tag/v3.3.0 * "v3.2.0":https://github.com/pat/thinking-sphinx/releases/tag/v3.2.0 @@ -24,7 +25,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp
gem 'mysql2', '~> 0.3', :platform => :ruby
gem 'jdbc-mysql', '= 5.1.35', :platform => :jruby
-gem 'thinking-sphinx', '~> 3.4.0'
+gem 'thinking-sphinx', '~> 3.4.1'
The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database. If you're using JRuby, there is "currently an issue with Sphinx and jdbc-mysql 5.1.36 or newer":http://sphinxsearch.com/forum/view.html?id=13939, so you'll need to stick to nothing more recent than 5.1.35.
diff --git a/bin/loadsphinx b/bin/loadsphinx
index 217160c0d..8592d668e 100755
--- a/bin/loadsphinx
+++ b/bin/loadsphinx
@@ -20,7 +20,8 @@ download_and_compile_source () {
}
load_cache () {
- aws s3 cp s3://$bucket/bincaches/$name.tar.gz $file
+ mkdir ext
+ curl -o $file http://$bucket.s3.amazonaws.com/bincaches/$name.tar.gz
tar -zxf $file
}
@@ -29,7 +30,7 @@ push_cache () {
aws s3 cp $file s3://$bucket/bincaches/$name.tar.gz --acl public-read
}
-if aws s3api head-object --bucket $bucket --key bincaches/$name.tar.gz
+if curl -i --head --fail http://$bucket.s3.amazonaws.com/bincaches/$name.tar.gz
then
load_cache
else
diff --git a/lib/thinking_sphinx/configuration/minimum_fields.rb b/lib/thinking_sphinx/configuration/minimum_fields.rb
index 7b7cfe3c0..2e7062db4 100644
--- a/lib/thinking_sphinx/configuration/minimum_fields.rb
+++ b/lib/thinking_sphinx/configuration/minimum_fields.rb
@@ -28,6 +28,7 @@ def indices_of_type(type)
def no_inheritance_columns?
indices.select { |index|
+ index.model.table_exists? &&
index.model.column_names.include?(index.model.inheritance_column)
}.empty?
end
diff --git a/lib/thinking_sphinx/errors.rb b/lib/thinking_sphinx/errors.rb
index d82468db4..99de0ebbf 100644
--- a/lib/thinking_sphinx/errors.rb
+++ b/lib/thinking_sphinx/errors.rb
@@ -9,7 +9,9 @@ def self.new_from_mysql(error)
replacement = ThinkingSphinx::SyntaxError.new(error.message)
when /query error/
replacement = ThinkingSphinx::QueryError.new(error.message)
- when /Can't connect to MySQL server/, /Communications link failure/
+ when /Can't connect to MySQL server/,
+ /Communications link failure/,
+ /Lost connection to MySQL server/
replacement = ThinkingSphinx::ConnectionError.new(
"Error connecting to Sphinx via the MySQL protocol. #{error.message}"
)
diff --git a/spec/thinking_sphinx/configuration/minimum_fields_spec.rb b/spec/thinking_sphinx/configuration/minimum_fields_spec.rb
index 27b61a84c..53ff9a223 100644
--- a/spec/thinking_sphinx/configuration/minimum_fields_spec.rb
+++ b/spec/thinking_sphinx/configuration/minimum_fields_spec.rb
@@ -10,8 +10,10 @@
let(:field_a2) { double :name => 'name' }
let(:field_b1) { double :name => 'sphinx_internal_class_name' }
let(:field_b2) { double :name => 'name' }
- let(:model_a) { double :inheritance_column => 'type' }
- let(:model_b) { double :inheritance_column => 'type' }
+ let(:model_a) { double :inheritance_column => 'type',
+ :table_exists? => true }
+ let(:model_b) { double :inheritance_column => 'type',
+ :table_exists? => true }
let(:subject) { ThinkingSphinx::Configuration::MinimumFields.new indices }
it 'removes the class name fields when no index models have type columns' do
@@ -24,6 +26,16 @@
expect(index_b.fields).to eq([field_b2])
end
+ it 'removes the class name fields when models have no tables' do
+ allow(model_a).to receive(:table_exists?).and_return(false)
+ allow(model_b).to receive(:table_exists?).and_return(false)
+
+ subject.reconcile
+
+ expect(index_a.sources.first.fields).to eq([field_a2])
+ expect(index_b.fields).to eq([field_b2])
+ end
+
it 'keeps the class name fields when one index model has a type column' do
allow(model_a).to receive(:column_names).and_return(['id', 'name', 'type'])
allow(model_b).to receive(:column_names).and_return(['id', 'name'])
diff --git a/spec/thinking_sphinx/errors_spec.rb b/spec/thinking_sphinx/errors_spec.rb
index 1183e814e..9e68675a5 100644
--- a/spec/thinking_sphinx/errors_spec.rb
+++ b/spec/thinking_sphinx/errors_spec.rb
@@ -35,7 +35,14 @@
it "translates connection errors" do
allow(error).to receive_messages :message => "Can't connect to MySQL server on '127.0.0.1' (61)"
+ expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
+ to be_a(ThinkingSphinx::ConnectionError)
+
+ allow(error).to receive_messages :message => "Communications link failure"
+ expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
+ to be_a(ThinkingSphinx::ConnectionError)
+ allow(error).to receive_messages :message => "Lost connection to MySQL server"
expect(ThinkingSphinx::SphinxError.new_from_mysql(error)).
to be_a(ThinkingSphinx::ConnectionError)
end
diff --git a/thinking-sphinx.gemspec b/thinking-sphinx.gemspec
index 3508ab8ed..efc3908f8 100644
--- a/thinking-sphinx.gemspec
+++ b/thinking-sphinx.gemspec
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
Gem::Specification.new do |s|
s.name = 'thinking-sphinx'
- s.version = '3.4.0'
+ s.version = '3.4.1'
s.platform = Gem::Platform::RUBY
s.authors = ["Pat Allan"]
s.email = ["pat@freelancing-gods.com"]