<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,49 +1,55 @@
+require 'yaml'
 require 'optparse'
+
 OptionParser.new do |opt|
   opt.banner = &quot;Usage: dbconsole [environment]&quot;
   opt.parse!(ARGV)
   abort opt.to_s unless (0..1).include?(ARGV.size)
 end
 
-env = ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development'
+env = ARGV.first || ENV['RAILS_ENV'] || 'development'
+unless config = YAML.load_file(RAILS_ROOT + &quot;/config/database.yml&quot;)[env]
+  abort &quot;No database is configured for the environment '#{env}'&quot;
+end
+
 
 def find_cmd(*commands)
-  dirs_on_path = ENV['PATH'].split(File::PATH_SEPARATOR)
+  dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR)
   commands += commands.map{|cmd| &quot;#{cmd}.exe&quot;} if RUBY_PLATFORM =~ /win32/
   commands.detect do |cmd|
     dirs_on_path.detect do |path|
       File.executable? File.join(path, cmd)
     end
-  end || abort(&quot;couldn't find matching executable: #{commands.join(', ')}&quot;)
+  end || abort(&quot;Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.&quot;)
 end
 
+case config[&quot;adapter&quot;]
+when &quot;mysql&quot;
+  args = {
+    'host'      =&gt; '--host',
+    'port'      =&gt; '--port',
+    'socket'    =&gt; '--socket',
+    'username'  =&gt; '--user',
+    'password'  =&gt; '--password',
+    'encoding'  =&gt; '--default-character-set'
+  }.map { |opt, arg| &quot;#{arg}=#{config[opt]}&quot; if config[opt] }.compact
 
-require 'yaml'
-config = YAML::load(File.read(RAILS_ROOT + &quot;/config/database.yml&quot;))[env]
+  args &lt;&lt; config['database']
 
-unless config
-  abort &quot;No database is configured for the environment '#{env}'&quot;
-end
+  exec(find_cmd('mysql5', 'mysql'), *args)
 
-case config[&quot;adapter&quot;]
-when &quot;mysql&quot;
-  exec(find_cmd(*%w(mysql5 mysql)),
-       *({ 'host'      =&gt; '--host',
-           'port'      =&gt; '--port',
-           'socket'    =&gt; '--socket',
-           'username'  =&gt; '--user',
-           'password'  =&gt; '--password',
-           'encoding'  =&gt; '--default-character-set'
-         }.map { |opt, arg| &quot;#{arg}=#{config[opt]}&quot; if config[opt] }.compact +
-         [config['database']]))
 when &quot;postgresql&quot;
   ENV['PGHOST']     = config[&quot;host&quot;] if config[&quot;host&quot;]
   ENV['PGPORT']     = config[&quot;port&quot;].to_s if config[&quot;port&quot;]
   ENV['PGPASSWORD'] = config[&quot;password&quot;].to_s if config[&quot;password&quot;]
   exec(find_cmd('psql'), '-U', config[&quot;username&quot;], config[&quot;database&quot;])
+
 when &quot;sqlite&quot;
   exec(find_cmd('sqlite'), config[&quot;database&quot;])
+
 when &quot;sqlite3&quot;
   exec(find_cmd('sqlite3'), config[&quot;database&quot;])
-else abort &quot;not supported for this database type&quot;
+
+else
+  abort &quot;Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!&quot;
 end</diff>
      <filename>railties/lib/commands/dbconsole.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b510d8bfd8355e63432514814e3177244a26275a</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Kemper</name>
    <email>jeremy@bitsweat.net</email>
  </author>
  <url>http://github.com/rails/rails/commit/2561732a08ae97fa44706a8eca4db147c4a7c286</url>
  <id>2561732a08ae97fa44706a8eca4db147c4a7c286</id>
  <committed-date>2008-05-07T13:54:02-07:00</committed-date>
  <authored-date>2008-05-07T13:50:46-07:00</authored-date>
  <message>Some dbconsole tweaks. [#102 state:resolved]</message>
  <tree>795a3c4e57c5d0cb3a01741e382dfb5c38432097</tree>
  <committer>
    <name>Jeremy Kemper</name>
    <email>jeremy@bitsweat.net</email>
  </committer>
</commit>
