thinking-sphinx 3.0.0 → 3.0.1

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.
Files changed (52) hide show
  1. data/.travis.yml +6 -3
  2. data/HISTORY +18 -0
  3. data/README.textile +31 -8
  4. data/gemfiles/rails_3_1.gemfile +2 -2
  5. data/gemfiles/rails_3_2.gemfile +2 -2
  6. data/lib/thinking/sphinx.rb +1 -0
  7. data/lib/thinking_sphinx.rb +1 -0
  8. data/lib/thinking_sphinx/active_record.rb +2 -0
  9. data/lib/thinking_sphinx/active_record/association.rb +8 -0
  10. data/lib/thinking_sphinx/active_record/associations.rb +25 -5
  11. data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +1 -5
  12. data/lib/thinking_sphinx/active_record/column.rb +12 -0
  13. data/lib/thinking_sphinx/active_record/database_adapters.rb +7 -0
  14. data/lib/thinking_sphinx/active_record/filtered_reflection.rb +49 -0
  15. data/lib/thinking_sphinx/active_record/interpreter.rb +6 -0
  16. data/lib/thinking_sphinx/active_record/polymorpher.rb +50 -0
  17. data/lib/thinking_sphinx/active_record/property.rb +6 -0
  18. data/lib/thinking_sphinx/active_record/property_query.rb +1 -1
  19. data/lib/thinking_sphinx/active_record/property_sql_presenter.rb +7 -1
  20. data/lib/thinking_sphinx/active_record/sql_builder.rb +7 -2
  21. data/lib/thinking_sphinx/active_record/sql_source.rb +5 -1
  22. data/lib/thinking_sphinx/capistrano.rb +64 -0
  23. data/lib/thinking_sphinx/configuration.rb +10 -1
  24. data/lib/thinking_sphinx/connection.rb +20 -0
  25. data/lib/thinking_sphinx/errors.rb +24 -0
  26. data/lib/thinking_sphinx/middlewares/sphinxql.rb +4 -1
  27. data/lib/thinking_sphinx/real_time/transcriber.rb +1 -1
  28. data/lib/thinking_sphinx/search/batch_inquirer.rb +3 -1
  29. data/lib/thinking_sphinx/search/glaze.rb +3 -3
  30. data/spec/acceptance/index_options_spec.rb +5 -0
  31. data/spec/acceptance/searching_on_fields_spec.rb +1 -0
  32. data/spec/acceptance/specifying_sql_spec.rb +107 -0
  33. data/spec/acceptance/sql_deltas_spec.rb +9 -0
  34. data/spec/acceptance/support/sphinx_controller.rb +1 -0
  35. data/spec/internal/app/models/event.rb +3 -0
  36. data/spec/internal/app/models/hardcover.rb +3 -0
  37. data/spec/internal/db/schema.rb +7 -1
  38. data/spec/thinking_sphinx/active_record/associations_spec.rb +2 -1
  39. data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +3 -3
  40. data/spec/thinking_sphinx/active_record/column_spec.rb +23 -0
  41. data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +18 -0
  42. data/spec/thinking_sphinx/active_record/filtered_reflection_spec.rb +141 -0
  43. data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +65 -0
  44. data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +28 -4
  45. data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +11 -1
  46. data/spec/thinking_sphinx/configuration_spec.rb +24 -0
  47. data/spec/thinking_sphinx/connection_spec.rb +82 -0
  48. data/spec/thinking_sphinx/errors_spec.rb +36 -0
  49. data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +25 -0
  50. data/spec/thinking_sphinx/search/glaze_spec.rb +3 -0
  51. data/thinking-sphinx.gemspec +1 -1
  52. metadata +25 -3
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe ThinkingSphinx::SphinxError do
4
+ describe '.new_from_mysql' do
5
+ let(:error) { double 'error', :message => 'index foo: unknown error',
6
+ :backtrace => ['foo', 'bar'] }
7
+
8
+ it "translates syntax errors" do
9
+ error.stub :message => 'index foo: syntax error: something is wrong'
10
+
11
+ ThinkingSphinx::SphinxError.new_from_mysql(error).
12
+ should be_a(ThinkingSphinx::SyntaxError)
13
+ end
14
+
15
+ it "translates parse errors" do
16
+ error.stub :message => 'index foo: parse error: something is wrong'
17
+
18
+ ThinkingSphinx::SphinxError.new_from_mysql(error).
19
+ should be_a(ThinkingSphinx::ParseError)
20
+ end
21
+
22
+ it "defaults to sphinx errors" do
23
+ error.stub :message => 'index foo: unknown error: something is wrong'
24
+
25
+ ThinkingSphinx::SphinxError.new_from_mysql(error).
26
+ should be_a(ThinkingSphinx::SphinxError)
27
+ end
28
+
29
+ it "keeps the original error's backtrace" do
30
+ error.stub :message => 'index foo: unknown error: something is wrong'
31
+
32
+ ThinkingSphinx::SphinxError.new_from_mysql(error).
33
+ backtrace.should == error.backtrace
34
+ end
35
+ end
36
+ end
@@ -108,6 +108,31 @@ describe ThinkingSphinx::Middlewares::SphinxQL do
108
108
  middleware.call [context]
109
109
  end
110
110
 
111
+ it "quotes namespaced models in the class name condition" do
112
+ db_connection = double('db connection', :select_values => [],
113
+ :schema_cache => double('cache', :table_exists? => false))
114
+ supermodel = Class.new(ActiveRecord::Base) do
115
+ def self.name; 'Animals::Cat'; end
116
+ def self.inheritance_column; 'type'; end
117
+ end
118
+ supermodel.stub :connection => db_connection, :column_names => ['type']
119
+ submodel = Class.new(supermodel) do
120
+ def self.name; 'Animals::Lion'; end
121
+ def self.inheritance_column; 'type'; end
122
+ def self.table_name; 'cats'; end
123
+ end
124
+ submodel.stub :connection => db_connection, :column_names => ['type'],
125
+ :descendants => []
126
+
127
+ search.options[:classes] = [submodel]
128
+
129
+ ThinkingSphinx::Search::Query.should_receive(:new).with(anything,
130
+ hash_including(:sphinx_internal_class_name => '("Animals::Lion")'), anything).
131
+ and_return(query)
132
+
133
+ middleware.call [context]
134
+ end
135
+
111
136
  it "does not query the database for subclasses if :skip_sti is set to true" do
112
137
  model = double('model', :connection => double,
113
138
  :ancestors => [ActiveRecord::Base], :name => 'Animal')
@@ -43,6 +43,9 @@ describe ThinkingSphinx::Search::Glaze do
43
43
  end
44
44
 
45
45
  it "raises the method missing error otherwise" do
46
+ object.stub :respond_to? => false
47
+ object.stub(:baz).and_raise(NoMethodError)
48
+
46
49
  lambda { glaze.baz }.should raise_error(NoMethodError)
47
50
  end
48
51
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'thinking-sphinx'
6
- s.version = '3.0.0'
6
+ s.version = '3.0.1'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ["Pat Allan"]
9
9
  s.email = ["pat@freelancing-gods.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-02 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -175,6 +175,7 @@ files:
175
175
  - gemfiles/rails_3_1.gemfile
176
176
  - gemfiles/rails_3_2.gemfile
177
177
  - lib/thinking-sphinx.rb
178
+ - lib/thinking/sphinx.rb
178
179
  - lib/thinking_sphinx.rb
179
180
  - lib/thinking_sphinx/active_record.rb
180
181
  - lib/thinking_sphinx/active_record/association.rb
@@ -194,9 +195,11 @@ files:
194
195
  - lib/thinking_sphinx/active_record/database_adapters/mysql_adapter.rb
195
196
  - lib/thinking_sphinx/active_record/database_adapters/postgresql_adapter.rb
196
197
  - lib/thinking_sphinx/active_record/field.rb
198
+ - lib/thinking_sphinx/active_record/filtered_reflection.rb
197
199
  - lib/thinking_sphinx/active_record/index.rb
198
200
  - lib/thinking_sphinx/active_record/interpreter.rb
199
201
  - lib/thinking_sphinx/active_record/log_subscriber.rb
202
+ - lib/thinking_sphinx/active_record/polymorpher.rb
200
203
  - lib/thinking_sphinx/active_record/property.rb
201
204
  - lib/thinking_sphinx/active_record/property_query.rb
202
205
  - lib/thinking_sphinx/active_record/property_sql_presenter.rb
@@ -205,6 +208,7 @@ files:
205
208
  - lib/thinking_sphinx/active_record/sql_source/template.rb
206
209
  - lib/thinking_sphinx/batched_search.rb
207
210
  - lib/thinking_sphinx/callbacks.rb
211
+ - lib/thinking_sphinx/capistrano.rb
208
212
  - lib/thinking_sphinx/configuration.rb
209
213
  - lib/thinking_sphinx/configuration/consistent_ids.rb
210
214
  - lib/thinking_sphinx/configuration/defaults.rb
@@ -216,6 +220,7 @@ files:
216
220
  - lib/thinking_sphinx/core/property.rb
217
221
  - lib/thinking_sphinx/deltas.rb
218
222
  - lib/thinking_sphinx/deltas/default_delta.rb
223
+ - lib/thinking_sphinx/errors.rb
219
224
  - lib/thinking_sphinx/excerpter.rb
220
225
  - lib/thinking_sphinx/facet.rb
221
226
  - lib/thinking_sphinx/facet_search.rb
@@ -313,8 +318,10 @@ files:
313
318
  - spec/internal/app/models/book.rb
314
319
  - spec/internal/app/models/city.rb
315
320
  - spec/internal/app/models/colour.rb
321
+ - spec/internal/app/models/event.rb
316
322
  - spec/internal/app/models/flightless_bird.rb
317
323
  - spec/internal/app/models/genre.rb
324
+ - spec/internal/app/models/hardcover.rb
318
325
  - spec/internal/app/models/mammal.rb
319
326
  - spec/internal/app/models/product.rb
320
327
  - spec/internal/app/models/tag.rb
@@ -340,14 +347,18 @@ files:
340
347
  - spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb
341
348
  - spec/thinking_sphinx/active_record/database_adapters_spec.rb
342
349
  - spec/thinking_sphinx/active_record/field_spec.rb
350
+ - spec/thinking_sphinx/active_record/filtered_reflection_spec.rb
343
351
  - spec/thinking_sphinx/active_record/index_spec.rb
344
352
  - spec/thinking_sphinx/active_record/interpreter_spec.rb
353
+ - spec/thinking_sphinx/active_record/polymorpher_spec.rb
345
354
  - spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb
346
355
  - spec/thinking_sphinx/active_record/sql_builder_spec.rb
347
356
  - spec/thinking_sphinx/active_record/sql_source_spec.rb
348
357
  - spec/thinking_sphinx/configuration_spec.rb
358
+ - spec/thinking_sphinx/connection_spec.rb
349
359
  - spec/thinking_sphinx/deltas/default_delta_spec.rb
350
360
  - spec/thinking_sphinx/deltas_spec.rb
361
+ - spec/thinking_sphinx/errors_spec.rb
351
362
  - spec/thinking_sphinx/excerpter_spec.rb
352
363
  - spec/thinking_sphinx/facet_search_spec.rb
353
364
  - spec/thinking_sphinx/index_set_spec.rb
@@ -389,12 +400,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
389
400
  - - ! '>='
390
401
  - !ruby/object:Gem::Version
391
402
  version: '0'
403
+ segments:
404
+ - 0
405
+ hash: -122546704410277760
392
406
  required_rubygems_version: !ruby/object:Gem::Requirement
393
407
  none: false
394
408
  requirements:
395
409
  - - ! '>='
396
410
  - !ruby/object:Gem::Version
397
411
  version: '0'
412
+ segments:
413
+ - 0
414
+ hash: -122546704410277760
398
415
  requirements: []
399
416
  rubyforge_project: thinking-sphinx
400
417
  rubygems_version: 1.8.23
@@ -447,8 +464,10 @@ test_files:
447
464
  - spec/internal/app/models/book.rb
448
465
  - spec/internal/app/models/city.rb
449
466
  - spec/internal/app/models/colour.rb
467
+ - spec/internal/app/models/event.rb
450
468
  - spec/internal/app/models/flightless_bird.rb
451
469
  - spec/internal/app/models/genre.rb
470
+ - spec/internal/app/models/hardcover.rb
452
471
  - spec/internal/app/models/mammal.rb
453
472
  - spec/internal/app/models/product.rb
454
473
  - spec/internal/app/models/tag.rb
@@ -474,14 +493,18 @@ test_files:
474
493
  - spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb
475
494
  - spec/thinking_sphinx/active_record/database_adapters_spec.rb
476
495
  - spec/thinking_sphinx/active_record/field_spec.rb
496
+ - spec/thinking_sphinx/active_record/filtered_reflection_spec.rb
477
497
  - spec/thinking_sphinx/active_record/index_spec.rb
478
498
  - spec/thinking_sphinx/active_record/interpreter_spec.rb
499
+ - spec/thinking_sphinx/active_record/polymorpher_spec.rb
479
500
  - spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb
480
501
  - spec/thinking_sphinx/active_record/sql_builder_spec.rb
481
502
  - spec/thinking_sphinx/active_record/sql_source_spec.rb
482
503
  - spec/thinking_sphinx/configuration_spec.rb
504
+ - spec/thinking_sphinx/connection_spec.rb
483
505
  - spec/thinking_sphinx/deltas/default_delta_spec.rb
484
506
  - spec/thinking_sphinx/deltas_spec.rb
507
+ - spec/thinking_sphinx/errors_spec.rb
485
508
  - spec/thinking_sphinx/excerpter_spec.rb
486
509
  - spec/thinking_sphinx/facet_search_spec.rb
487
510
  - spec/thinking_sphinx/index_set_spec.rb
@@ -510,4 +533,3 @@ test_files:
510
533
  - spec/thinking_sphinx/search/query_spec.rb
511
534
  - spec/thinking_sphinx/search_spec.rb
512
535
  - spec/thinking_sphinx_spec.rb
513
- has_rdoc: