Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4753

Make global Boolean definition opt-in

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 7.3.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Major Change

      Mongoid defines Boolean here:
      https://github.com/mongodb/mongoid/blob/621294b9d4f38e2f0a32984bbb415d544bed437c/lib/mongoid/criteria/queryable/extensions.rb#L4

       

      Reasons why this is bad:

      1) It is not Ruby-esque. Ruby core team has chosen NOT to define Boolean (see here: https://bugs.ruby-lang.org/issues/12515)

      2) It may conflict with gems which define Boolean as a module instead of a class.

      3) Internally, Mongoid is already mapping `field :my_bool, type: Boolean` to `Mongoid::Boolean`, which causes surprising behavior in various places (one small example: https://github.com/mongoid/mongoid-rspec/issues/136)

       

      A good solution would be to remove `::Boolean` require users to use `Mongoid::Boolean` everywhere. This will require users to update their API usage in a backward compatible way (Mongoid::Boolean already works on Mongoid 3+) so it's a relatively painless upgrade.

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

              Created:
              Updated:
              Resolved: