diff --git a/lib/addressable/uri.rb b/lib/addressable/uri.rb
index <HASH>..<HASH> 100644
--- a/lib/addressable/uri.rb
+++ b/lib/addressable/uri.rb
@@ -331,7 +331,10 @@ module Addressable
       return nil if component.nil?
 
       begin
-        if component.kind_of?(Symbol) || component.kind_of?(Numeric)
+        if component.kind_of?(Symbol) ||
+            component.kind_of?(Numeric) ||
+            component.kind_of?(TrueClass) ||
+            component.kind_of?(FalseClass)
           component = component.to_s
         else
           component = component.to_str
diff --git a/spec/addressable/uri_spec.rb b/spec/addressable/uri_spec.rb
index <HASH>..<HASH> 100644
--- a/spec/addressable/uri_spec.rb
+++ b/spec/addressable/uri_spec.rb
@@ -2934,7 +2934,7 @@ describe Addressable::URI, "when parsed from " +
   end
 
   it "should have the correct query string after flag hash assignment" do
-    @uri.query_values = {'flag?1' => true, 'fl=ag2' => true, 'flag3' => true}
+    @uri.query_values = {'flag?1' => nil, 'fl=ag2' => nil, 'flag3' => nil}
     @uri.query.split("&").should include("flag%3F1")
     @uri.query.split("&").should include("fl%3Dag2")
     @uri.query.split("&").should include("flag3")
Wasn't handling boolean query values consistently.