rails/rails — pull request #8959 by vitorbaptista (2013-01-16 02:39:48+00:00)
Title: Don't rely on Hash key's ordering to configure default options

(I've talked with @rafaelfranca about it)

If we set encoding latin1 for a PostgreSQL database, it calls
PostgreSQLAdapter::create_database with options that have,
among other things:

{ 'encoding' => 'latin1' }

Then, we use reverse_merge(:encoding => "utf8") to setup the default
encoding. In the end, the hash looks like:

{ :encoding => 'utf8', 'encoding' => 'latin1' }

The call to options.symbolize_keys calls to_sym on each_key of this
Hash. It usually means that the encoding passed overwrites the default
utf8, but it's not guaranteed. So, we shouldn't rely on it.

The same was happening in ActiveRecord::ConnectionHandling.