I'd label this purely as undefined behavior and such cases shouldn't occur
in the first place.

On Thu, Mar 24, 2016 at 6:59 PM, Andrew Selder <[email protected]>
wrote:

> Hi all,
>
> After we got bit by it a couple times recently, I was thinking of
> submitting a PR for ActiveRecord that would issue a warning if you submit a
> hash containing the same key as both a symbol and a string to any of the AR
> construction methods (create, new, update_attributes, etc…) . As far as I
> can tell, the behavior when this happens in undefined (and change between
> Rails 3 and 4 for example).
>
> For example:
>
> attr = { ‘a’ => 123, :a => 456 }
> ARModel.create!(attr)
>
> In Rails 3, you’ll get an object with the ‘a’ attributes set to 456, in
> Rails 4, you’ll get 123.
>
> I think this kind of things is almost always unintentional and worth a
> warning.
>
> I’ll be happy to code this up and submit it if people think it would be
> useful and accepted.
>
> Please let me know your thoughts and feedback.
>
> Thanks,
>
> Andrew
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to