This project is archived and is in readonly mode.

#3377 ✓stale
Denis

Hash#from_xml converted camelCase to underscore in 2.3.2, doesn't in 2.3.4

Reported by Denis | October 14th, 2009 @ 05:50 PM

The recent changes to Hash.from_xml seem to be a mess. As best I can tell from the related bugs, in 2.3.2 Hash#from_xml was broken for all-caps tags (#2604); it converted them to lowercase. In 2.3.2 Hash#from_xml's behavior with camelCase elements was to underscore them.

In attempting to fix the all-caps tags bug, commit eb201e which is in 2.3.4, at least, fixed Hash#from_xml for all-cap tags, but broke it for with camelCase tags, and no longer converted them to underscore (maybe #2334? that bug is sort of confusing). @dstrelau in that commit claims that they never should have been converted to underscore in the first place, although I've never found anything where that was documented.

Not sure whether this is actually a bug, or just needs documentation (and unit tests) as to what the behavior should (and should remain to) be. I'd be happpy to add unit tests once that's decided.

The other related commit is aa5cdb.

Comments and changes to this ticket

  • Denis

    Denis October 14th, 2009 @ 05:57 PM

    And of course the bug title should say Hash#from_xml, not Hash.from_xml.

  • Denis

    Denis October 14th, 2009 @ 05:58 PM

    • Title changed from “Hash.from_xml converted camelCase to underscore in 2.3.2, doesn't in 2.3.4” to “Hash#from_xml converted camelCase to underscore in 2.3.2, doesn't in 2.3.4”
  • Mike Grafton

    Mike Grafton December 6th, 2009 @ 06:11 PM

    I agree that it's a mess. I was depending on the de-camelization (i.e. underscoring) as I have a controller that accepts XML in the POST. It was nice (though surprising) that it was auto-magically translated into underscore-style element names, since it meant I could pretty much dump portions of the params Hash into my model as you would in a normal REST POST/PUT operation.

    While the behavior may have been wrong, reverting to the old behavior has broken those of us that depend on the new way - without even giving us a good workaround short of monkey-patching.

    I wonder if part of the problem here is that this code lives in ActiveSupport, where I suppose it doesn't make a lot of sense to be mucking with the element names as they get turned into a Hash. This seems more the responsibility of the ActionController::ParamsParser.

    Wherever it lives, some of us need this behavior back. I think it's best to leave the default behavior as it now stands, but to provide an option to do the underscorization.

  • Jeff Dean

    Jeff Dean January 12th, 2010 @ 02:42 AM

    I have an xml feed that comes in in all caps. It used to come in downcased, which I disliked, but wrote my code to accomodate. It now comes in correctly, which I like. What I don't like is being forced to make these changes because of a minor version bump. I'm about to settle into yet another night of converting hash keys, for the second time.

    The series of patches leading up to this are irresponsible.

    Were there deprecation warnings? No.
    Were there blog posts alerting us to these changes? No.
    Are there options in ActiveSupport where I can specify how I want tags handled? If so, I can't find them.

    Core fail.

  • Rohit Arondekar

    Rohit Arondekar October 7th, 2010 @ 05:47 AM

    • Importance changed from “” to “”

    Any updates here?

    I'm afraid your ticket was never opened or looked at by a core member.

  • Ryan Bigg

    Ryan Bigg October 9th, 2010 @ 09:47 PM

    • Tag cleared.

    Automatic cleanup of spam.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:30 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

    Santiago Pastorino February 2nd, 2011 @ 04:30 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>

Referenced by

Pages