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.

Aggregation writer doesn't behave nicely when converter returns nil

#2747

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.

Reported by Chris Hapgood · June 2nd, 2009 @ 09:43 PM

State: stale
Milestone: 2.3.10
Assigned to: nobody
Importance: none

Activity

  1. Chris Hapgood
  2. Michael Koziarski
    Michael Koziarski
    • Milestone changed from 2.x to 2.3.4

    June 10th, 2009 @ 04:22 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.4 to 2.3.6

    [milestone:id#50064 bulk edit command]

    September 11th, 2009 @ 11:04 PM

  4. Rizwan Reza
    Rizwan Reza
    • Tag changed from activerecord, aggregations, patch, testcase to activerecord, aggregations, bugmash, patch, testcase

    May 16th, 2010 @ 02:41 AM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.6 to 2.3.7

    May 23rd, 2010 @ 05:54 PM

  6. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.7 to 2.3.8

    May 24th, 2010 @ 09:40 AM

  7. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.8 to 2.3.9

    May 25th, 2010 @ 11:45 PM

  8. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.9 to 2.3.10
    • Importance changed from to

    August 30th, 2010 @ 02:28 AM

  9. Santiago Pastorino
    Santiago Pastorino
    • 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.

    February 2nd, 2011 @ 04:33 PM

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

    February 2nd, 2011 @ 04:33 PM

  11. jfelchner
    jfelchner

    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.

    May 17th, 2011 @ 02:28 AM

  12. Chris Hapgood
    Chris Hapgood

    jfelchner,
    At a minimum, this ticket is going to need to be moved to the new system on GitHub. Care to take a stab?

    May 17th, 2011 @ 02:02 PM

  13. jfelchner
    jfelchner

    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.

    May 18th, 2011 @ 03:10 PM