thinking-sphinx 4.4.1 → 5.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +218 -0
- data/.travis.yml +12 -21
- data/Appraisals +16 -19
- data/CHANGELOG.markdown +93 -0
- data/README.textile +17 -17
- data/bin/loadsphinx +22 -4
- data/lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb +1 -1
- data/lib/thinking_sphinx/active_record/attribute/sphinx_presenter.rb +1 -1
- data/lib/thinking_sphinx/active_record/base.rb +2 -6
- data/lib/thinking_sphinx/active_record/callbacks/association_delta_callbacks.rb +21 -0
- data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +6 -2
- data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +3 -2
- data/lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb +1 -1
- data/lib/thinking_sphinx/active_record/interpreter.rb +4 -4
- data/lib/thinking_sphinx/active_record/sql_source/template.rb +2 -2
- data/lib/thinking_sphinx/active_record/sql_source.rb +12 -0
- data/lib/thinking_sphinx/active_record.rb +3 -0
- data/lib/thinking_sphinx/callbacks/appender.rb +63 -0
- data/lib/thinking_sphinx/callbacks.rb +9 -0
- data/lib/thinking_sphinx/connection/client.rb +6 -1
- data/lib/thinking_sphinx/connection.rb +4 -0
- data/lib/thinking_sphinx/core/index.rb +1 -2
- data/lib/thinking_sphinx/deletion.rb +18 -17
- data/lib/thinking_sphinx/errors.rb +1 -1
- data/lib/thinking_sphinx/index_set.rb +7 -3
- data/lib/thinking_sphinx/middlewares/sphinxql.rb +1 -1
- data/lib/thinking_sphinx/railtie.rb +20 -7
- data/lib/thinking_sphinx/real_time/index/template.rb +12 -0
- data/lib/thinking_sphinx/real_time/index.rb +5 -3
- data/lib/thinking_sphinx/real_time/interpreter.rb +8 -6
- data/lib/thinking_sphinx/real_time/populator.rb +4 -1
- data/lib/thinking_sphinx/real_time/transcriber.rb +41 -19
- data/lib/thinking_sphinx/real_time/translator.rb +1 -0
- data/lib/thinking_sphinx/search/stale_ids_exception.rb +2 -1
- data/lib/thinking_sphinx/search.rb +1 -1
- data/lib/thinking_sphinx/settings.rb +13 -9
- data/lib/thinking_sphinx/sinatra.rb +1 -1
- data/lib/thinking_sphinx/test.rb +1 -1
- data/lib/thinking_sphinx.rb +0 -3
- data/spec/acceptance/attribute_access_spec.rb +10 -2
- data/spec/acceptance/big_integers_spec.rb +1 -1
- data/spec/acceptance/geosearching_spec.rb +13 -3
- data/spec/acceptance/merging_spec.rb +1 -1
- data/spec/acceptance/paginating_search_results_spec.rb +18 -2
- data/spec/acceptance/real_time_updates_spec.rb +2 -2
- data/spec/acceptance/searching_with_filters_spec.rb +3 -3
- data/spec/acceptance/sql_deltas_spec.rb +16 -4
- data/spec/acceptance/support/sphinx_controller.rb +6 -4
- data/spec/acceptance/support/sphinx_helpers.rb +4 -4
- data/spec/acceptance/suspended_deltas_spec.rb +3 -3
- data/spec/internal/app/indices/article_index.rb +0 -1
- data/spec/internal/app/indices/colour_index.rb +7 -0
- data/spec/internal/app/models/admin/person.rb +3 -1
- data/spec/internal/app/models/album.rb +3 -1
- data/spec/internal/app/models/animal.rb +1 -0
- data/spec/internal/app/models/article.rb +2 -0
- data/spec/internal/app/models/bird.rb +1 -0
- data/spec/internal/app/models/book.rb +2 -0
- data/spec/internal/app/models/car.rb +1 -1
- data/spec/internal/app/models/city.rb +2 -0
- data/spec/internal/app/models/colour.rb +2 -0
- data/spec/internal/app/models/product.rb +1 -1
- data/spec/internal/app/models/tee.rb +5 -0
- data/spec/internal/app/models/user.rb +2 -0
- data/spec/internal/config/database.yml +6 -1
- data/spec/internal/db/schema.rb +1 -0
- data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +2 -1
- data/spec/thinking_sphinx/active_record/index_spec.rb +3 -13
- data/spec/thinking_sphinx/active_record/interpreter_spec.rb +15 -14
- data/spec/thinking_sphinx/active_record/sql_source_spec.rb +41 -3
- data/spec/thinking_sphinx/connection/mri_spec.rb +49 -0
- data/spec/thinking_sphinx/deletion_spec.rb +5 -4
- data/spec/thinking_sphinx/index_set_spec.rb +28 -12
- data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +2 -1
- data/spec/thinking_sphinx/real_time/index_spec.rb +51 -13
- data/spec/thinking_sphinx/real_time/interpreter_spec.rb +14 -14
- data/spec/thinking_sphinx/real_time/transcriber_spec.rb +9 -1
- data/thinking-sphinx.gemspec +3 -3
- metadata +17 -12
- data/spec/acceptance/connection_spec.rb +0 -25
@@ -30,6 +30,44 @@ describe ThinkingSphinx::ActiveRecord::SQLSource do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
describe '#add_attribute' do
|
34
|
+
let(:attribute) { double('attribute', name: 'my_attribute') }
|
35
|
+
|
36
|
+
it "appends attributes to the collection" do
|
37
|
+
source.add_attribute attribute
|
38
|
+
|
39
|
+
expect(source.attributes.collect(&:name)).to include('my_attribute')
|
40
|
+
end
|
41
|
+
|
42
|
+
it "replaces attributes with the same name" do
|
43
|
+
source.add_attribute double('attribute', name: 'my_attribute')
|
44
|
+
source.add_attribute attribute
|
45
|
+
|
46
|
+
matching = source.attributes.select { |attr| attr.name == attribute.name }
|
47
|
+
|
48
|
+
expect(matching).to eq([attribute])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#add_field' do
|
53
|
+
let(:field) { double('field', name: 'my_field') }
|
54
|
+
|
55
|
+
it "appends fields to the collection" do
|
56
|
+
source.add_field field
|
57
|
+
|
58
|
+
expect(source.fields.collect(&:name)).to include('my_field')
|
59
|
+
end
|
60
|
+
|
61
|
+
it "replaces fields with the same name" do
|
62
|
+
source.add_field double('field', name: 'my_field')
|
63
|
+
source.add_field field
|
64
|
+
|
65
|
+
matching = source.fields.select { |fld| fld.name == field.name }
|
66
|
+
|
67
|
+
expect(matching).to eq([field])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
33
71
|
describe '#attributes' do
|
34
72
|
it "has the internal id attribute by default" do
|
35
73
|
expect(source.attributes.collect(&:name)).to include('sphinx_internal_id')
|
@@ -287,14 +325,14 @@ describe ThinkingSphinx::ActiveRecord::SQLSource do
|
|
287
325
|
expect(source.sql_attr_string).to include('name')
|
288
326
|
end
|
289
327
|
|
290
|
-
it "adds timestamp attributes to
|
328
|
+
it "adds timestamp attributes to sql_attr_uint" do
|
291
329
|
source.attributes << double('attribute')
|
292
330
|
allow(presenter).to receive_messages :declaration => 'created_at',
|
293
|
-
:collection_type => :
|
331
|
+
:collection_type => :uint
|
294
332
|
|
295
333
|
source.render
|
296
334
|
|
297
|
-
expect(source.
|
335
|
+
expect(source.sql_attr_uint).to include('created_at')
|
298
336
|
end
|
299
337
|
|
300
338
|
it "adds float attributes to sql_attr_float" do
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec.describe ThinkingSphinx::Connection::MRI do
|
4
|
+
subject { described_class.new :host => "127.0.0.1", :port => 9306 }
|
5
|
+
|
6
|
+
let(:client) { double :client, :query => "result", :next_result => false }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
allow(Mysql2::Client).to receive(:new).and_return(client)
|
10
|
+
end
|
11
|
+
|
12
|
+
after :each do
|
13
|
+
ThinkingSphinx::Configuration.reset
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#execute" do
|
17
|
+
it "sends the query to the client" do
|
18
|
+
subject.execute "SELECT QUERY"
|
19
|
+
|
20
|
+
expect(client).to have_received(:query).with("SELECT QUERY")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns a result" do
|
24
|
+
expect(subject.execute("SELECT QUERY")).to eq("result")
|
25
|
+
end
|
26
|
+
|
27
|
+
context "with long queries" do
|
28
|
+
let(:maximum) { (2 ** 23) - 5 }
|
29
|
+
let(:query) { String.new "SELECT * FROM book_core WHERE MATCH('')" }
|
30
|
+
let(:difference) { maximum - query.length }
|
31
|
+
|
32
|
+
it 'does not allow overly long queries' do
|
33
|
+
expect {
|
34
|
+
subject.execute(query.insert(-3, 'a' * (difference + 5)))
|
35
|
+
}.to raise_error(ThinkingSphinx::QueryLengthError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'does not allow queries longer than specified in the settings' do
|
39
|
+
ThinkingSphinx::Configuration.reset
|
40
|
+
|
41
|
+
write_configuration('maximum_statement_length' => maximum - 5)
|
42
|
+
|
43
|
+
expect {
|
44
|
+
subject.execute(query.insert(-3, 'a' * (difference)))
|
45
|
+
}.to raise_error(ThinkingSphinx::QueryLengthError)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end if RUBY_PLATFORM != 'java'
|
@@ -6,7 +6,7 @@ describe ThinkingSphinx::Deletion do
|
|
6
6
|
describe '.perform' do
|
7
7
|
let(:connection) { double('connection', :execute => nil) }
|
8
8
|
let(:index) { double('index', :name => 'foo_core',
|
9
|
-
:
|
9
|
+
:type => 'plain', :distributed? => false) }
|
10
10
|
|
11
11
|
before :each do
|
12
12
|
allow(ThinkingSphinx::Connection).to receive(:take).and_yield(connection)
|
@@ -15,8 +15,9 @@ describe ThinkingSphinx::Deletion do
|
|
15
15
|
|
16
16
|
context 'index is SQL-backed' do
|
17
17
|
it "updates the deleted flag to false" do
|
18
|
-
expect(connection).to receive(:execute).
|
19
|
-
|
18
|
+
expect(connection).to receive(:execute).with(
|
19
|
+
'UPDATE foo_core SET sphinx_deleted = 1 WHERE sphinx_internal_id IN (7)'
|
20
|
+
)
|
20
21
|
|
21
22
|
ThinkingSphinx::Deletion.perform index, 7
|
22
23
|
end
|
@@ -38,7 +39,7 @@ describe ThinkingSphinx::Deletion do
|
|
38
39
|
|
39
40
|
it "deletes the record to false" do
|
40
41
|
expect(connection).to receive(:execute).
|
41
|
-
with('DELETE FROM foo_core WHERE
|
42
|
+
with('DELETE FROM foo_core WHERE sphinx_internal_id IN (7)')
|
42
43
|
|
43
44
|
ThinkingSphinx::Deletion.perform index, 7
|
44
45
|
end
|
@@ -30,6 +30,16 @@ describe ThinkingSphinx::IndexSet do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#to_a' do
|
33
|
+
let(:article_index) do
|
34
|
+
double(:reference => :article, :distributed? => false)
|
35
|
+
end
|
36
|
+
let(:opinion_article_index) do
|
37
|
+
double(:reference => :opinion_article, :distributed? => false)
|
38
|
+
end
|
39
|
+
let(:page_index) do
|
40
|
+
double(:reference => :page, :distributed? => false)
|
41
|
+
end
|
42
|
+
|
33
43
|
it "ensures the indices are loaded" do
|
34
44
|
expect(configuration).to receive(:preload_indices)
|
35
45
|
|
@@ -50,21 +60,29 @@ describe ThinkingSphinx::IndexSet do
|
|
50
60
|
|
51
61
|
it "uses indices for the given classes" do
|
52
62
|
configuration.indices.replace [
|
53
|
-
|
54
|
-
double(:reference => :opinion_article, :distributed? => false),
|
55
|
-
double(:reference => :page, :distributed? => false)
|
63
|
+
article_index, opinion_article_index, page_index
|
56
64
|
]
|
57
65
|
|
58
66
|
options[:classes] = [class_double('Article', :column_names => [])]
|
59
67
|
|
60
|
-
expect(set.to_a
|
68
|
+
expect(set.to_a).to eq([article_index])
|
69
|
+
end
|
70
|
+
|
71
|
+
it "uses indices for the given instance's class" do
|
72
|
+
configuration.indices.replace [
|
73
|
+
article_index, opinion_article_index, page_index
|
74
|
+
]
|
75
|
+
|
76
|
+
instance_class = class_double('Article', :column_names => [])
|
77
|
+
|
78
|
+
options[:instances] = [double(:instance, :class => instance_class)]
|
79
|
+
|
80
|
+
expect(set.to_a).to eq([article_index])
|
61
81
|
end
|
62
82
|
|
63
83
|
it "requests indices for any STI superclasses" do
|
64
84
|
configuration.indices.replace [
|
65
|
-
|
66
|
-
double(:reference => :opinion_article, :distributed? => false),
|
67
|
-
double(:reference => :page, :distributed? => false)
|
85
|
+
article_index, opinion_article_index, page_index
|
68
86
|
]
|
69
87
|
|
70
88
|
article = class_double('Article', :column_names => [:type])
|
@@ -73,14 +91,12 @@ describe ThinkingSphinx::IndexSet do
|
|
73
91
|
|
74
92
|
options[:classes] = [opinion]
|
75
93
|
|
76
|
-
expect(set.to_a
|
94
|
+
expect(set.to_a).to eq([article_index, opinion_article_index])
|
77
95
|
end
|
78
96
|
|
79
97
|
it "does not use MTI superclasses" do
|
80
98
|
configuration.indices.replace [
|
81
|
-
|
82
|
-
double(:reference => :opinion_article, :distributed? => false),
|
83
|
-
double(:reference => :page, :distributed? => false)
|
99
|
+
article_index, opinion_article_index, page_index
|
84
100
|
]
|
85
101
|
|
86
102
|
article = class_double('Article', :column_names => [])
|
@@ -88,7 +104,7 @@ describe ThinkingSphinx::IndexSet do
|
|
88
104
|
|
89
105
|
options[:classes] = [opinion]
|
90
106
|
|
91
|
-
expect(set.to_a
|
107
|
+
expect(set.to_a).to eq([opinion_article_index])
|
92
108
|
end
|
93
109
|
|
94
110
|
it "uses named indices if names are provided" do
|
@@ -31,7 +31,7 @@ describe ThinkingSphinx::Middlewares::SphinxQL do
|
|
31
31
|
let(:query) { double('query') }
|
32
32
|
let(:configuration) { double('configuration', :settings => {},
|
33
33
|
index_set_class: set_class) }
|
34
|
-
let(:set_class) { double(:new => index_set) }
|
34
|
+
let(:set_class) { double(:new => index_set, :reference_name => :article) }
|
35
35
|
|
36
36
|
before :each do
|
37
37
|
stub_const 'Riddle::Query::Select', double(:new => sphinx_sql)
|
@@ -115,6 +115,7 @@ describe ThinkingSphinx::Middlewares::SphinxQL do
|
|
115
115
|
model = double('model', :connection => double,
|
116
116
|
:ancestors => [ActiveRecord::Base], :name => 'Animal')
|
117
117
|
allow(index_set.first).to receive_messages :reference => :animal
|
118
|
+
allow(set_class).to receive_messages(:reference_name => :animal)
|
118
119
|
|
119
120
|
search.options[:classes] = [model]
|
120
121
|
|
@@ -5,12 +5,52 @@ require 'spec_helper'
|
|
5
5
|
describe ThinkingSphinx::RealTime::Index do
|
6
6
|
let(:index) { ThinkingSphinx::RealTime::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(:index_set_class, :reference_name => :user) }
|
9
11
|
|
10
12
|
before :each do
|
11
13
|
allow(ThinkingSphinx::Configuration).to receive_messages :instance => config
|
12
14
|
end
|
13
15
|
|
16
|
+
describe '#add_attribute' do
|
17
|
+
let(:attribute) { double('attribute', name: 'my_attribute') }
|
18
|
+
|
19
|
+
it "appends attributes to the collection" do
|
20
|
+
index.add_attribute attribute
|
21
|
+
|
22
|
+
expect(index.attributes.collect(&:name)).to include('my_attribute')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "replaces attributes with the same name" do
|
26
|
+
index.add_attribute double('attribute', name: 'my_attribute')
|
27
|
+
index.add_attribute attribute
|
28
|
+
|
29
|
+
matching = index.attributes.select { |attr| attr.name == attribute.name }
|
30
|
+
|
31
|
+
expect(matching).to eq([attribute])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#add_field' do
|
36
|
+
let(:field) { double('field', name: 'my_field') }
|
37
|
+
|
38
|
+
it "appends fields to the collection" do
|
39
|
+
index.add_field field
|
40
|
+
|
41
|
+
expect(index.fields.collect(&:name)).to include('my_field')
|
42
|
+
end
|
43
|
+
|
44
|
+
it "replaces fields with the same name" do
|
45
|
+
index.add_field double('field', name: 'my_field')
|
46
|
+
index.add_field field
|
47
|
+
|
48
|
+
matching = index.fields.select { |fld| fld.name == field.name }
|
49
|
+
|
50
|
+
expect(matching).to eq([field])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
14
54
|
describe '#attributes' do
|
15
55
|
it "has the internal id attribute by default" do
|
16
56
|
expect(index.attributes.collect(&:name)).to include('sphinx_internal_id')
|
@@ -23,23 +63,21 @@ describe ThinkingSphinx::RealTime::Index do
|
|
23
63
|
it "has the internal deleted attribute by default" do
|
24
64
|
expect(index.attributes.collect(&:name)).to include('sphinx_deleted')
|
25
65
|
end
|
26
|
-
end
|
27
66
|
|
28
|
-
|
29
|
-
|
30
|
-
expect(index).not_to be_delta
|
67
|
+
it "does not have an internal updated_at attribute by default" do
|
68
|
+
expect(index.attributes.collect(&:name)).to_not include('sphinx_updated_at')
|
31
69
|
end
|
32
|
-
end
|
33
70
|
|
34
|
-
|
35
|
-
|
36
|
-
expect(index.docinfo).to eq(:extern)
|
37
|
-
end
|
71
|
+
it "has an internal updated_at attribute if real_time_tidy is true" do
|
72
|
+
config.settings["real_time_tidy"] = true
|
38
73
|
|
39
|
-
|
40
|
-
|
74
|
+
expect(index.attributes.collect(&:name)).to include('sphinx_updated_at')
|
75
|
+
end
|
76
|
+
end
|
41
77
|
|
42
|
-
|
78
|
+
describe '#delta?' do
|
79
|
+
it "always returns false" do
|
80
|
+
expect(index).not_to be_delta
|
43
81
|
end
|
44
82
|
end
|
45
83
|
|
@@ -10,6 +10,10 @@ describe ThinkingSphinx::RealTime::Interpreter do
|
|
10
10
|
let(:index) { Struct.new(:attributes, :fields, :options).new([], [], {}) }
|
11
11
|
let(:block) { Proc.new { } }
|
12
12
|
|
13
|
+
before :each do
|
14
|
+
allow(index).to receive_messages(:add_attribute => nil, :add_field => nil)
|
15
|
+
end
|
16
|
+
|
13
17
|
describe '.translate!' do
|
14
18
|
let(:instance) { double('interpreter', :translate! => true) }
|
15
19
|
|
@@ -51,17 +55,15 @@ describe ThinkingSphinx::RealTime::Interpreter do
|
|
51
55
|
end
|
52
56
|
|
53
57
|
it "adds an attribute to the index" do
|
54
|
-
|
58
|
+
expect(index).to receive(:add_attribute).with(attribute)
|
55
59
|
|
56
|
-
|
60
|
+
instance.has column
|
57
61
|
end
|
58
62
|
|
59
63
|
it "adds multiple attributes when passed multiple columns" do
|
60
|
-
|
64
|
+
expect(index).to receive(:add_attribute).with(attribute).twice
|
61
65
|
|
62
|
-
|
63
|
-
saved_attribute == attribute
|
64
|
-
}.length).to eq(2)
|
66
|
+
instance.has column, column
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -88,17 +90,15 @@ describe ThinkingSphinx::RealTime::Interpreter do
|
|
88
90
|
end
|
89
91
|
|
90
92
|
it "adds a field to the index" do
|
91
|
-
|
93
|
+
expect(index).to receive(:add_field).with(field)
|
92
94
|
|
93
|
-
|
95
|
+
instance.indexes column
|
94
96
|
end
|
95
97
|
|
96
98
|
it "adds multiple fields when passed multiple columns" do
|
97
|
-
|
99
|
+
expect(index).to receive(:add_field).with(field).twice
|
98
100
|
|
99
|
-
|
100
|
-
saved_field == field
|
101
|
-
}.length).to eq(2)
|
101
|
+
instance.indexes column, column
|
102
102
|
end
|
103
103
|
|
104
104
|
context 'sortable' do
|
@@ -135,9 +135,9 @@ describe ThinkingSphinx::RealTime::Interpreter do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it "adds an attribute to the index" do
|
138
|
-
|
138
|
+
expect(index).to receive(:add_attribute).with(attribute)
|
139
139
|
|
140
|
-
|
140
|
+
instance.indexes column, :sortable => true
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -6,7 +6,8 @@ RSpec.describe ThinkingSphinx::RealTime::Transcriber do
|
|
6
6
|
let(:subject) { ThinkingSphinx::RealTime::Transcriber.new index }
|
7
7
|
let(:index) { double 'index', :name => 'foo_core', :conditions => [],
|
8
8
|
:fields => [double(:name => 'field_a'), double(:name => 'field_b')],
|
9
|
-
:attributes => [double(:name => 'attr_a'), double(:name => 'attr_b')]
|
9
|
+
:attributes => [double(:name => 'attr_a'), double(:name => 'attr_b')],
|
10
|
+
:primary_key => :id }
|
10
11
|
let(:insert) { double :replace! => replace }
|
11
12
|
let(:replace) { double :to_sql => 'REPLACE QUERY' }
|
12
13
|
let(:connection) { double :execute => true }
|
@@ -40,6 +41,13 @@ RSpec.describe ThinkingSphinx::RealTime::Transcriber do
|
|
40
41
|
subject.copy instance_a, instance_b
|
41
42
|
end
|
42
43
|
|
44
|
+
it "deletes previous records" do
|
45
|
+
expect(connection).to receive(:execute).
|
46
|
+
with('DELETE FROM foo_core WHERE sphinx_internal_id IN (48, 49)')
|
47
|
+
|
48
|
+
subject.copy instance_a, instance_b
|
49
|
+
end
|
50
|
+
|
43
51
|
it "skips instances that aren't in the database" do
|
44
52
|
allow(instance_a).to receive(:persisted?).and_return(false)
|
45
53
|
|
data/thinking-sphinx.gemspec
CHANGED
@@ -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 = '
|
8
|
+
s.version = '5.4.0'
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Pat Allan"]
|
11
11
|
s.email = ["pat@freelancing-gods.com"]
|
@@ -21,9 +21,9 @@ Gem::Specification.new do |s|
|
|
21
21
|
}
|
22
22
|
s.require_paths = ['lib']
|
23
23
|
|
24
|
-
s.add_runtime_dependency 'activerecord', '>=
|
24
|
+
s.add_runtime_dependency 'activerecord', '>= 4.2.0'
|
25
25
|
s.add_runtime_dependency 'builder', '>= 2.1.2'
|
26
|
-
s.add_runtime_dependency 'joiner', '>= 0.
|
26
|
+
s.add_runtime_dependency 'joiner', '>= 0.3.4'
|
27
27
|
s.add_runtime_dependency 'middleware', '>= 0.1.0'
|
28
28
|
s.add_runtime_dependency 'innertube', '>= 1.0.2'
|
29
29
|
s.add_runtime_dependency 'riddle', '~> 2.3'
|
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:
|
4
|
+
version: 5.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Allan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.2.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.2.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: builder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.3.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.3.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: middleware
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +174,7 @@ executables:
|
|
174
174
|
extensions: []
|
175
175
|
extra_rdoc_files: []
|
176
176
|
files:
|
177
|
+
- ".circleci/config.yml"
|
177
178
|
- ".gitignore"
|
178
179
|
- ".travis.yml"
|
179
180
|
- Appraisals
|
@@ -197,6 +198,7 @@ files:
|
|
197
198
|
- lib/thinking_sphinx/active_record/attribute/type.rb
|
198
199
|
- lib/thinking_sphinx/active_record/attribute/values.rb
|
199
200
|
- lib/thinking_sphinx/active_record/base.rb
|
201
|
+
- lib/thinking_sphinx/active_record/callbacks/association_delta_callbacks.rb
|
200
202
|
- lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb
|
201
203
|
- lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb
|
202
204
|
- lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb
|
@@ -232,6 +234,7 @@ files:
|
|
232
234
|
- lib/thinking_sphinx/attribute_types.rb
|
233
235
|
- lib/thinking_sphinx/batched_search.rb
|
234
236
|
- lib/thinking_sphinx/callbacks.rb
|
237
|
+
- lib/thinking_sphinx/callbacks/appender.rb
|
235
238
|
- lib/thinking_sphinx/capistrano.rb
|
236
239
|
- lib/thinking_sphinx/capistrano/v2.rb
|
237
240
|
- lib/thinking_sphinx/capistrano/v3.rb
|
@@ -355,7 +358,6 @@ files:
|
|
355
358
|
- spec/acceptance/attribute_updates_spec.rb
|
356
359
|
- spec/acceptance/batch_searching_spec.rb
|
357
360
|
- spec/acceptance/big_integers_spec.rb
|
358
|
-
- spec/acceptance/connection_spec.rb
|
359
361
|
- spec/acceptance/excerpts_spec.rb
|
360
362
|
- spec/acceptance/facets_spec.rb
|
361
363
|
- spec/acceptance/geosearching_spec.rb
|
@@ -392,6 +394,7 @@ files:
|
|
392
394
|
- spec/internal/app/indices/book_index.rb
|
393
395
|
- spec/internal/app/indices/car_index.rb
|
394
396
|
- spec/internal/app/indices/city_index.rb
|
397
|
+
- spec/internal/app/indices/colour_index.rb
|
395
398
|
- spec/internal/app/indices/product_index.rb
|
396
399
|
- spec/internal/app/indices/tee_index.rb
|
397
400
|
- spec/internal/app/indices/user_index.rb
|
@@ -460,6 +463,7 @@ files:
|
|
460
463
|
- spec/thinking_sphinx/commands/stop_spec.rb
|
461
464
|
- spec/thinking_sphinx/configuration/minimum_fields_spec.rb
|
462
465
|
- spec/thinking_sphinx/configuration_spec.rb
|
466
|
+
- spec/thinking_sphinx/connection/mri_spec.rb
|
463
467
|
- spec/thinking_sphinx/connection_spec.rb
|
464
468
|
- spec/thinking_sphinx/deletion_spec.rb
|
465
469
|
- spec/thinking_sphinx/deltas/default_delta_spec.rb
|
@@ -507,7 +511,7 @@ homepage: https://pat.github.io/thinking-sphinx/
|
|
507
511
|
licenses:
|
508
512
|
- MIT
|
509
513
|
metadata: {}
|
510
|
-
post_install_message:
|
514
|
+
post_install_message:
|
511
515
|
rdoc_options: []
|
512
516
|
require_paths:
|
513
517
|
- lib
|
@@ -522,8 +526,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
522
526
|
- !ruby/object:Gem::Version
|
523
527
|
version: '0'
|
524
528
|
requirements: []
|
525
|
-
rubygems_version: 3.0.
|
526
|
-
signing_key:
|
529
|
+
rubygems_version: 3.0.3
|
530
|
+
signing_key:
|
527
531
|
specification_version: 4
|
528
532
|
summary: A smart wrapper over Sphinx for ActiveRecord
|
529
533
|
test_files:
|
@@ -532,7 +536,6 @@ test_files:
|
|
532
536
|
- spec/acceptance/attribute_updates_spec.rb
|
533
537
|
- spec/acceptance/batch_searching_spec.rb
|
534
538
|
- spec/acceptance/big_integers_spec.rb
|
535
|
-
- spec/acceptance/connection_spec.rb
|
536
539
|
- spec/acceptance/excerpts_spec.rb
|
537
540
|
- spec/acceptance/facets_spec.rb
|
538
541
|
- spec/acceptance/geosearching_spec.rb
|
@@ -569,6 +572,7 @@ test_files:
|
|
569
572
|
- spec/internal/app/indices/book_index.rb
|
570
573
|
- spec/internal/app/indices/car_index.rb
|
571
574
|
- spec/internal/app/indices/city_index.rb
|
575
|
+
- spec/internal/app/indices/colour_index.rb
|
572
576
|
- spec/internal/app/indices/product_index.rb
|
573
577
|
- spec/internal/app/indices/tee_index.rb
|
574
578
|
- spec/internal/app/indices/user_index.rb
|
@@ -637,6 +641,7 @@ test_files:
|
|
637
641
|
- spec/thinking_sphinx/commands/stop_spec.rb
|
638
642
|
- spec/thinking_sphinx/configuration/minimum_fields_spec.rb
|
639
643
|
- spec/thinking_sphinx/configuration_spec.rb
|
644
|
+
- spec/thinking_sphinx/connection/mri_spec.rb
|
640
645
|
- spec/thinking_sphinx/connection_spec.rb
|
641
646
|
- spec/thinking_sphinx/deletion_spec.rb
|
642
647
|
- spec/thinking_sphinx/deltas/default_delta_spec.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'acceptance/spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'Connections', :live => true do
|
6
|
-
let(:maximum) { (2 ** 23) - 5 }
|
7
|
-
let(:query) { String.new "SELECT * FROM book_core WHERE MATCH('')" }
|
8
|
-
let(:difference) { maximum - query.length }
|
9
|
-
|
10
|
-
it 'allows normal length queries through' do
|
11
|
-
expect {
|
12
|
-
ThinkingSphinx::Connection.take do |connection|
|
13
|
-
connection.execute query.insert(-3, 'a' * difference)
|
14
|
-
end
|
15
|
-
}.to_not raise_error
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'does not allow overly long queries' do
|
19
|
-
expect {
|
20
|
-
ThinkingSphinx::Connection.take do |connection|
|
21
|
-
connection.execute query.insert(-3, 'a' * (difference + 5))
|
22
|
-
end
|
23
|
-
}.to raise_error(ThinkingSphinx::QueryLengthError)
|
24
|
-
end
|
25
|
-
end
|