From 4f85c3998bd279989a6e0b76d87498e3ad6e3e1e Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Tue, 16 Jan 2007 21:28:44 +0000 Subject: [PATCH] Exempt nil parameters from the Solr request git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@496863 13f79535-47bb-0310-9956-ffa450edef68 --- client/ruby/solrb/lib/solr/request/select.rb | 4 ++-- client/ruby/solrb/test/unit/standard_request_test.rb | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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,