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

Allow Int32/Int64 objects to be constructed from other objects of the same type

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • bson-4.6.0
    • Affects Version/s: None
    • Component/s: BSON
    • None
    • Fully Compatible

      Currently Int32/Int64 constructors require Integer objects, and fail when given objects of their own class:

      irb(main):001:0> a=BSON::Int64.new(1)
      => #<BSON::Int64:0x000055770cbdc148 @integer=1>
      irb(main):002:0> a=BSON::Int64.new(a)
      Traceback (most recent call last):
              6: from /home/me/.rbenv/versions/2.6/bin/irb:23:in `<main>'
              5: from /home/me/.rbenv/versions/2.6/bin/irb:23:in `load'
              4: from /home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/irb-1.0.0/exe/irb:11:in `<top (required)>'
              3: from (irb):2
              2: from (irb):2:in `new'
              1: from /home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/bson-4.5.0/lib/bson/int64.rb:55:in `initialize'
      NoMethodError (undefined method `bson_int64?' for #<BSON::Int64:0x000055770cbdc148 @integer=1>)
      Did you mean?  bson_type
      

      This makes it awkward for calling code to instantiate Int32/Int64 objects.

      Instead constructors should accept parameters of the same class as the one being constructed.

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

              Created:
              Updated:
              Resolved: