lib/thinking_sphinx/source.rb in warp-thinking-sphinx-1.3.11 vs lib/thinking_sphinx/source.rb in warp-thinking-sphinx-1.3.13
- old
+ new
@@ -6,21 +6,23 @@
include ThinkingSphinx::Source::InternalProperties
include ThinkingSphinx::Source::SQL
attr_accessor :model, :fields, :attributes, :conditions, :groupings,
:options
- attr_reader :base, :index
+ attr_reader :base, :index, :database_configuration
def initialize(index, options = {})
@index = index
@model = index.model
@fields = []
@attributes = []
@conditions = []
@groupings = []
@options = options
@associations = {}
+ @database_configuration = @model.connection.
+ instance_variable_get(:@config).clone
@base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new(
@model, [], nil
)
@@ -78,10 +80,10 @@
def adapter
@adapter ||= @model.sphinx_database_adapter
end
def set_source_database_settings(source)
- config = @model.connection.instance_variable_get(:@config)
+ config = @database_configuration
source.sql_host = config[:host] || "localhost"
source.sql_user = config[:username] || config[:user] || 'root'
source.sql_pass = (config[:password].to_s || "").gsub('#', '\#')
source.sql_db = config[:database]