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

Hi,

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

For example, when I execute

  Game.first.touch

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 (
games.id = 1)' at line 1: UPDATE games SET WHERE (games.id = 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
  end

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

Regards
Lars

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments