This project is archived and is in readonly mode.
save! silently fails
Reported by fearless_fool | August 18th, 2010 @ 05:28 PM
I'm undecided if this is a bug in ActiveRecord or a hole in the documentation, but I'm certain that it is one or the other. Consider:
irb(main):059:0> obs = Observation.get_observations() ; obs.size
=> 320
irb(main):060:0> obs[0].save!
=> true
irb(main):061:0> Observation.count
=> 0
Note that save! returns without writing anything to the observations table and without any error or warning. Before you conclude that this is an ActiveRecord bug, you should know that get_observations() is a wrapper for find_by_sql():
def Observation.get_observations()
Observation.find_by_sql(@massive_sql_query_string)
end
Though the AR documentation offers caveats for records generated by find_by_sql(), it makes no mention of this (mis)behavior.
Whether or not you believe this is an AR bug, "save! silently fails" is unexpected and can't be anticipated by reading the documentation alone. I'd suggest that either the code get changed, or the documentation be augmented to warn users about this unexpected consequence of using find_by_sql().
Environment:
bash$ rake about
(in /Users/ff/Developer/dev)
About your application's environment
Ruby version 1.9.2 (x86_64-darwin10.4.0)
RubyGems version 1.3.7
Rack version 1.2
Rails version 3.0.0.rc
Active Record version 3.0.0.rc
Action Pack version 3.0.0.rc
Active Resource version 3.0.0.rc
Action Mailer version 3.0.0.rc
Active Support version 3.0.0.rc
Application root /Users/ff/Developer/bd
Environment development
Comments and changes to this ticket
-
Santiago Pastorino February 2nd, 2011 @ 04:59 PM
- State changed from new to open
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.
-
Santiago Pastorino February 2nd, 2011 @ 04:59 PM
- State changed from open to stale
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>