Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1768

URI serialization to string

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.19.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible

      The stdlib URI can serialize itself back to a string:

      irb(main):002:0> URI.parse('http://foo.bar')
      => #<URI::HTTP http://foo.bar>
      irb(main):003:0> URI.parse('http://foo.bar').to_s
      => "http://foo.bar"
      

      MongoDB URIs do not support this functionality:

      irb(main):001:0> Mongo::URI.new('mongodb://foo.bar')
      => #<Mongo::URI:0x00005612fe09f620 @string="mongodb://foo.bar", @options={}, @servers=["foo.bar"], @user=nil, @password=nil, @uri_options={}>
      irb(main):002:0> Mongo::URI.new('mongodb://foo.bar').to_s
      => "#<Mongo::URI:0x00005612fe0a1ec0>"
      

      This makes it impossible to take a URI string, parse it into a URI, modify the URI and serialize the result out to a string to be used as a URI later.

            Assignee:
            neil.shweky@mongodb.com Neil Shweky (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: