#604 ✓resolved

dm-validations and dm-timestamps do not validate timestamp properties with :nullable => false

Reported by kristian | October 18th, 2008 @ 07:57 AM

dm-validations and dm-timestamps do not validate timestamp properties with :nullable => false

these validation errors pop up because validation happens before the timestamps are set. but I do want the :nullable => false since I want to the NOT NULL in the database on that timestamps.

right now I do not have control of the order of these aspects. but the lack of control comes from the way how the accepts are integrated. dm-validation uses method chaining:

alias save! save alias save save_with_validations

and dm-timestamps uses the before hook on the save method. but if both would use the same pattern then I could control the order with the order of the require statements:

require 'dm-validations' require 'dm-timestamps'

for myself I patched the dm-timestamps to use methods chaining as well and now I can validate my timestamps !

if there is any interest and I could provide the patch on the dm-timestamps ?!?

Comments and changes to this ticket

  • Paul Sadauskas (Rando)

    Paul Sadauskas (Rando) October 18th, 2008 @ 09:53 AM

    • State changed from “new” to “open”

    The right way would be for dm-timestamps to do:

    before :valid?, :set_timestamp_properties
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) October 18th, 2008 @ 11:43 AM

    Doesn't it seem wrong for Resource#valid? to have a side effect?

  • Sam Smoot

    Sam Smoot October 18th, 2008 @ 08:16 PM

    • State changed from “open” to “hold”

    Both projects will soon be integrated into core, and we won't have this specific issue.

    Other plugins may run into something similar, but we'll tackle that when it comes up.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 4th, 2008 @ 04:18 AM

    • Assigned user cleared.

    Kristan, actually, if you wouldn't mind providing a patch to dm-timestamps it would be appreciated. It is still going to be a few months before we can consider merging dm-timestamps or dm-validations into dm-core, and it would be nice for it to work consistently until them.

    BTW I also updated dm-timestamps so that the timestamp properties are created with :nullable => false constraints: http://is.gd/abkI

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 05:00 AM

    • State changed from “hold” to “resolved”

    FYI, I am no longer considering merging dm-validations and dm-timestamps into core.

    Also, I have updated dm-timestamps so that using the helper method inside it you can create timestamp properties that has nullable => false, and auto_validation => false too.. so you get your nice NOT NULL db constraints now :)

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 »

People watching this ticket