thinking-sphinx 3.1.4 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -2
  3. data/Appraisals +4 -4
  4. data/Gemfile +2 -0
  5. data/HISTORY +24 -0
  6. data/README.textile +5 -4
  7. data/gemfiles/rails_3_2.gemfile +2 -1
  8. data/gemfiles/rails_4_0.gemfile +2 -1
  9. data/gemfiles/rails_4_1.gemfile +2 -1
  10. data/gemfiles/rails_4_2.gemfile +2 -1
  11. data/lib/thinking_sphinx.rb +4 -1
  12. data/lib/thinking_sphinx/active_record.rb +1 -0
  13. data/lib/thinking_sphinx/active_record/association_proxy/attribute_finder.rb +1 -1
  14. data/lib/thinking_sphinx/active_record/attribute/type.rb +1 -1
  15. data/lib/thinking_sphinx/active_record/base.rb +1 -1
  16. data/lib/thinking_sphinx/active_record/callbacks/delete_callbacks.rb +1 -1
  17. data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +7 -3
  18. data/lib/thinking_sphinx/active_record/callbacks/update_callbacks.rb +2 -2
  19. data/lib/thinking_sphinx/active_record/column_sql_presenter.rb +5 -1
  20. data/lib/thinking_sphinx/active_record/index.rb +4 -4
  21. data/lib/thinking_sphinx/active_record/source_joins.rb +55 -0
  22. data/lib/thinking_sphinx/active_record/sql_builder.rb +3 -18
  23. data/lib/thinking_sphinx/active_record/sql_builder/query.rb +7 -0
  24. data/lib/thinking_sphinx/active_record/sql_source.rb +7 -5
  25. data/lib/thinking_sphinx/active_record/sql_source/template.rb +1 -1
  26. data/lib/thinking_sphinx/callbacks.rb +18 -0
  27. data/lib/thinking_sphinx/configuration.rb +50 -33
  28. data/lib/thinking_sphinx/configuration/duplicate_names.rb +34 -0
  29. data/lib/thinking_sphinx/connection.rb +4 -4
  30. data/lib/thinking_sphinx/controller.rb +6 -4
  31. data/lib/thinking_sphinx/deletion.rb +13 -0
  32. data/lib/thinking_sphinx/errors.rb +8 -0
  33. data/lib/thinking_sphinx/index_set.rb +6 -1
  34. data/lib/thinking_sphinx/indexing_strategies/all_at_once.rb +7 -0
  35. data/lib/thinking_sphinx/indexing_strategies/one_at_a_time.rb +14 -0
  36. data/lib/thinking_sphinx/middlewares/active_record_translator.rb +1 -1
  37. data/lib/thinking_sphinx/middlewares/inquirer.rb +1 -1
  38. data/lib/thinking_sphinx/middlewares/sphinxql.rb +2 -2
  39. data/lib/thinking_sphinx/middlewares/stale_id_checker.rb +1 -1
  40. data/lib/thinking_sphinx/middlewares/stale_id_filter.rb +2 -2
  41. data/lib/thinking_sphinx/rake_interface.rb +14 -5
  42. data/lib/thinking_sphinx/real_time.rb +1 -0
  43. data/lib/thinking_sphinx/real_time/attribute.rb +7 -1
  44. data/lib/thinking_sphinx/real_time/index.rb +2 -0
  45. data/lib/thinking_sphinx/real_time/populator.rb +3 -3
  46. data/lib/thinking_sphinx/real_time/property.rb +1 -5
  47. data/lib/thinking_sphinx/real_time/transcriber.rb +44 -9
  48. data/lib/thinking_sphinx/real_time/translator.rb +36 -0
  49. data/lib/thinking_sphinx/search.rb +10 -0
  50. data/lib/thinking_sphinx/search/context.rb +8 -0
  51. data/lib/thinking_sphinx/search/stale_ids_exception.rb +3 -2
  52. data/lib/thinking_sphinx/subscribers/populator_subscriber.rb +1 -1
  53. data/lib/thinking_sphinx/tasks.rb +3 -1
  54. data/spec/acceptance/remove_deleted_records_spec.rb +18 -0
  55. data/spec/acceptance/searching_with_filters_spec.rb +13 -0
  56. data/spec/internal/app/indices/product_index.rb +1 -0
  57. data/spec/internal/db/schema.rb +1 -0
  58. data/spec/spec_helper.rb +1 -0
  59. data/spec/support/json_column.rb +29 -0
  60. data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +10 -0
  61. data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +10 -0
  62. data/spec/thinking_sphinx/active_record/column_sql_presenter_spec.rb +37 -0
  63. data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +7 -17
  64. data/spec/thinking_sphinx/active_record/sql_source_spec.rb +43 -15
  65. data/spec/thinking_sphinx/errors_spec.rb +7 -0
  66. data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +15 -1
  67. data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +1 -0
  68. data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +26 -6
  69. data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +4 -4
  70. data/spec/thinking_sphinx_spec.rb +2 -1
  71. data/thinking-sphinx.gemspec +1 -1
  72. metadata +12 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c37a8158a4baca6cab0f26af120eeb5465ee53fc
4
- data.tar.gz: 875569737b2a9456c28302c2bfd5a06b9571f3ea
3
+ metadata.gz: 3f8b8aa71063530ab0e184d27cc0fd8afe17da77
4
+ data.tar.gz: c54952a5a6aa5a4b84e75ceb57071ddfc2244851
5
5
  SHA512:
6
- metadata.gz: 8409e713da894877707dfd5d0bad3fc6454b1c1b21edce294778fedad926d04e6947db05d938fb9473af59f4636c57d65b9ffc682e9afdfde467ab86a552bf6c
7
- data.tar.gz: 486a6e944456d0d007e44759259d915e32c09bbd8e263699762d56be1a5ad736de8576f41a2ceb6b035552bb6cf0baf44c7d8c440a54d0c1dff470d159bfba64
6
+ metadata.gz: 5684d082b99b5e6131d3244711316d099df261a9b07a1c1452f47150344e2e5ed32f55bdc0fe69948d62f291ef8fd99aeb71b936aebd845d96a2cee78453bc08
7
+ data.tar.gz: 8d6de05c533ff85787d7d248a548e53fdc1c370c7a625a5a6dd717b2c1bb449c16a1a54b643e87f8ea16ad8b0b844c0ac7c31c453da4a23ec6c763b03bf74cbf
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.0.0
5
- - 2.1.0
4
+ - 2.1
5
+ - 2.2
6
6
  - jruby-19mode
7
7
  before_install:
8
8
  - gem update --system
@@ -19,3 +19,8 @@ env:
19
19
  - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.1.9/bin/ SPHINX_VERSION=2.1.9
20
20
  - DATABASE=mysql2 SPHINX_BIN=/usr/local/sphinx-2.2.6/bin/ SPHINX_VERSION=2.2.6
21
21
  - DATABASE=postgresql SPHINX_BIN=/usr/local/sphinx-2.2.6/bin/ SPHINX_VERSION=2.2.6
22
+ sudo: false
23
+ addons:
24
+ postgresql: "9.4"
25
+ services:
26
+ - postgresql
data/Appraisals CHANGED
@@ -1,15 +1,15 @@
1
1
  appraise 'rails_3_2' do
2
- gem 'rails', '~> 3.2.21'
2
+ gem 'rails', '~> 3.2.22.2'
3
3
  end
4
4
 
5
5
  appraise 'rails_4_0' do
6
- gem 'rails', '~> 4.0.12'
6
+ gem 'rails', '~> 4.0.13'
7
7
  end
8
8
 
9
9
  appraise 'rails_4_1' do
10
- gem 'rails', '~> 4.1.8'
10
+ gem 'rails', '~> 4.1.15'
11
11
  end
12
12
 
13
13
  appraise 'rails_4_2' do
14
- gem 'rails', '~> 4.2.0'
14
+ gem 'rails', '~> 4.2.6'
15
15
  end
data/Gemfile CHANGED
@@ -5,5 +5,7 @@ gemspec
5
5
  gem 'mysql2', '~> 0.3.12b4', :platform => :ruby
6
6
  gem 'pg', '~> 0.16.0', :platform => :ruby
7
7
 
8
+ gem 'jdbc-mysql', '5.1.35', :platform => :jruby
8
9
  gem 'activerecord-jdbcmysql-adapter', '~> 1.3.4', :platform => :jruby
9
10
  gem 'activerecord-jdbcpostgresql-adapter', '~> 1.3.4', :platform => :jruby
11
+
data/HISTORY CHANGED
@@ -1,3 +1,27 @@
1
+ 2016-05-13: 3.2.0
2
+ * [FIX] Ensure SQL table aliases are reliable for SQL-backed index queries.
3
+ * [FEATURE] Add JSON attribute support for real-time indices.
4
+ * [FEATURE] Add ability to disable *all* Sphinx-related callbacks via ThinkingSphinx::Callbacks.suspend! and ThinkingSphinx::Callbacks.resume!. Particularly useful for unit tests.
5
+ * [FEATURE] Add native OutOfBoundsError for search queries outside the pagination bounds.
6
+ * [CHANGE] Improved error messages for duplicate property names and missing columns.
7
+ * [FIX] Fixed mysql2 compatibility for memory references (Roman Usherenko).
8
+ * [FIX] Fixed JRuby compatibility with camelCase method names (Brandon Dewitt).
9
+ * [FEATURE] Support MySQL SSL options on a per-index level (@arrtchiu).
10
+ * [CHANGE] Don't populate search results when requesting just the count values (Andrew Roth).
11
+ * [CHANGE] Reset delta column before core indexing begins (reverting behaviour introduced in 3.1.0). See issue #958 for further discussion.
12
+ * [FEATURE] Allow for different indexing strategies (e.g. all at once, or one by one).
13
+ * [FIX] Fix stale id handling for multiple search contexts (Jonathan del Strother).
14
+ * [CHANGE] Use Sphinx's bulk insert ability (Chance Downs).
15
+ * [CHANGE] Reduce memory/object usage for model references (Jonathan del Strother).
16
+ * [CHANGE] Disable deletion callbacks when real-time indices are in place and all other real-time callbacks are disabled.
17
+ * [FIX] Handle quoting of namespaced tables (Roman Usherenko).
18
+ * [FIX] Make preload_indices thread-safe.
19
+ * [FIX] Improved handling of marshalled/demarshalled search results.
20
+ * [FEATURE] Allow rand_seed as a select option (Mattia Gheda).
21
+ * [FEATURE] Add primary_key option for index definitions (Nathaneal Gray).
22
+ * [FEATURE] Add ability to start searchd in the foreground (Andrey Novikov).
23
+ * [CHANGE] Only use ERB to parse the YAML file if ERB is loaded.
24
+
1
25
  2015-06-01: 3.1.4
2
26
  * [FIX] Kaminari expects prev_page to be available.
3
27
  * [CHANGE] Add a contributor code of conduct.
@@ -1,11 +1,12 @@
1
1
  h1. Thinking Sphinx
2
2
 
3
- 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.1.4.
3
+ 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.2.0.
4
4
 
5
5
  h2. Upgrading
6
6
 
7
7
  Please refer to the release notes for any changes you need to make when upgrading:
8
8
 
9
+ * "v3.2.0":https://github.com/pat/thinking-sphinx/releases/tag/v3.2.0
9
10
  * "v3.1.4":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.4
10
11
  * "v3.1.3":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.3
11
12
  * "v3.1.2":https://github.com/pat/thinking-sphinx/releases/tag/v3.1.2
@@ -20,10 +21,10 @@ h2. Installation
20
21
  It's a gem, so install it like you would any other gem. You will also need to specify the mysql2 gem if you're using MRI, or jdbc-mysql if you're using JRuby:
21
22
 
22
23
  <pre><code>gem 'mysql2', '~> 0.3.18', :platform => :ruby
23
- gem 'jdbc-mysql', '~> 5.1.35', :platform => :jruby
24
- gem 'thinking-sphinx', '~> 3.1.4'</code></pre>
24
+ gem 'jdbc-mysql', '= 5.1.35', :platform => :jruby
25
+ gem 'thinking-sphinx', '~> 3.2.0'</code></pre>
25
26
 
26
- The MySQL gems mentioned are required for connecting to Sphinx, so please include it even when you're using PostgreSQL for your database.
27
+ 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.
27
28
 
28
29
  You'll also need to install Sphinx - this is covered in "the extended documentation":http://pat.github.io/thinking-sphinx/installing_sphinx.html.
29
30
 
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
6
  gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "jdbc-mysql", "5.1.35", :platform => :jruby
7
8
  gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
9
  gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
- gem "rails", "~> 3.2.21"
10
+ gem "rails", "~> 3.2.22.2"
10
11
 
11
12
  gemspec :path => "../"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
6
  gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "jdbc-mysql", "5.1.35", :platform => :jruby
7
8
  gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
9
  gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
- gem "rails", "~> 4.0.12"
10
+ gem "rails", "~> 4.0.13"
10
11
 
11
12
  gemspec :path => "../"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
6
  gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "jdbc-mysql", "5.1.35", :platform => :jruby
7
8
  gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
9
  gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
- gem "rails", "~> 4.1.8"
10
+ gem "rails", "~> 4.1.15"
10
11
 
11
12
  gemspec :path => "../"
@@ -4,8 +4,9 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "mysql2", "~> 0.3.12b4", :platform => :ruby
6
6
  gem "pg", "~> 0.16.0", :platform => :ruby
7
+ gem "jdbc-mysql", "5.1.35", :platform => :jruby
7
8
  gem "activerecord-jdbcmysql-adapter", "~> 1.3.4", :platform => :jruby
8
9
  gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.4", :platform => :jruby
9
- gem "rails", "~> 4.2.0"
10
+ gem "rails", "~> 4.2.6"
10
11
 
11
12
  gemspec :path => "../"
@@ -16,7 +16,7 @@ require 'active_support/core_ext/module/attribute_accessors'
16
16
 
17
17
  module ThinkingSphinx
18
18
  def self.count(query = '', options = {})
19
- search(query, options).total_entries
19
+ search_for_ids(query, options).total_entries
20
20
  end
21
21
 
22
22
  def self.facets(query = '', options = {})
@@ -39,6 +39,7 @@ module ThinkingSphinx
39
39
  @before_index_hooks = []
40
40
 
41
41
  module Subscribers; end
42
+ module IndexingStrategies; end
42
43
  end
43
44
 
44
45
  # Core
@@ -57,6 +58,8 @@ require 'thinking_sphinx/float_formatter'
57
58
  require 'thinking_sphinx/frameworks'
58
59
  require 'thinking_sphinx/guard'
59
60
  require 'thinking_sphinx/index'
61
+ require 'thinking_sphinx/indexing_strategies/all_at_once'
62
+ require 'thinking_sphinx/indexing_strategies/one_at_a_time'
60
63
  require 'thinking_sphinx/index_set'
61
64
  require 'thinking_sphinx/masks'
62
65
  require 'thinking_sphinx/middlewares'
@@ -23,6 +23,7 @@ require 'thinking_sphinx/active_record/polymorpher'
23
23
  require 'thinking_sphinx/active_record/property_query'
24
24
  require 'thinking_sphinx/active_record/property_sql_presenter'
25
25
  require 'thinking_sphinx/active_record/simple_many_query'
26
+ require 'thinking_sphinx/active_record/source_joins'
26
27
  require 'thinking_sphinx/active_record/sql_builder'
27
28
  require 'thinking_sphinx/active_record/sql_source'
28
29
 
@@ -29,7 +29,7 @@ class ThinkingSphinx::ActiveRecord::AssociationProxy::AttributeFinder
29
29
  @indices ||= begin
30
30
  configuration.preload_indices
31
31
  configuration.indices_for_references(
32
- *@association.klass.name.underscore.to_sym
32
+ *ThinkingSphinx::IndexSet.reference_name(@association.klass)
33
33
  ).reject &:distributed?
34
34
  end
35
35
  end
@@ -72,7 +72,7 @@ class ThinkingSphinx::ActiveRecord::Attribute::Type
72
72
 
73
73
  def type_from_database
74
74
  raise ThinkingSphinx::MissingColumnError,
75
- "column #{column_name} does not exist" if database_column.nil?
75
+ "Cannot determine the database type of column #{column_name}, as it does not exist" if database_column.nil?
76
76
 
77
77
  return :bigint if big_integer?
78
78
 
@@ -21,7 +21,7 @@ module ThinkingSphinx::ActiveRecord::Base
21
21
  end
22
22
 
23
23
  def search_count(query = nil, options = {})
24
- search(query, options).total_entries
24
+ search_for_ids(query, options).total_entries
25
25
  end
26
26
 
27
27
  def search_for_ids(query = nil, options = {})
@@ -4,7 +4,7 @@ class ThinkingSphinx::ActiveRecord::Callbacks::DeleteCallbacks <
4
4
  callbacks :after_destroy
5
5
 
6
6
  def after_destroy
7
- return if instance.new_record?
7
+ return if ThinkingSphinx::Callbacks.suspended? || instance.new_record?
8
8
 
9
9
  indices.each { |index|
10
10
  ThinkingSphinx::Deletion.perform index, instance.id
@@ -4,9 +4,9 @@ class ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks <
4
4
  callbacks :after_commit, :before_save
5
5
 
6
6
  def after_commit
7
- return unless delta_indices? && processors.any? { |processor|
7
+ return unless !suspended? && delta_indices? && processors.any? { |processor|
8
8
  processor.toggled?(instance)
9
- } && !ThinkingSphinx::Deltas.suspended?
9
+ }
10
10
 
11
11
  delta_indices.each do |index|
12
12
  index.delta_processor.index index
@@ -18,7 +18,7 @@ class ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks <
18
18
  end
19
19
 
20
20
  def before_save
21
- return unless delta_indices?
21
+ return unless !ThinkingSphinx::Callbacks.suspended? && delta_indices?
22
22
 
23
23
  processors.each { |processor| processor.toggle instance }
24
24
  end
@@ -48,4 +48,8 @@ class ThinkingSphinx::ActiveRecord::Callbacks::DeltaCallbacks <
48
48
  def processors
49
49
  delta_indices.collect &:delta_processor
50
50
  end
51
+
52
+ def suspended?
53
+ ThinkingSphinx::Callbacks.suspended? || ThinkingSphinx::Deltas.suspended?
54
+ end
51
55
  end
@@ -4,7 +4,7 @@ class ThinkingSphinx::ActiveRecord::Callbacks::UpdateCallbacks <
4
4
  callbacks :after_update
5
5
 
6
6
  def after_update
7
- return unless updates_enabled?
7
+ return unless !ThinkingSphinx::Callbacks.suspended? && updates_enabled?
8
8
 
9
9
  indices.each do |index|
10
10
  update index unless index.distributed?
@@ -35,7 +35,7 @@ class ThinkingSphinx::ActiveRecord::Callbacks::UpdateCallbacks <
35
35
  end
36
36
 
37
37
  def reference
38
- instance.class.name.underscore.to_sym
38
+ ThinkingSphinx::IndexSet.reference_name(instance.class)
39
39
  end
40
40
 
41
41
  def update(index)
@@ -13,7 +13,7 @@ class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter
13
13
  return __name if string?
14
14
  return nil unless exists?
15
15
 
16
- quoted_table = escape_table? ? adapter.quote(table) : table
16
+ quoted_table = escape_table? ? escape_table(table) : table
17
17
 
18
18
  "#{quoted_table}.#{adapter.quote __name}"
19
19
  end
@@ -24,6 +24,10 @@ class ThinkingSphinx::ActiveRecord::ColumnSQLPresenter
24
24
 
25
25
  delegate :__stack, :__name, :string?, :to => :column
26
26
 
27
+ def escape_table(table_name)
28
+ table_name.split('.').map { |t| adapter.quote(t) }.join('.')
29
+ end
30
+
27
31
  def escape_table?
28
32
  table[/[`"]/].nil?
29
33
  end
@@ -28,6 +28,10 @@ class ThinkingSphinx::ActiveRecord::Index < Riddle::Configuration::Index
28
28
  @facets ||= sources.collect(&:facets).flatten
29
29
  end
30
30
 
31
+ def fields
32
+ sources.collect(&:fields).flatten
33
+ end
34
+
31
35
  def sources
32
36
  interpret_definition!
33
37
  super
@@ -44,10 +48,6 @@ class ThinkingSphinx::ActiveRecord::Index < Riddle::Configuration::Index
44
48
  adapter_for(model)
45
49
  end
46
50
 
47
- def fields
48
- sources.collect(&:fields).flatten
49
- end
50
-
51
51
  def interpreter
52
52
  ThinkingSphinx::ActiveRecord::Interpreter
53
53
  end
@@ -0,0 +1,55 @@
1
+ class ThinkingSphinx::ActiveRecord::SourceJoins
2
+ def self.call(model, source)
3
+ new(model, source).call
4
+ end
5
+
6
+ def initialize(model, source)
7
+ @model, @source = model, source
8
+ end
9
+
10
+ def call
11
+ append_specified_associations
12
+ append_property_associations
13
+
14
+ joins
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :model, :source
20
+
21
+ def append_property_associations
22
+ source.properties.collect(&:columns).each do |columns|
23
+ columns.each { |column| append_column_associations column }
24
+ end
25
+ end
26
+
27
+ def append_column_associations(column)
28
+ return if column.__stack.empty?
29
+
30
+ joins.add_join_to column.__stack if column_exists?(column)
31
+ end
32
+
33
+ def append_specified_associations
34
+ source.associations.reject(&:string?).each do |association|
35
+ joins.add_join_to association.stack
36
+ end
37
+ end
38
+
39
+ def column_exists?(column)
40
+ Joiner::Path.new(model, column.__stack).model
41
+ true
42
+ rescue Joiner::AssociationNotFound
43
+ false
44
+ end
45
+
46
+ def joins
47
+ @joins ||= begin
48
+ joins = Joiner::Joins.new model
49
+ if joins.respond_to?(:join_association_class)
50
+ joins.join_association_class = ThinkingSphinx::ActiveRecord::JoinAssociation
51
+ end
52
+ joins
53
+ end
54
+ end
55
+ end
@@ -20,12 +20,6 @@ module ThinkingSphinx
20
20
  query.to_query
21
21
  end
22
22
 
23
- def sql_query_post_index
24
- return [] unless delta_processor && !source.delta?
25
-
26
- [delta_processor.reset_query]
27
- end
28
-
29
23
  private
30
24
 
31
25
  delegate :adapter, :model, :delta_processor, :to => :source
@@ -49,18 +43,9 @@ module ThinkingSphinx
49
43
  end
50
44
 
51
45
  def associations
52
- @associations ||= begin
53
- joins = Joiner::Joins.new model
54
- if joins.respond_to?(:join_association_class)
55
- joins.join_association_class = ThinkingSphinx::ActiveRecord::JoinAssociation
56
- end
57
-
58
- source.associations.reject(&:string?).each do |association|
59
- joins.add_join_to association.stack
60
- end
61
-
62
- joins
63
- end
46
+ @associations ||= ThinkingSphinx::ActiveRecord::SourceJoins.call(
47
+ model, source
48
+ )
64
49
  end
65
50
 
66
51
  def quote_column(column)
@@ -18,10 +18,17 @@ module ThinkingSphinx
18
18
 
19
19
  def filter_by_query_pre
20
20
  scope_by_time_zone
21
+ scope_by_delta_processor
21
22
  scope_by_session
22
23
  scope_by_utf8
23
24
  end
24
25
 
26
+ def scope_by_delta_processor
27
+ return unless delta_processor && !source.delta?
28
+
29
+ self.scope << delta_processor.reset_query
30
+ end
31
+
25
32
  def scope_by_session
26
33
  return unless max_len = source.options[:group_concat_max_len]
27
34
 
@@ -61,6 +61,10 @@ module ThinkingSphinx
61
61
  options[:primary_key]
62
62
  end
63
63
 
64
+ def properties
65
+ fields + attributes
66
+ end
67
+
64
68
  def render
65
69
  prepare_for_render unless @prepared
66
70
 
@@ -74,6 +78,9 @@ module ThinkingSphinx
74
78
  @sql_db ||= settings[:database]
75
79
  @sql_port ||= settings[:port]
76
80
  @sql_sock ||= settings[:socket]
81
+ @mysql_ssl_cert ||= settings[:sslcert]
82
+ @mysql_ssl_key ||= settings[:sslkey]
83
+ @mysql_ssl_ca ||= settings[:sslca]
77
84
  end
78
85
 
79
86
  def type
@@ -119,7 +126,6 @@ module ThinkingSphinx
119
126
  @sql_query = builder.sql_query
120
127
  @sql_query_range ||= builder.sql_query_range
121
128
  @sql_query_pre += builder.sql_query_pre
122
- @sql_query_post_index += builder.sql_query_post_index
123
129
  end
124
130
 
125
131
  def config
@@ -136,10 +142,6 @@ module ThinkingSphinx
136
142
 
137
143
  @prepared = true
138
144
  end
139
-
140
- def properties
141
- fields + attributes
142
- end
143
145
  end
144
146
  end
145
147
  end