datastax_rails 1.0.17.1 → 1.0.17.2

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.
@@ -113,7 +113,7 @@ module DatastaxRails
113
113
  # @return [DatastaxRails::RSolrClientWrapper] a wrapped RSolr connection
114
114
  def solr_connection(reconnect = false)
115
115
  if(!@rsolr || reconnect)
116
- @rsolr = DatastaxRails::RSolrClientWrapper.new(establish_solr_connection)
116
+ @rsolr = DatastaxRails::RSolrClientWrapper.new(establish_solr_connection, self)
117
117
  end
118
118
  @rsolr
119
119
  end
@@ -431,7 +431,15 @@ module DatastaxRails
431
431
 
432
432
  protected
433
433
  def find_by_attributes(match, attributes, *args) #:nodoc:
434
- conditions = Hash[attributes.map {|a| [a, args[attributes.index(a)]]}]
434
+ conditions = {}
435
+ Hash[attributes.map {|a| [a, args[attributes.index(a)]]}].each do |k,v|
436
+ if(v.is_a?(String))
437
+ conditions[k] = v.gsub(/(\W)/, '\\\\\1')
438
+ else
439
+ conditions[k] = v
440
+ end
441
+ end
442
+
435
443
  result = where(conditions).send(match.finder)
436
444
 
437
445
  if match.blank? && result.blank?
@@ -3,14 +3,15 @@ module DatastaxRails
3
3
  # a new server tried (if one is available)
4
4
  class RSolrClientWrapper < BlankSlate
5
5
  # @param [RSolr::Client] rsolr the initial RSolr client object to wrap
6
- def initialize(rsolr)
6
+ def initialize(rsolr,model)
7
7
  @rsolr = rsolr
8
+ @model = model
8
9
  end
9
10
 
10
11
  def method_missing(sym, *args, &block)
11
12
  if @rsolr.uri.host != DatastaxRails::Base.current_server
12
13
  @rsolr.uri.host = DatastaxRails::Base.current_server
13
- @rsolr = DatastaxRails::Base.establish_solr_connection
14
+ @rsolr = @model.establish_solr_connection
14
15
  end
15
16
  @rsolr.__send__(sym, *args, &block)
16
17
  rescue Errno::ECONNREFUSED
@@ -1,4 +1,4 @@
1
1
  module DatastaxRails
2
2
  # The current version of the gem
3
- VERSION = "1.0.17.1"
3
+ VERSION = "1.0.17.2"
4
4
  end
@@ -1,4 +1,16 @@
1
1
  development:
2
+ servers: ["sade-rs-ds1.opensource.gov:9160", "sade-rs-ds2.opensource.gov:9160", "sade-rs-ds3.opensource.gov:9160"]
3
+ keyspace: "datastax_rails_development"
4
+ strategy_options: {"RS": "3"}
5
+ connection_options:
6
+ timeout: 20
7
+ retries: 3
8
+ server_max_requests: 1000
9
+ solr:
10
+ port: 8983
11
+ path: /solr
12
+
13
+ dev:
2
14
  servers: ["127.0.0.1:9160"]
3
15
  keyspace: "datastax_rails_development"
4
16
  strategy_class: "org.apache.cassandra.locator.SimpleStrategy"