diff --git a/client/ruby/solrb/lib/solr/request/select.rb b/client/ruby/solrb/lib/solr/request/select.rb index e4ddabd577a..120c129a8f5 100644 --- a/client/ruby/solrb/lib/solr/request/select.rb +++ b/client/ruby/solrb/lib/solr/request/select.rb @@ -40,9 +40,9 @@ module Solr http_params = [] raw_params.each do |key,value| if value.respond_to? :each - value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" } + value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" unless v.nil?} else - http_params << "#{key}=#{ERB::Util::url_encode(value)}" + http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil? end end diff --git a/client/ruby/solrb/test/unit/standard_request_test.rb b/client/ruby/solrb/test/unit/standard_request_test.rb index c536ff01190..2ffc63810c5 100755 --- a/client/ruby/solrb/test/unit/standard_request_test.rb +++ b/client/ruby/solrb/test/unit/standard_request_test.rb @@ -41,8 +41,15 @@ class StandardRequestTest < Test::Unit::TestCase assert_equal ['fq1','fq2'], request.to_hash[:fq] assert_equal "id,title,score", request.to_hash[:fl] end + + def test_empty_params + request = Solr::Request::Standard.new(:query => 'query', :debug_query => false) + assert_nil request.to_hash[:rows] + assert_no_match /rows/, request.to_s + assert_match /debugQuery/, request.to_s + end - def test_facet_params + def test_facet_params_all request = Solr::Request::Standard.new(:query => 'query', :facets => { :fields => [:genre,