This project is archived and is in readonly mode.

#941 incomplete

Postgres ActiveRecord adapter merges UTF8 encoding as symbol instead of string in create_database

Reported by science | August 30th, 2008 @ 07:28 AM | in 3.x

Synopsis: The postgressql-adapter create_datbase function does a reverse_merge on the database options - trying to set a default value of "utf8" - however the incoming keys are all strings and the adapter sets a symbol ':encoding' which results in utf8 being used in all cases.

This is causing problems for me after upgrading to v2.1 b/c when the test database is recreated it is created as 'utf8' format which is incorrect for my situation.

Analysis: Line 490 in file 'active-record-2.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb' is currently:

< options = options.reverse_merge(:encoding => "utf8")

It should be changed to be:

options = options.reverse_merge('encoding' => "utf8")

Or the keys should be locally symbolized before messing with them (they are currently symbolized just after this line!).

I'm sorry I'm not able to submit a patch - I don't use git yet (I just got to the point where I could submit patches in SVN and now git!) [smile]

I hope this bug report is sufficient - I think this is a very easy / low impact thing to fix. Contact me anytime with questions.

I think this bug will break any postgresql user who isn't using a utf8 database and who has tests which fail if utf8 is the format of the test database.

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=""></a>

Referenced by