#1290 ✓not-applicable

dm-timestamps does not work on "save!"

Reported by DeSchleib | May 25th, 2010 @ 05:21 PM

If one calls "save!" on an dm-timestamps enabled resource, no timestamps gets updatet.
I browsed the source. It's because 'save!' calls _save instead of save and timestamps only adds 'before :save'.

Possible solution:

# syntax formatting is broken
module DataMapper
  module Timestamps

def self.included(model)
  model.before :save,  :set_timestamps_on_save
  model.before :save!, :set_timestamps_on_save # added
  model.extend ClassMethods

end end

I use 1.0.0.rc2

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) May 25th, 2010 @ 08:31 PM

    • State changed from “new” to “not-applicable”

    The timestamps are not supposed to save with Resource#save!. The purpose of Resource#save! is to bypass all hooks, validations and everything else and save the exact current state of the resource. By setting timestamps in that context we'd be breaking the contract that method has.

    Are you thinking that Resource#save! behaves differently than it does? Perhaps you assume it works like in ActiveRecord where it will throw an exception if something goes wrong?

  • DeSchleib

    DeSchleib May 26th, 2010 @ 01:11 AM

    • Tag cleared.

    My bad. Thanks for the hint.

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 »