Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/connection_adapters/sqlserver_adapter.rb
Class Method Summary collapse
Class Method Details
.sqlserver_connection(config) ⇒ Object
:nodoc:
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/active_record/connection_adapters/sqlserver_adapter.rb', line 19 def self.sqlserver_connection(config) #:nodoc: config = config.symbolize_keys config.reverse_merge! :mode => :dblib, :host => 'localhost', :username => 'sa', :password => '' mode = config[:mode].to_s.downcase.underscore.to_sym case mode when :dblib require_library_or_gem 'tiny_tds' warn("TinyTds v0.4.3 or higher required. Using #{TinyTds::VERSION}") unless TinyTds::Client.instance_methods.map(&:to_s).include?("active?") when :odbc raise ArgumentError, 'Missing :dsn configuration.' unless config.has_key?(:dsn) if RUBY_VERSION < '1.9' require_library_or_gem 'odbc' else begin # TODO: [ODBC] Change this to 'odbc_utf8' require_library_or_gem 'odbc' rescue LoadError require_library_or_gem 'odbc' end end unless ['::ODBC','::ODBC_UTF8','::ODBC_NONE'].any? { |odbc_ns| odbc_ns.constantize rescue nil } require 'active_record/connection_adapters/sqlserver/core_ext/odbc' when :adonet require 'System.Data' raise ArgumentError, 'Missing :database configuration.' unless config.has_key?(:database) else raise ArgumentError, "Unknown connection mode in #{config.inspect}." end ConnectionAdapters::SQLServerAdapter.new(logger,config.merge(:mode=>mode)) end |