Skip to content

Commit

Permalink
Merge branch 'release/v3.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Aug 29, 2017
2 parents 04cc1ea + 14ad66e commit 6c5ecd4
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 8 deletions.
4 changes: 4 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
5 changes: 3 additions & 2 deletions README.textile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,7 +25,7 @@ It's a gem, so install it like you would any other gem. You will also need to sp

<pre><code>gem 'mysql2', '~> 0.3', :platform => :ruby
gem 'jdbc-mysql', '= 5.1.35', :platform => :jruby
gem 'thinking-sphinx', '~> 3.4.0'</code></pre>
gem 'thinking-sphinx', '~> 3.4.1'</code></pre>

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.

Expand Down
5 changes: 3 additions & 2 deletions bin/loadsphinx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/thinking_sphinx/configuration/minimum_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib/thinking_sphinx/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)
Expand Down
16 changes: 14 additions & 2 deletions spec/thinking_sphinx/configuration/minimum_fields_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])
Expand Down
7 changes: 7 additions & 0 deletions spec/thinking_sphinx/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion thinking-sphinx.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ["[email protected]"]
Expand Down

0 comments on commit 6c5ecd4

Please sign in to comment.