This project is archived and is in readonly mode.

#2747 ✓stale
Chris Hapgood

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

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>

Attachments

Pages