#1136 ✓resolved

:nullable => false is NOT equivalent to :required => true

Reported by kristian | November 28th, 2009 @ 12:28 AM | in 0.10.2

to reproduce the bug clone http://github.com/mkristian/datamapper4rails and run rake integration_tests.

this produces 2 failures with dm-core edge (0.10.2). after replacing :nullable => false with :required => true in tmp/app/models/group.rb and tmp/app/models/user.rb it worked:

cd tmp
rake spec

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) November 30th, 2009 @ 02:06 AM

    @kristian: I ran the specs, saw the failures and made the change from :nullable => false to :required => true and the specs pass. I'm not sure I understand how this is a bug? In dm-core 0.10.2, we deprecated :nullable in favor of :required. Is the error message not clear enough, or is there another problem I'm not seeing?

  • kristian

    kristian November 30th, 2009 @ 02:58 AM

    • Tag cleared.

    @dkubb: deprecated is OK and what to do to "remove" the deprecated is also clear. the bug is that specs pass with 0.10.1 and fail with 0.10.2, i.e. the behavior changed as well. and from logic I would say nullable => false is the same as required => true !! (but I know I can mess up these logic problems quite a bit so please feel free to correct me)

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) November 30th, 2009 @ 01:41 PM

    • State changed from “unconfirmed” to “not-applicable”
    • Milestone cleared.

    @kristan: Ahh, I see what you mean. Actually, there was bug in validations #935 that was resolved partly due to restructuring the code in dm-validations, and partly due to clearing up the API in dm-core.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 2nd, 2009 @ 12:19 PM

    • Assigned user set to “Dan Kubb (dkubb)”
    • State changed from “not-applicable” to “accepted”
    • Milestone set to 0.10.2

    After discussing with kristian on irc, I have decided that along with the deprecation warning we will flip :nullable => false to be :required => true, instead of :allow_nil => false.

    This change only affects people using :nullable, and will keep the behaviour consistent. Everyone is expected to find/replace instances of :nullable with :required ASAP however, since the deprecation warning is likely going away in the next release.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 2nd, 2009 @ 12:32 PM

    • State changed from “accepted” to “resolved”

    (from [5f9a0b5c0f7108025c98bb33bedffc185a21f839]) Cleaned up deprecation warnings for :nullable

    • When :nullable => true is required, change it to :required => false instead of :allow_nil => true.

    [#1136 state:resolved] http://github.com/datamapper/dm-core/commit/5f9a0b5c0f7108025c98bb3...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Referenced by