Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord::record_timestamps broken in RC2 (regression from RC1)

#5440

Just noticed that ActiveRecord::Base.record_timestamps = false no longer prevents timestamps from being updated. This is a regression in RC2; the issue was not present in RC1.

Demo using an "Article" mode in a rails console session:

>> a=Article.first
  Article Load (0.2ms)  SELECT `articles`.* FROM `articles` LIMIT 1
>> Article.record_timestamps
=> true
>> Article.record_timestamps = false
=> false
>> Article.record_timestamps
=> false
>> a.public = false
=> false
>> a.save
  SQL (0.2ms)  UPDATE `articles` SET `public` = 0, `updated_at` = '2010-08-24 12:25:58' WHERE (`articles`.`id` = 1)

Same bug occurs when setting the record_timestamps value on ActiveRecord::Base itself:

>> ActiveRecord::Base.record_timestamps 
=> true
>> ActiveRecord::Base.record_timestamps = false
=> false
>> a=Article.first
  Article Load (0.2ms)  SELECT `articles`.* FROM `articles` LIMIT 1
>> a.public=true
=> true
>> a.save
  SQL (0.2ms)  UPDATE `articles` SET `public` = 1, `updated_at` = '2010-08-24 12:27:11' WHERE (`articles`.`id` = 1)

Going to use git bisect to see if I can locate the bad commit. There are a couple of candidates I can see in the history that touch code in the record_timestamps path. Will post back once I've found the commit.

Reported by Wincent Colaiuta · August 24th, 2010 @ 01:32 PM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: High

Activity

  1. Wincent Colaiuta
    Wincent Colaiuta
    • Assigned user set to José Valim

    Output from git bisect reveals that this commit is the culprit:

    30ea923040ded944209c98383389b6c9aafe806a is the first bad commit
    commit 30ea923040ded944209c98383389b6c9aafe806a
    Author: José Valim <jose.valim@gmail.com>
    Date:   Thu Aug 12 12:04:16 2010 -0300
    
        Make update_attribute behave as in Rails 2.3 and document the behavior intrinsic to its implementation.
    
    :040000 040000 22165ee5875272a3e985c8fec168483b2c885a89 2ec79fa40b23c189cad633ae076204835fda4e83 M  activerecord
    

    August 24th, 2010 @ 01:40 PM

  2. José Valim
    José Valim
    • Milestone cleared.
    • State changed from new to open
    • Importance changed from to High

    Could you please to attach a failing test case in ActiveRecord test suite? And I will fix it ASAP.

    August 24th, 2010 @ 01:56 PM

  3. José Valim
    José Valim

    The fix is simple:

    http://github.com/rails/rails/commit/30ea923040ded944209c98383389b6...

    We are missing a parenthesis there. Just waiting for the test case to fix it (feel free to include the fix in your patch as well!).

    August 24th, 2010 @ 02:15 PM

  4. Wincent Colaiuta
    Wincent Colaiuta

    Here's a test case, but I can't actually run it yet because Bundler is giving me hell. Hopefully it's right. In the meantime I'll continue to fight with Bundler.

    August 24th, 2010 @ 02:22 PM

  5. Repository
  6. Repository
  7. Wincent Colaiuta
  8. Jeremy Kemper