Ivan Evtuhovich
2008-Jun-07 12:51 UTC
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:unitsNOTICE: 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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy Kemper
2008-Jun-07 20:42 UTC
Re: Problem with RoR 2.1 when run tests on postgres DB with difficlut name
On Sat, Jun 7, 2008 at 5:51 AM, Ivan Evtuhovich <evtuhovich@gmail.com> wrote:> > 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}\"" > endThanks Ivan. Fixed in http://github.com/rails/rails/commit/21bb0f40 jeremy --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Sam Giffney
2008-Jun-10 21:08 UTC
Re: Problem with RoR 2.1 when run tests on postgres DB with difficlut name
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy Kemper
2008-Jun-11 00:21 UTC
Re: Problem with RoR 2.1 when run tests on postgres DB with difficlut name
On Tue, Jun 10, 2008 at 2:08 PM, Sam Giffney <ruby-forum-incoming@andreas-s.net> wrote:> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---