Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pusewicz committed Jan 14, 2009
2 parents f6a6146 + 33a75e4 commit 815f7c0
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/rails_sequel.rb
@@ -1,4 +1,4 @@
gem 'sequel' # gem 'sequel'
require 'sequel' require 'sequel'


require File.expand_path(File.dirname(__FILE__) + '/rails_sequel/rails_sequel') require File.expand_path(File.dirname(__FILE__) + '/rails_sequel/rails_sequel')
Expand Down
37 changes: 28 additions & 9 deletions lib/rails_sequel/rails_sequel.rb
Expand Up @@ -5,7 +5,11 @@ module SequelConnection


# Connects to database using constructed Database Connection URI # Connects to database using constructed Database Connection URI
def self.connect 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 end


# Returns loaded database.yml configuration for current environment # Returns loaded database.yml configuration for current environment
Expand All @@ -14,14 +18,29 @@ def self.config
end end


# Constructs Database Connection URI # Constructs Database Connection URI
def self.uri def self.prepare_options
uri = config[:adapter] << "://" options = {}
uri << config[:username] if config[:username]
uri << ':' << config[:password] if config[:password] # Use SQLite by default
uri << '@' if config[:username] || config[:password] options[:adapter] = (config[:adapter] || "sqlite")
uri << ':' << config[:port] if config[:port] # Use localhost as default host
uri << (config[:host] || 'localhost') options[:host] = (config[:host] || "localhost")
uri << '/' << config[:database] # 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 end
end end
4 changes: 2 additions & 2 deletions lib/rails_sequel/version.rb
Expand Up @@ -2,8 +2,8 @@ module Rails
module SequelConnection module SequelConnection
module Version module Version
MAJOR = 0 MAJOR = 0
MINOR = 0 MINOR = 1
TINY = 2 TINY = 0


STRING = [MAJOR, MINOR, TINY].join('.') STRING = [MAJOR, MINOR, TINY].join('.')
end end
Expand Down
2 changes: 1 addition & 1 deletion rails_sequel.gemspec
Expand Up @@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/lib/rails_sequel/version')


Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = 'rails_sequel' s.name = 'rails_sequel'
s.version = "0.1.0" s.version = "0.1.2"
s.date = '2009-01-14' s.date = '2009-01-14'


s.summary = "Sequel plugin for Ruby on Rails" s.summary = "Sequel plugin for Ruby on Rails"
Expand Down
17 changes: 17 additions & 0 deletions tasks/sequel.rake
@@ -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

0 comments on commit 815f7c0

Please sign in to comment.