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.
on 2008-06-07 14:52
on 2008-06-07 22:43
On Sat, Jun 7, 2008 at 5:51 AM, Ivan Evtuhovich <evtuhovich@gmail.com> wrote: > NOTICE: database "brun.trionet.ru_test" does not exist, skipping > end > - execute "DROP DATABASE IF EXISTS #{name}" > + execute "DROP DATABASE IF EXISTS \"#{name}\"" > end Thanks Ivan. Fixed in http://github.com/rails/rails/commit/21bb0f40 jeremy
on 2008-06-10 23:08
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.
on 2008-06-11 02:22
On Tue, Jun 10, 2008 at 2:08 PM, Sam Giffney <ruby-forum-incoming@andreas-s.net> wrote: > 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