Problem with RoR 2.1 when run tests on postgres DB with difficlut name

Hello.

cat config/database.yml
development:
  adapter: postgresql
  database: brun.trionet.ru_development
  username: brun

rake test:units

NOTICE: database "brun.trionet.ru_test" does not exist, skipping
PGError: ERROR: syntax error near "."
LINE 1: CREATE DATABASE brun.trionet.ru_test ENCODING = 'utf8'

This is a patch, that fix this problem (adding " around database name)
--- /home/brun/postgresql_adapter.rb 2008-06-07 16:49:57.000000000
+0400
+++ lib/active_record/connection_adapters/postgresql_adapter.rb
2008-06-07 16:50:18.000000000 +0400
@@ -506,7 +506,7 @@
           end
         end

- execute "CREATE DATABASE #{name}#{option_string}"
+ execute "CREATE DATABASE \"#{name}\"#{option_string}"
       end

       # Drops a PostgreSQL database
@@ -514,7 +514,7 @@
       # Example:
       # drop_database 'matt_development'
       def drop_database(name) #:nodoc:
- execute "DROP DATABASE IF EXISTS #{name}"
+ execute "DROP DATABASE IF EXISTS \"#{name}\""
       end

PS Sorry for my english.

Thanks Ivan. Fixed in http://github.com/rails/rails/commit/21bb0f40

jeremy

The IF EXISTS grammar clause in
DROP DATABASE [IF EXISTS] "#{name}"
was introduced in Postgresql 8.2.

Using IF EXISTS in 8.1 or prior is an SQL error.
8.1 is still in major use, it is the primary Postgresql version on
Debian Etch for example.

The backwards compatible fix would seem to be to go back to the way it
was done in Rails 2.0.2 using the dropdb and createdb commandline
commands.

Could you post a ticket to http://rails.lighthouseapp.com please? We
can use IF EXISTS for 8.2 and later and fallback otherwise.

Thanks!
jeremy