#716 ✓resolved
matt (at mattking)

property of Time type setting to timestamp type in MySQL

Reported by matt (at mattking) | December 15th, 2008 @ 04:18 PM

When setting a property of the Time type, like so:

property :date, Time

It sets the column in MySQL to timestamp type, which makes it so whenever the record is updated, the column is updated to the current timestamp. Not sure if this is expected behavior for the column type.

Can we make it an option to use the timestamp column type? Maybe using :default => :now?

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 15th, 2008 @ 05:55 PM

    • Assigned user set to “Dan Kubb (dkubb)”
    • State changed from “unconfirmed” to “accepted”

    I think this is a property that the MySQL adapter is inheriting from the DO adapter. In ANSI SQL the DATETIME column type doesn't exist, and you use TIMESTAMP. However, in MySQL a TIMESTAMP automatically sets the time to the time now, when nil.

    I will adjust the typemap for MySQL to use DATETIME for Time and DateTime objects and make sure that the DO adapter uses TIMESTAMP for those objects, since the DO adapter should attempt to confirm to ANSI SQL as close as possible, with exceptions made in the RDBMS specific adapters.

    As far as allowing the default to be :now, we likely won't build that into DM. We will however, make it so the :default option can be either a Proc or a Symbol, and when it's a Symbol it will execute the corresponding instance method. In that method you could easily return Time.now. We also have the dm-timestamps plugin for this specific case too.

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 15th, 2008 @ 09:23 PM

    • State changed from “accepted” to “resolved”

    This is now updated in dkubb/dm-core:


    All changes to dm-core, aside from major bug fixes are being done in dkubb/dm-core now. I will accept patches that backport fixes to sam/dm-core (just attach it to this ticket), but it isn't a priority since dkubb/dm-core will become the stable branch in the next month or so. Marking this as resolved.

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