This project is archived and is in readonly mode.
Sqlite errors when using dbfile directive in database.yml
Reported by David Kelso | March 27th, 2009 @ 08:40 PM | in 2.3.4
Hi there!
So, after many hours of debugging why my script/dbconsole wouldn't run, I've discovered that I was using the dbfile directive in my database.yml. eg:
development:
adapter: sqlite3
dbfile: db/development.db
This makes script/dbconsole crash with the following message:
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/dbconsole.rb:80:in `exec': can't convert nil into String (TypeError)
from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/dbconsole.rb:80
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/dbconsole:3
Changing to use the 'database' directive fixes this problem. Is there any reason the 'dbfile' directive is still around? Is this really a bug in the sqlite-ruby gem?
First time bug reporting, so I'm sure I'm doing things wrong. Let me know where to start if I need to do tests/patches/whatnot.
david
Comments and changes to this ticket
-
Paul Hinze May 13th, 2009 @ 03:51 PM
- Assigned user set to Jeremy Kemper
- Tag changed from 2.3.2, database, database.yml, sqlite to 2-3-stable, 2.3.2, database, database.yml, dbfile, railties, sqlite, sqlite3
I just found a related issue with using
rake db:drop
given a SQLite database.The related block of code from
railties/lib/tasks/databases.rake
:def drop_database(config) case config['adapter'] # ... when /^sqlite/ FileUtils.rm(File.join(RAILS_ROOT, config['database'])) # ... end end
If this is called when only the dbfile config option is provided, you get an error as you'd expect:
Couldn't drop : #<TypeError: can't convert nil into String>
Looked in 2-3-stable and it seems like there are some places where both are supported and others (like the two mentioned here) where only the
database
key is used.The way forward it seems it to be one of these two options:
- officially deprecate
dbfile
and therefore include code to warn users of this fact - ensure support for
dbfile
everywhere thedatabase
config option is used
I've attached a patch against 2-3-stable that should fix the two issues mentioned in this ticket, but making the above decision is more important for this ticket.
Assigning to the last committer to the line in question for
databases.rake
just to have someone listed. -
Jeremy Kemper August 2nd, 2009 @ 02:24 AM
- State changed from new to resolved
- Milestone changed from 2.x to 2.3.4
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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>