Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake dm:drop fails when using Postgres #1264

Closed
kenkeiter opened this issue Apr 28, 2013 · 3 comments
Closed

rake dm:drop fails when using Postgres #1264

kenkeiter opened this issue Apr 28, 2013 · 3 comments
Milestone

Comments

@kenkeiter
Copy link

Seeing an error when I attempt to drop a database using the padrino-gen dm:drop rake task. Firing up the console and running

1.9.3-p392 :001 > DataMapper.repository.adapter.options.symbolize_keys
=> {:scheme=>"postgres", :user=>nil, :password=>nil, :host=>"localhost", :port=>nil, :path=>"/some_database", :query=>nil, :fragment=>nil, :adapter=>"postgres"} 

So basically it looks like the system call in datamapper.rb:91 is missing the user and database fields it's expecting.

Here's the full backtrace:

$ rake dm:drop
=> Dropping database 'kenkeiter:password@some_database'
rake aborted!
can't convert nil into String
/Users/kenkeiter/.rvm/gems/ruby-1.9.3-p392/gems/padrino-gen-0.11.1/lib/padrino-gen/padrino-tasks/datamapper.rb:91:in `system'
/Users/kenkeiter/.rvm/gems/ruby-1.9.3-p392/gems/padrino-gen-0.11.1/lib/padrino-gen/padrino-tasks/datamapper.rb:91:in `block (2 levels) in <top (required)>'
/Users/kenkeiter/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `eval'
/Users/kenkeiter/.rvm/gems/ruby-1.9.3-p392/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => dm:drop
(See full trace by running task with --trace)

Digging into the doc for DataMapper (http://rubydoc.info/github/datamapper/dm-core/master/DataMapper) it appears that there are two ways to specify connection details. The shorthand way:

DataMapper.setup(:default, 'postgres://root:supahsekret@127.0.0.1/dm_core_test')

and the longhand way:

DataMapper.setup(:default, {
  :adapter  => 'adapter_name_here',
  :database => 'path/to/repo',
  :username => 'username',
  :password => 'password',
  :host     => 'hostname'
})

I'm imagining the long-hand way was expected, since it seems to yield the keys that datamapper.rb:91's system call is expecting.

@Ortuna
Copy link
Member

Ortuna commented May 8, 2013

@kenkeiter ran into this with something like

DataMapper.setup(:default, "postgres://ortuna@127.0.0.1/dev_db")

It seems the arguments being passed where a bit fragile when passed to #system.
Hopefully our issues are the same issue.

@Ortuna
Copy link
Member

Ortuna commented May 27, 2013

@kenkeiter have you had a chance to verify this fix? Thanks!

@DAddYE
Copy link
Member

DAddYE commented Jul 1, 2013

Closing for now, @kenkeiter, please tell us if @Ortuna fix worked. Thanks @Ortuna

@DAddYE DAddYE closed this as completed Jul 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants