This project is archived and is in readonly mode.

#5439 ✓resolved
Lars Kuhnt

[Patch] ActiveRecord::Timestamp#touch still fails when no updated_at/on column is present

Reported by Lars Kuhnt | August 24th, 2010 @ 12:12 PM | in 3.0.2


ActiveRecord::Timestamp#touch generates malformed SQL when the models table misses an updated_at/on column.

For example, when I execute


the following error is raised:

ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ( = 1)' at line 1: UPDATE games SET WHERE ( = 1)

Shouldnt #touch in this case just return false instead of raising an error?

This is especially a problem with polymorphic associations, i.e.

  class Comment < ActiveRecord::Base
    belongs_to :commentable, :polymorphic => true, :touch => true

does not work when one of the commentable models misses the updated_at/on column.


Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>