thinking-sphinx 1.4.10 → 1.4.11
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.
- data/README.textile +1 -0
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +1 -1
- data/lib/thinking_sphinx/auto_version.rb +3 -1
- data/lib/thinking_sphinx/configuration.rb +1 -1
- data/lib/thinking_sphinx/index/builder.rb +8 -3
- data/lib/thinking_sphinx/search.rb +5 -3
- data/lib/thinking_sphinx/source.rb +32 -32
- data/lib/thinking_sphinx/version.rb +1 -1
- data/spec/thinking_sphinx/auto_version_spec.rb +24 -16
- data/spec/thinking_sphinx/source_spec.rb +48 -48
- metadata +18 -34
data/README.textile
CHANGED
@@ -14,7 +14,7 @@ module ThinkingSphinx
|
|
14
14
|
clause.split('), ').join(") || '#{separator}' || ")
|
15
15
|
else
|
16
16
|
clause.split(', ').collect { |field|
|
17
|
-
"CAST(COALESCE(#{field}, '') as varchar)"
|
17
|
+
"CAST(COALESCE(#{field}::varchar, '') as varchar)"
|
18
18
|
}.join(" || '#{separator}' || ")
|
19
19
|
end
|
20
20
|
end
|
@@ -9,10 +9,12 @@ module ThinkingSphinx
|
|
9
9
|
require 'riddle/1.10'
|
10
10
|
when /2.0.\d/
|
11
11
|
require 'riddle/2.0.1'
|
12
|
+
when /2.1.\d/
|
13
|
+
require 'riddle/2.1.0'
|
12
14
|
else
|
13
15
|
documentation_link = %Q{
|
14
16
|
For more information, read the documentation:
|
15
|
-
http://freelancing-god.github.com/ts/en/advanced_config.html
|
17
|
+
http://freelancing-god.github.com/ts/en/advanced_config.html
|
16
18
|
}
|
17
19
|
|
18
20
|
if version.nil? || version.empty?
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'blankslate'
|
2
|
-
|
3
1
|
module ThinkingSphinx
|
4
2
|
class Index
|
5
3
|
# The Builder class is the core for the index definition block processing.
|
@@ -14,7 +12,14 @@ module ThinkingSphinx
|
|
14
12
|
# set_property allows you to set some settings on a per-index basis. Check
|
15
13
|
# out each method's documentation for better ideas of usage.
|
16
14
|
#
|
17
|
-
class Builder
|
15
|
+
class Builder
|
16
|
+
instance_methods.grep(/^[^_]/).each { |method|
|
17
|
+
next if method.to_s == "instance_eval"
|
18
|
+
define_method(method) {
|
19
|
+
caller.grep(/irb.completion/).empty? ? method_missing(method) : super
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
18
23
|
def self.generate(model, name = nil, &block)
|
19
24
|
index = ThinkingSphinx::Index.new(model)
|
20
25
|
index.name = name unless name.nil?
|
@@ -215,7 +215,7 @@ module ThinkingSphinx
|
|
215
215
|
def next_page?
|
216
216
|
!next_page.nil?
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
219
|
def last_page?
|
220
220
|
next_page.nil?
|
221
221
|
end
|
@@ -254,7 +254,7 @@ module ThinkingSphinx
|
|
254
254
|
#
|
255
255
|
def total_pages
|
256
256
|
populate
|
257
|
-
return 0 if @results[:total].nil?
|
257
|
+
return 0 if @results.nil? || @results[:total].nil?
|
258
258
|
|
259
259
|
@total_pages ||= (@results[:total] / per_page.to_f).ceil
|
260
260
|
end
|
@@ -279,7 +279,7 @@ module ThinkingSphinx
|
|
279
279
|
#
|
280
280
|
def total_entries
|
281
281
|
populate
|
282
|
-
return 0 if @results[:total_found].nil?
|
282
|
+
return 0 if @results.nil? || @results[:total_found].nil?
|
283
283
|
|
284
284
|
@total_entries ||= @results[:total_found]
|
285
285
|
end
|
@@ -296,6 +296,8 @@ module ThinkingSphinx
|
|
296
296
|
@options[:offset] || ((current_page - 1) * per_page)
|
297
297
|
end
|
298
298
|
|
299
|
+
alias_method :offset_value, :offset
|
300
|
+
|
299
301
|
def indexes
|
300
302
|
return options[:index] if options[:index]
|
301
303
|
return '*' if classes.empty?
|
@@ -5,11 +5,11 @@ module ThinkingSphinx
|
|
5
5
|
class Source
|
6
6
|
include ThinkingSphinx::Source::InternalProperties
|
7
7
|
include ThinkingSphinx::Source::SQL
|
8
|
-
|
8
|
+
|
9
9
|
attr_accessor :model, :fields, :attributes, :joins, :conditions, :groupings,
|
10
10
|
:options
|
11
11
|
attr_reader :base, :index, :database_configuration
|
12
|
-
|
12
|
+
|
13
13
|
def initialize(index, options = {})
|
14
14
|
@index = index
|
15
15
|
@model = index.model
|
@@ -22,83 +22,83 @@ module ThinkingSphinx
|
|
22
22
|
@associations = {}
|
23
23
|
@database_configuration = @model.connection.
|
24
24
|
instance_variable_get(:@config).clone
|
25
|
-
|
25
|
+
|
26
26
|
@base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new(
|
27
27
|
@model, [], nil
|
28
28
|
)
|
29
|
-
|
29
|
+
|
30
30
|
unless @model.descends_from_active_record?
|
31
31
|
stored_class = @model.store_full_sti_class ? @model.name : @model.name.demodulize
|
32
32
|
@conditions << "#{@model.quoted_table_name}.#{quote_column(@model.inheritance_column)} = '#{stored_class}'"
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
add_internal_attributes_and_facets
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def name
|
39
39
|
index.name
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def to_riddle_for_core(offset, position)
|
43
43
|
source = Riddle::Configuration::SQLSource.new(
|
44
44
|
"#{index.core_name}_#{position}", adapter.sphinx_identifier
|
45
45
|
)
|
46
|
-
|
46
|
+
|
47
47
|
set_source_database_settings source
|
48
48
|
set_source_fields source
|
49
49
|
set_source_attributes source, offset
|
50
50
|
set_source_settings source
|
51
51
|
set_source_sql source, offset
|
52
|
-
|
52
|
+
|
53
53
|
source
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def to_riddle_for_delta(offset, position)
|
57
57
|
source = Riddle::Configuration::SQLSource.new(
|
58
58
|
"#{index.delta_name}_#{position}", adapter.sphinx_identifier
|
59
59
|
)
|
60
60
|
source.parent = "#{index.core_name}_#{position}"
|
61
|
-
|
61
|
+
|
62
62
|
set_source_database_settings source
|
63
63
|
set_source_fields source
|
64
64
|
set_source_attributes source, offset, true
|
65
65
|
set_source_settings source
|
66
66
|
set_source_sql source, offset, true
|
67
|
-
|
67
|
+
|
68
68
|
source
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def delta?
|
72
72
|
!@index.delta_object.nil?
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
# Gets the association stack for a specific key.
|
76
|
-
#
|
76
|
+
#
|
77
77
|
def association(key)
|
78
78
|
@associations[key] ||= Association.children(@model, key)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
private
|
82
|
-
|
82
|
+
|
83
83
|
def adapter
|
84
84
|
@adapter ||= @model.sphinx_database_adapter
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
def available_attributes
|
88
88
|
attributes.select { |attrib| attrib.available? }
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def set_source_database_settings(source)
|
92
92
|
config = @database_configuration
|
93
|
-
|
93
|
+
|
94
94
|
source.sql_host = config[:host] || "localhost"
|
95
|
-
source.sql_user = config[:username] || config[:user] || '
|
95
|
+
source.sql_user = config[:username] || config[:user] || ENV['USER']
|
96
96
|
source.sql_pass = (config[:password].to_s || "").gsub('#', '\#')
|
97
97
|
source.sql_db = config[:database]
|
98
98
|
source.sql_port = config[:port]
|
99
99
|
source.sql_sock = config[:socket]
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
def set_source_fields(source)
|
103
103
|
fields.each do |field|
|
104
104
|
source.sql_file_field << field.unique_name if field.file?
|
@@ -106,34 +106,34 @@ module ThinkingSphinx
|
|
106
106
|
source.sql_field_str2wordcount << field.unique_name if field.with_wordcount?
|
107
107
|
end
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
def set_source_attributes(source, offset, delta = false)
|
111
111
|
available_attributes.each do |attrib|
|
112
112
|
source.send(attrib.type_to_config) << attrib.config_value(offset, delta)
|
113
113
|
end
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def set_source_sql(source, offset, delta = false)
|
117
117
|
source.sql_query = to_sql(:offset => offset, :delta => delta).gsub(/\n/, ' ')
|
118
118
|
source.sql_query_range = to_sql_query_range(:delta => delta)
|
119
119
|
source.sql_query_info = to_sql_query_info(offset)
|
120
|
-
|
120
|
+
|
121
121
|
source.sql_query_pre += send(!delta ? :sql_query_pre_for_core : :sql_query_pre_for_delta)
|
122
|
-
|
122
|
+
|
123
123
|
if @index.local_options[:group_concat_max_len]
|
124
124
|
source.sql_query_pre << "SET SESSION group_concat_max_len = #{@index.local_options[:group_concat_max_len]}"
|
125
125
|
end
|
126
|
-
|
126
|
+
|
127
127
|
source.sql_query_pre += [adapter.utf8_query_pre].compact if utf8?
|
128
128
|
source.sql_query_pre << adapter.utc_query_pre
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
def set_source_settings(source)
|
132
132
|
config = ThinkingSphinx::Configuration.instance
|
133
133
|
config.source_options.each do |key, value|
|
134
134
|
source.send("#{key}=".to_sym, value)
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
source_options = ThinkingSphinx::Configuration::SourceOptions
|
138
138
|
@options.each do |key, value|
|
139
139
|
if source_options.include?(key.to_s) && !value.nil?
|
@@ -141,11 +141,11 @@ module ThinkingSphinx
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
# Returns all associations used amongst all the fields and attributes.
|
146
146
|
# This includes all associations between the model and what the actual
|
147
147
|
# columns are from.
|
148
|
-
#
|
148
|
+
#
|
149
149
|
def all_associations
|
150
150
|
@all_associations ||= (
|
151
151
|
# field associations
|
@@ -165,7 +165,7 @@ module ThinkingSphinx
|
|
165
165
|
assoc.ancestors
|
166
166
|
}.flatten.uniq
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
def utf8?
|
170
170
|
@index.options[:charset_type] =~ /utf-8|zh_cn.utf-8/
|
171
171
|
end
|
@@ -5,65 +5,73 @@ describe ThinkingSphinx::AutoVersion do
|
|
5
5
|
before :each do
|
6
6
|
@config = ThinkingSphinx::Configuration.instance
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "should require 0.9.8 if that is the detected version" do
|
10
10
|
ThinkingSphinx::AutoVersion.should_receive(:require).
|
11
11
|
with('riddle/0.9.8')
|
12
|
-
|
12
|
+
|
13
13
|
@config.stub!(:version => '0.9.8')
|
14
14
|
ThinkingSphinx::AutoVersion.detect
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should require 0.9.9 if that is the detected version" do
|
18
18
|
ThinkingSphinx::AutoVersion.should_receive(:require).
|
19
19
|
with('riddle/0.9.9')
|
20
|
-
|
20
|
+
|
21
21
|
@config.stub!(:version => '0.9.9')
|
22
22
|
ThinkingSphinx::AutoVersion.detect
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it "should require 1.10-beta if that is the detected version" do
|
26
26
|
ThinkingSphinx::AutoVersion.should_receive(:require).
|
27
27
|
with('riddle/1.10')
|
28
|
-
|
28
|
+
|
29
29
|
@config.stub!(:version => '1.10-beta')
|
30
30
|
ThinkingSphinx::AutoVersion.detect
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
it "should require 1.10-beta if using 1.10-beta compiled with id64 support" do
|
34
34
|
ThinkingSphinx::AutoVersion.should_receive(:require).
|
35
35
|
with('riddle/1.10')
|
36
|
-
|
36
|
+
|
37
37
|
@config.stub!(:version => '1.10-id64-beta')
|
38
38
|
ThinkingSphinx::AutoVersion.detect
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should require 2.0.1 if using Sphinx 2.0.1 beta" do
|
42
42
|
ThinkingSphinx::AutoVersion.should_receive(:require).
|
43
43
|
with('riddle/2.0.1')
|
44
|
-
|
44
|
+
|
45
45
|
@config.stub!(:version => '2.0.1-beta')
|
46
46
|
ThinkingSphinx::AutoVersion.detect
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "should require 2.0.1 if using Sphinx 2.0.2 dev" do
|
50
50
|
ThinkingSphinx::AutoVersion.should_receive(:require).
|
51
51
|
with('riddle/2.0.1')
|
52
|
-
|
52
|
+
|
53
53
|
@config.stub!(:version => '2.0.2-dev')
|
54
54
|
ThinkingSphinx::AutoVersion.detect
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
|
+
it "should require 2.1.0 if using Sphinx 2.1.0 dev" do
|
58
|
+
ThinkingSphinx::AutoVersion.should_receive(:require).
|
59
|
+
with('riddle/2.1.0')
|
60
|
+
|
61
|
+
@config.stub!(:version => '2.1.0-dev')
|
62
|
+
ThinkingSphinx::AutoVersion.detect
|
63
|
+
end
|
64
|
+
|
57
65
|
it "should output a warning if the detected version is unsupported" do
|
58
66
|
STDERR.should_receive(:puts).with(/unsupported/i)
|
59
|
-
|
67
|
+
|
60
68
|
@config.stub!(:version => '0.9.7')
|
61
69
|
ThinkingSphinx::AutoVersion.detect
|
62
70
|
end
|
63
|
-
|
71
|
+
|
64
72
|
it "should output a warning if the version cannot be determined" do
|
65
73
|
STDERR.should_receive(:puts).at_least(:once)
|
66
|
-
|
74
|
+
|
67
75
|
@config.stub!(:version => nil)
|
68
76
|
ThinkingSphinx::AutoVersion.detect
|
69
77
|
end
|
@@ -5,36 +5,36 @@ describe ThinkingSphinx::Source do
|
|
5
5
|
@index = ThinkingSphinx::Index.new(Person)
|
6
6
|
@source = ThinkingSphinx::Source.new(@index, :sql_range_step => 1000)
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
describe '#initialize' do
|
10
10
|
it "should store the current connection details" do
|
11
11
|
config = Person.connection.instance_variable_get(:@config)
|
12
12
|
@source.database_configuration.should == config
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should generate the name from the model" do
|
17
17
|
@source.name.should == "person"
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should handle namespaced models for name generation" do
|
21
21
|
index = ThinkingSphinx::Index.new(Admin::Person)
|
22
22
|
source = ThinkingSphinx::Source.new(index)
|
23
23
|
source.name.should == "admin_person"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
describe "#to_riddle_for_core" do
|
27
27
|
before :each do
|
28
28
|
config = ThinkingSphinx::Configuration.instance
|
29
29
|
config.source_options[:sql_ranged_throttle] = 100
|
30
|
-
|
30
|
+
|
31
31
|
ThinkingSphinx::Field.new(
|
32
32
|
@source, ThinkingSphinx::Index::FauxColumn.new(:first_name)
|
33
33
|
)
|
34
34
|
ThinkingSphinx::Field.new(
|
35
35
|
@source, ThinkingSphinx::Index::FauxColumn.new(:last_name)
|
36
36
|
)
|
37
|
-
|
37
|
+
|
38
38
|
ThinkingSphinx::Attribute.new(
|
39
39
|
@source, ThinkingSphinx::Index::FauxColumn.new(:id), :as => :internal_id
|
40
40
|
)
|
@@ -52,31 +52,31 @@ describe ThinkingSphinx::Source do
|
|
52
52
|
@source, ThinkingSphinx::Index::FauxColumn.new(:source, :id),
|
53
53
|
:as => :source_id, :type => :integer
|
54
54
|
)
|
55
|
-
|
55
|
+
|
56
56
|
ThinkingSphinx::Join.new(
|
57
57
|
@source, ThinkingSphinx::Index::FauxColumn.new(:links)
|
58
58
|
)
|
59
|
-
|
59
|
+
|
60
60
|
@source.conditions << "`birthday` <= NOW()"
|
61
61
|
@source.groupings << "`first_name`"
|
62
|
-
|
62
|
+
|
63
63
|
@index.local_options[:group_concat_max_len] = 1024
|
64
|
-
|
64
|
+
|
65
65
|
@riddle = @source.to_riddle_for_core(1, 0)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should generate a Riddle Source object" do
|
69
69
|
@riddle.should be_a_kind_of(Riddle::Configuration::SQLSource)
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
it "should use the index and name its own name" do
|
73
73
|
@riddle.name.should == "person_core_0"
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it "should use the model's database connection to determine type" do
|
77
77
|
@riddle.type.should == "mysql"
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
it "should match the model's database settings" do
|
81
81
|
config = Person.connection.instance_variable_get(:@config)
|
82
82
|
@riddle.sql_db.should == config[:database]
|
@@ -86,123 +86,123 @@ describe ThinkingSphinx::Source do
|
|
86
86
|
@riddle.sql_port.should == config[:port]
|
87
87
|
@riddle.sql_sock.should == config[:socket]
|
88
88
|
end
|
89
|
-
|
90
|
-
it "should use a
|
89
|
+
|
90
|
+
it "should use a environment user if nothing else is provided" do
|
91
91
|
Person.connection.stub!(:instance_variable_get => {
|
92
92
|
:user => nil,
|
93
93
|
:username => nil
|
94
94
|
})
|
95
95
|
@source = ThinkingSphinx::Source.new(@index)
|
96
|
-
|
96
|
+
|
97
97
|
riddle = @source.to_riddle_for_core(1, 0)
|
98
|
-
riddle.sql_user.should == '
|
98
|
+
riddle.sql_user.should == ENV['USER']
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
it "should assign attributes" do
|
102
102
|
# 3 internal attributes plus the one requested
|
103
103
|
@riddle.sql_attr_uint.length.should == 4
|
104
104
|
@riddle.sql_attr_uint.last.should == :internal_id
|
105
|
-
|
105
|
+
|
106
106
|
@riddle.sql_attr_timestamp.length.should == 1
|
107
107
|
@riddle.sql_attr_timestamp.first.should == :birthday
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
it "should not include an attribute definition for polymorphic references without data" do
|
111
111
|
@riddle.sql_attr_uint.select { |uint|
|
112
112
|
uint == :source_id
|
113
113
|
}.should be_empty
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
it "should set Sphinx Source options" do
|
117
117
|
@riddle.sql_range_step.should == 1000
|
118
118
|
@riddle.sql_ranged_throttle.should == 100
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
describe "#sql_query" do
|
122
122
|
before :each do
|
123
123
|
@query = @riddle.sql_query
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
it "should select data from the model table" do
|
127
127
|
@query.should match(/FROM `people`/)
|
128
128
|
end
|
129
|
-
|
129
|
+
|
130
130
|
it "should select each of the fields" do
|
131
131
|
@query.should match(/`first_name`.+FROM/)
|
132
132
|
@query.should match(/`last_name`.+FROM/)
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
it "should select each of the attributes" do
|
136
136
|
@query.should match(/`id` AS `internal_id`.+FROM/)
|
137
137
|
@query.should match(/`birthday`.+FROM/)
|
138
138
|
@query.should match(/`tags`.`id`.+ AS `tag_ids`.+FROM/)
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
it "should not match the sourced MVA attribute" do
|
142
142
|
@query.should_not match(/contact_ids/)
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
it "should include joins for required associations" do
|
146
146
|
@query.should match(/LEFT OUTER JOIN `tags`/)
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
it "should not include joins for the sourced MVA attribute" do
|
150
150
|
@query.should_not match(/LEFT OUTER JOIN `contacts`/)
|
151
151
|
end
|
152
|
-
|
152
|
+
|
153
153
|
it "should include explicitly requested joins" do
|
154
154
|
@query.should match(/LEFT OUTER JOIN `links`/)
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
it "should include any defined conditions" do
|
158
158
|
@query.should match(/WHERE.+`birthday` <= NOW()/)
|
159
159
|
end
|
160
|
-
|
160
|
+
|
161
161
|
it "should include any defined groupings" do
|
162
162
|
@query.should match(/GROUP BY.+`first_name`/)
|
163
163
|
end
|
164
164
|
end
|
165
|
-
|
165
|
+
|
166
166
|
describe "#sql_query_range" do
|
167
167
|
before :each do
|
168
168
|
@query = @riddle.sql_query_range
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
it "should select data from the model table" do
|
172
172
|
@query.should match(/FROM `people`/)
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
it "should select the minimum and the maximum ids" do
|
176
176
|
@query.should match(/SELECT.+MIN.+MAX.+FROM/)
|
177
177
|
end
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
describe "#sql_query_info" do
|
181
181
|
before :each do
|
182
182
|
@query = @riddle.sql_query_info
|
183
183
|
end
|
184
|
-
|
184
|
+
|
185
185
|
it "should select all fields from the model table" do
|
186
186
|
@query.should match(/SELECT \* FROM `people`/)
|
187
187
|
end
|
188
|
-
|
188
|
+
|
189
189
|
it "should filter the primary key with the offset" do
|
190
190
|
model_count = ThinkingSphinx.context.indexed_models.size
|
191
191
|
@query.should match(/WHERE `id` = \(\(\$id - 1\) \/ #{model_count}\)/)
|
192
192
|
end
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
describe "#sql_query_pre" do
|
196
196
|
before :each do
|
197
197
|
@queries = @riddle.sql_query_pre
|
198
198
|
end
|
199
|
-
|
199
|
+
|
200
200
|
it "should default to just the UTF8 statement" do
|
201
201
|
@queries.detect { |query|
|
202
202
|
query == "SET NAMES utf8"
|
203
203
|
}.should_not be_nil
|
204
204
|
end
|
205
|
-
|
205
|
+
|
206
206
|
it "should set the group_concat_max_len session value for MySQL if requested" do
|
207
207
|
@queries.detect { |query|
|
208
208
|
query == "SET SESSION group_concat_max_len = 1024"
|
@@ -210,41 +210,41 @@ describe ThinkingSphinx::Source do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
end
|
213
|
-
|
213
|
+
|
214
214
|
describe "#to_riddle_for_core with range disabled" do
|
215
215
|
before :each do
|
216
216
|
ThinkingSphinx::Field.new(
|
217
217
|
@source, ThinkingSphinx::Index::FauxColumn.new(:first_name)
|
218
218
|
)
|
219
219
|
end
|
220
|
-
|
220
|
+
|
221
221
|
describe "set per-index" do
|
222
222
|
before :each do
|
223
223
|
@index.local_options[:disable_range] = true
|
224
224
|
@riddle = @source.to_riddle_for_core(1, 0)
|
225
225
|
end
|
226
|
-
|
226
|
+
|
227
227
|
it "should not have the range in the sql_query" do
|
228
228
|
@riddle.sql_query.should_not match(/`people`.`id` >= \$start/)
|
229
229
|
@riddle.sql_query.should_not match(/`people`.`id` <= \$end/)
|
230
230
|
end
|
231
|
-
|
231
|
+
|
232
232
|
it "should not have a sql_query_range" do
|
233
233
|
@riddle.sql_query_range.should be_nil
|
234
234
|
end
|
235
235
|
end
|
236
|
-
|
236
|
+
|
237
237
|
describe "set globally" do
|
238
238
|
before :each do
|
239
239
|
ThinkingSphinx::Configuration.instance.index_options[:disable_range] = true
|
240
240
|
@riddle = @source.to_riddle_for_core(1, 0)
|
241
241
|
end
|
242
|
-
|
242
|
+
|
243
243
|
it "should not have the range in the sql_query" do
|
244
244
|
@riddle.sql_query.should_not match(/`people`.`id` >= \$start/)
|
245
245
|
@riddle.sql_query.should_not match(/`people`.`id` <= \$end/)
|
246
246
|
end
|
247
|
-
|
247
|
+
|
248
248
|
it "should not have a sql_query_range" do
|
249
249
|
@riddle.sql_query_range.should be_nil
|
250
250
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thinking-sphinx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 1.4.
|
9
|
+
- 11
|
10
|
+
version: 1.4.11
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pat Allan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2012-01-02 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -74,25 +74,9 @@ dependencies:
|
|
74
74
|
type: :runtime
|
75
75
|
prerelease: false
|
76
76
|
requirement: *id003
|
77
|
-
- !ruby/object:Gem::Dependency
|
78
|
-
name: builder
|
79
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
80
|
-
none: false
|
81
|
-
requirements:
|
82
|
-
- - ">="
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
hash: 15
|
85
|
-
segments:
|
86
|
-
- 2
|
87
|
-
- 1
|
88
|
-
- 2
|
89
|
-
version: 2.1.2
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
requirement: *id004
|
93
77
|
- !ruby/object:Gem::Dependency
|
94
78
|
name: cucumber
|
95
|
-
version_requirements: &
|
79
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
96
80
|
none: false
|
97
81
|
requirements:
|
98
82
|
- - "="
|
@@ -105,10 +89,10 @@ dependencies:
|
|
105
89
|
version: 1.0.2
|
106
90
|
type: :development
|
107
91
|
prerelease: false
|
108
|
-
requirement: *
|
92
|
+
requirement: *id004
|
109
93
|
- !ruby/object:Gem::Dependency
|
110
94
|
name: faker
|
111
|
-
version_requirements: &
|
95
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
112
96
|
none: false
|
113
97
|
requirements:
|
114
98
|
- - "="
|
@@ -121,10 +105,10 @@ dependencies:
|
|
121
105
|
version: 0.3.1
|
122
106
|
type: :development
|
123
107
|
prerelease: false
|
124
|
-
requirement: *
|
108
|
+
requirement: *id005
|
125
109
|
- !ruby/object:Gem::Dependency
|
126
110
|
name: ginger
|
127
|
-
version_requirements: &
|
111
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
128
112
|
none: false
|
129
113
|
requirements:
|
130
114
|
- - "="
|
@@ -137,10 +121,10 @@ dependencies:
|
|
137
121
|
version: 1.2.0
|
138
122
|
type: :development
|
139
123
|
prerelease: false
|
140
|
-
requirement: *
|
124
|
+
requirement: *id006
|
141
125
|
- !ruby/object:Gem::Dependency
|
142
126
|
name: rake
|
143
|
-
version_requirements: &
|
127
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
144
128
|
none: false
|
145
129
|
requirements:
|
146
130
|
- - ">="
|
@@ -153,10 +137,10 @@ dependencies:
|
|
153
137
|
version: 0.9.2
|
154
138
|
type: :development
|
155
139
|
prerelease: false
|
156
|
-
requirement: *
|
140
|
+
requirement: *id007
|
157
141
|
- !ruby/object:Gem::Dependency
|
158
142
|
name: rspec
|
159
|
-
version_requirements: &
|
143
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
160
144
|
none: false
|
161
145
|
requirements:
|
162
146
|
- - "="
|
@@ -169,10 +153,10 @@ dependencies:
|
|
169
153
|
version: 2.6.0
|
170
154
|
type: :development
|
171
155
|
prerelease: false
|
172
|
-
requirement: *
|
156
|
+
requirement: *id008
|
173
157
|
- !ruby/object:Gem::Dependency
|
174
158
|
name: will_paginate
|
175
|
-
version_requirements: &
|
159
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
176
160
|
none: false
|
177
161
|
requirements:
|
178
162
|
- - "="
|
@@ -185,10 +169,10 @@ dependencies:
|
|
185
169
|
version: 2.3.15
|
186
170
|
type: :development
|
187
171
|
prerelease: false
|
188
|
-
requirement: *
|
172
|
+
requirement: *id009
|
189
173
|
- !ruby/object:Gem::Dependency
|
190
174
|
name: yard
|
191
|
-
version_requirements: &
|
175
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
192
176
|
none: false
|
193
177
|
requirements:
|
194
178
|
- - ">="
|
@@ -201,7 +185,7 @@ dependencies:
|
|
201
185
|
version: 0.7.2
|
202
186
|
type: :development
|
203
187
|
prerelease: false
|
204
|
-
requirement: *
|
188
|
+
requirement: *id010
|
205
189
|
description: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
|
206
190
|
email:
|
207
191
|
- pat@freelancing-gods.com
|