Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow sequel command line tool to work with yaml config files with sy…

…mbol keys

This commit will try the following in order to find the parameters to
use:

  # Assume yaml_hash is the hash returned by YAML.load for the
  # file given on the command line, and env is the environment
  # specified by the user (or 'development' by default)
  params = yaml_hash[env] || yaml_hash[env.to_sym] || yaml_hash

Notice that in addition to supporting symbol keys (such as
:development), Sequel now also supports a plain yaml file for
parameters, such as:

  ---
  :adapter: sqlite
  :database: ':memory:'
  • Loading branch information...
commit 392963a028180cd21c5bfc9d5c0b40d668c0e30f 1 parent 5df9a37
@jeremyevans authored
Showing with 7 additions and 8 deletions.
  1. +2 −0  CHANGELOG
  2. +5 −8 bin/sequel
View
2  CHANGELOG
@@ -1,5 +1,7 @@
=== HEAD
+* Support symbol keys and unnested hashes in the sequel command line tool's yaml config support (jeremyevans)
+
* Add schema parsing support to the JDBC adapter (jeremyevans)
* Add per-database type translation support for schema changes, translating ruby classes to database specific types (jeremyevans)
View
13 bin/sequel
@@ -83,18 +83,15 @@ end
if File.exist?(db)
require 'yaml'
- db_config = YAML.load_file(db)[env || "development"]
- db_config.each {|(k,v)| db_config[k.to_sym] = db_config.delete(k)}
+ env ||= "development"
+ db_config = YAML.load_file(db)
+ db_config = db_config[env] || db_config[env.to_sym] || db_config
+ db_config.each{|(k,v)| db_config[k.to_sym] = db_config.delete(k)}
db_config.merge!(db_opts)
end
begin
- if db_config
- opts = [db_config]
- else
- opts = [db, db_opts]
- end
- DB = Sequel.connect(*opts)
+ DB = Sequel.connect(*(db_config ? [db_config] : [db, db_opts]))
DB.test_connection
if migrate_dir
Sequel::Migrator.apply(DB, migrate_dir, migrate_ver)
Please sign in to comment.
Something went wrong with that request. Please try again.