Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Resolve conflict

  • Loading branch information...
commit 3e321dac3bb9dbfc06db520482376fd8d5594c28 1 parent f6a6146
Piotr Usewicz authored
2  lib/rails_sequel.rb
View
@@ -1,4 +1,4 @@
-gem 'sequel'
+# gem 'sequel'
require 'sequel'
require File.expand_path(File.dirname(__FILE__) + '/rails_sequel/rails_sequel')
37 lib/rails_sequel/rails_sequel.rb
View
@@ -5,7 +5,11 @@ module SequelConnection
# Connects to database using constructed Database Connection URI
def self.connect
- Sequel.connect uri, :loggers => [Rails.logger]
+ options = self.prepare_options
+ connection = Sequel.connect(options)
+ if options[:adapter] == 'mysql'
+ connection.execute("SET SQL_AUTO_IS_NULL=0")
+ end
end
# Returns loaded database.yml configuration for current environment
@@ -14,14 +18,29 @@ def self.config
end
# Constructs Database Connection URI
- def self.uri
- uri = config[:adapter] << "://"
- uri << config[:username] if config[:username]
- uri << ':' << config[:password] if config[:password]
- uri << '@' if config[:username] || config[:password]
- uri << ':' << config[:port] if config[:port]
- uri << (config[:host] || 'localhost')
- uri << '/' << config[:database]
+ def self.prepare_options
+ options = {}
+
+ # Use SQLite by default
+ options[:adapter] = (config[:adapter] || "sqlite")
+ # Use localhost as default host
+ options[:host] = (config[:host] || "localhost")
+ # Default user is an empty string. Both username and user keys are supported.
+ options[:user] = (config[:username] || config[:user] || "")
+
+ options[:password] = config[:password] || ""
+
+ # Both encoding and charset options are supported, default is utf8
+ options[:encoding] = (config[:encoding] || config[:charset] || "utf8")
+ # Default database is hey_dude_configure_your_database
+ options[:database] = config[:database] || "hey_dude_configure_your_database"
+ # MSSQL support
+ options[:db_type] = config[:db_type] if config[:db_type]
+ options[:socket] = config[:socket] if config[:socket]
+ options[:charset] = config[:charset] if config[:charset]
+ options[:encoding] = config[:encoding] if config[:encoding]
+ options[:loggers] = [Rails.logger]
+ options
end
end
end
4 lib/rails_sequel/version.rb
View
@@ -2,8 +2,8 @@ module Rails
module SequelConnection
module Version
MAJOR = 0
- MINOR = 0
- TINY = 2
+ MINOR = 1
+ TINY = 0
STRING = [MAJOR, MINOR, TINY].join('.')
end
2  rails_sequel.gemspec
View
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/lib/rails_sequel/version')
Gem::Specification.new do |s|
s.name = 'rails_sequel'
- s.version = "0.1.0"
+ s.version = "0.1.2"
s.date = '2009-01-14'
s.summary = "Sequel plugin for Ruby on Rails"
17 tasks/sequel.rake
View
@@ -0,0 +1,17 @@
+# Usage:
+#
+# rake sequel:migrate
+# rake sequel:migrate VERSION=0
+# rake sequel:migrate VERSION=3
+#
+desc 'Sequel migration'
+namespace :sequel do
+ task :migrate => :environment do
+ path = File.join(RAILS_ROOT, 'db', 'migrate')
+ if ENV['VERSION']
+ Sequel::Migrator.apply(Sequel::Model.db, path, ENV['VERSION'].to_i)
+ else
+ Sequel::Migrator.apply(Sequel::Model.db, path)
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.