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.

When an ActiveRecord has a column named 'field', bad behavior happens

#3274

I've attached a patch showing the broken test.

If Blarg has a string column named 'field', creating a Blarg instance results in the following:

@@@>> a = Blarg.new => #

a.field = {:elad => 'elad'} ArgumentError: wrong number of arguments (4 for 1)

from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/../../activemodel/lib/active_model/attribute_methods.rb:147:in attribute_changed?'<br/> from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/../../activemodel/lib/active_model/attribute_methods.rb:147:insend'
from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/../../activemodel/lib/active_model/attribute_methods.rb:147:in field_changed?'<br/> from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods/dirty.rb:153:inwrite_attribute'
from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods/write.rb:13:in field='<br/> from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:35:insend'
from /Users/eladmeidar/projects/bugmash/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:35:in method_missing'<br/> from (irb):3 @@@

Reported by Joe Van Dyk · September 27th, 2009 @ 12:56 AM

State: stale
Milestone: none
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Joe Van Dyk
    Joe Van Dyk

    Ouch, thought I formatted it correctly.

    September 27th, 2009 @ 12:57 AM

  2. Joe Van Dyk
    Joe Van Dyk

    I've attached a patch that includes the broken test and fixes the issue.

    September 27th, 2009 @ 01:08 AM

  3. Joe Van Dyk
    Joe Van Dyk

    Ooops, bad patch. Better one attached.

    September 27th, 2009 @ 01:09 AM

  4. Joe Van Dyk
    Joe Van Dyk
    • Tag changed from 3, activerecord to 3, activerecord, patch

    September 27th, 2009 @ 01:11 AM

  5. Elad Meidar
    Elad Meidar

    +1 verified and applies cleanly on Master, tests pass as well... also, this may probably lead to also closing down #1742 [PATCH] serialize fails when :type => :text and :null => false with mysql only

    September 27th, 2009 @ 04:09 AM

  6. cohitre
  7. rbxbx
    rbxbx

    was getting this failure:

      1) Failure:
    test_should_allow_except_option_for_list_of_authors(DatabaseConnectedJsonEncodingTest)

    [./test/cases/json_serialization_test.rb:179:in `test_should_allow_except_option_for_list_of_authors'
     ./test/cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__'
     ./test/cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `run']:
    
    
    
    
    <"[{&quot;id&quot;:1},{&quot;id&quot;:2}]"> expected but was <"[{&quot;id&quot;:1,&quot;field&quot;:null},{&quot;id&quot;:2,&quot;field&quot;:null}]">.
    attached patch corrects on master.

    September 27th, 2009 @ 05:04 AM

  8. rbxbx
    rbxbx
    • Tag changed from 3, activerecord, patch to 3, activerecord, bugmash, patch

    September 27th, 2009 @ 05:08 AM

  9. sr.iniv.t
    sr.iniv.t

    +1 on rbxbx's patch (applies cleanly on master and all tests pass). Joe's patch applies, but the test test_should_allow_except_option_for_list_of_authors fails for me.

    September 27th, 2009 @ 07:03 PM

  10. Rizwan Reza
    Rizwan Reza
    • Assigned user set to Pratik

    January 18th, 2010 @ 01:09 PM

  11. Rizwan Reza
    Rizwan Reza
    • Tag changed from 3, activerecord, bugmash, patch to 3, 3.0, activerecord, bugmash, patch

    I can confirm this error still exists.

    +1 verified.

    The patch by rbxbx applies cleanly.

    January 18th, 2010 @ 01:29 PM

  12. Rizwan Reza
    Rizwan Reza
    • Tag changed from 3, 3.0, activerecord, bugmash, patch to 3, 3.0, activerecord, patch

    February 12th, 2010 @ 12:46 PM

  13. Ryan Bigg
    Ryan Bigg
    • State changed from new to open
    • Tag changed from 3, 3.0, activerecord, patch to 3.0, activerecord, patch
    • Importance changed from to

    Does this error still exist guys?

    October 11th, 2010 @ 02:08 AM

  14. Santiago Pastorino
    Santiago Pastorino
    • Tag changed from 3.0, activerecord, patch to 30, activerecord, patch

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:30 PM

  15. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:30 PM