#748 ✓not-applicable

enquoting of function as default value generates incorrect syntax in mysql

Reported by gruntruk | January 6th, 2009 @ 08:00 PM

This will cause mysql to fail:

@@@ruby create_table :test do column :created_at, DateTime, :not_null => true, :default => 'NOW()'

It appears the base adapter implementation is always enquoting strings, so you get:

`created_at` datetime NOT NULL DEFAULT 'NOW()'

Instead of @@@sql created_at datetime NOT NULL DEFAULT NOW()

I'm not sure what the right fix here is, so wanted to raise ticket and see about suggestions.  Workaround for now would be to execute alter table directly to set the default value.

Comments and changes to this ticket

  • gruntruk

    gruntruk January 6th, 2009 @ 08:03 PM

    • Tag set to migrations

    Really wish there was a preview... sorry for bad formatting :(

    create_table :test do column :created_at, DateTime, :not_null => true, :default => 'NOW()'
    `created_at` datetime NOT NULL DEFAULT 'NOW()'
    `created_at` datetime NOT NULL DEFAULT NOW()
  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) January 8th, 2009 @ 04:28 AM

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

    DataMapper should not support using database specific functions in any of it's commands (and the odd place where this is not true, will likely be changing).

    Try using dm-timestamps to get the equivalent behavior in a database agnostic manner.

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