This project is archived and is in readonly mode.
Aggregation writer doesn't behave nicely when converter returns nil
Reported by Chris Hapgood | June 2nd, 2009 @ 09:43 PM | in 2.3.10
If the aggregation converter returns nil, the writer attempts to invoke the mapping method(s) anyway. Many such cases go undetected because nil responds adequately to common mapping methods such as :to_s, :to_i, etc.
(this behavior may even have been desirable before the :allow_nil option was introduced)
However, with mapping methods that are specific to the value class, returning nil from the converter results in NoMethod exceptions.
The attached patch ensures that normal nil mapping (all DB
columns set to nil) occurs if the converter returns nil.
The patch includes failing tests and currently applies to edge and 2-3-stable.
No documentation changes are required. However, this patch further refines support for nil values such that the purpose of the :allow_nil => false option is unclear. It seems almost like a misplaced validation at this point.
Comments and changes to this ticket
-
Chris Hapgood June 2nd, 2009 @ 09:50 PM
- no changes were found...
-
Michael Koziarski June 10th, 2009 @ 04:22 AM
- Milestone changed from 2.x to 2.3.4
-
Jeremy Kemper September 11th, 2009 @ 11:04 PM
- Milestone changed from 2.3.4 to 2.3.6
[milestone:id#50064 bulk edit command]
-
Rizwan Reza May 16th, 2010 @ 02:41 AM
- Tag changed from activerecord, aggregations, patch, testcase to activerecord, aggregations, bugmash, patch, testcase
-
Jeremy Kemper August 30th, 2010 @ 02:28 AM
- Milestone changed from 2.3.9 to 2.3.10
- Importance changed from to
-
Santiago Pastorino February 2nd, 2011 @ 04:33 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:33 PM
- State changed from open to stale
-
jfelchner May 17th, 2011 @ 02:28 AM
This is most definitely something that I would like to see fixed in 3.1. I am currently having the same problem where the converter should (correctly) return nil but the mapping methods are being called on it.
I understand resources are limited but 2 years seems like an excessively long amount of time to get a small change like this merged in.
If this particular patch is now out of date for the 3.x branch, let me know and I'll convert it over.
-
Chris Hapgood May 17th, 2011 @ 02:02 PM
jfelchner,
At a minimum, this ticket is going to need to be moved to the new system on GitHub. Care to take a stab? -
jfelchner May 18th, 2011 @ 03:10 PM
I'm on it. Forgot you guys switched over. I also took a look and the patch is no longer valid. I'll submit a new pull request with a link back to this page.
Thanks for the quick reply Chris.
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>