This project is archived and is in readonly mode.
[PATCH] ActiveRecord::Base#reload didn't respect default_scope conditions
Reported by Tobi | September 8th, 2009 @ 03:24 PM
Just a quick bug fix for reloading a model which has a default_scope set but doesn't meet the condition:
It lead to a RecordNotFound exception, in case the model didn't met the default_scope condition (anymore) - this was obviously a bug. This quick fix makes use of with_exclusive_scope in the reload method to return the updated model in any case. See test for full example.
Cheers Tobi
Comments and changes to this ticket
-
Tobi September 9th, 2009 @ 10:58 AM
- Tag set to 2.3.4, activerecord, default_scope, patch, reload, with_exclusive_scope
-
Tobi September 11th, 2009 @ 10:17 AM
there was an issue with protected method. is fixed, see updated patch
-
CancelProfileIsBroken September 25th, 2009 @ 12:29 PM
- Tag changed from 2.3.4, activerecord, default_scope, patch, reload, with_exclusive_scope to 2.3.4, activerecord, bugmash, default_scope, patch, reload, with_exclusive_scope
-
John Guenin September 26th, 2009 @ 10:51 PM
+1 verified bug & patch.
Patch applies cleanly to master & 2-3-stable.
Good catch!
-
rbxbx September 26th, 2009 @ 11:00 PM
+1 patch applies cleanly to master and stable, tests passing.
:)
-
CancelProfileIsBroken September 27th, 2009 @ 12:00 PM
- Tag changed from 2.3.4, activerecord, bugmash, default_scope, patch, reload, with_exclusive_scope to 2.3.4, activerecord, bugmash-review, default_scope, patch, reload, with_exclusive_scope
-
José Valim February 19th, 2010 @ 05:03 PM
- Assigned user set to José Valim
-
Repository February 26th, 2010 @ 10:40 AM
(from [b06e5dce9786bf69ac5f114286fc9236dc9bfe5c]) fixed a 'RecordNotFound' bug when calling 'reload' on a object which doesn't met the default_scope conditions, added test [#3166 status:resolved]
The reload method didn't made use of 'with_exclusive_scope' when reloading the object. This lead to a RecordNotFound exception, in case the object doesn't met the default_scope condition (anymore) - which is obviously a bug. This quick fix makes use of with_exclusive_scope in the reload method as well. See test for full example.
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/b06e5dce9786bf69ac5f114286fc92... -
Repository February 26th, 2010 @ 11:15 AM
(from [4db72b702f7faca7da30a64e45daeee13733762a]) fixed a 'RecordNotFound' bug when calling 'reload' on a object which doesn't met the default_scope conditions, added test [#3166 status:resolved]
The reload method didn't made use of 'with_exclusive_scope' when reloading the object. This lead to a RecordNotFound exception, in case the object doesn't met the default_scope condition (anymore) - which is obviously a bug. This quick fix makes use of with_exclusive_scope in the reload method as well. See test for full example.
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/4db72b702f7faca7da30a64e45daee... -
Rizwan Reza May 15th, 2010 @ 06:37 PM
- Tag changed from 2.3.4, activerecord, bugmash-review, default_scope, patch, reload, with_exclusive_scope to 2.3.4, activerecord, default_scope, patch, reload, with_exclusive_scope
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>
People watching this ticket
Attachments
Referenced by
- 3166 [PATCH] ActiveRecord::Base#reload didn't respect default_scope conditions (from [b06e5dce9786bf69ac5f114286fc9236dc9bfe5c]) fixed a...
- 3166 [PATCH] ActiveRecord::Base#reload didn't respect default_scope conditions (from [4db72b702f7faca7da30a64e45daeee13733762a]) fixed a...