Permalink
Browse files

Fixed native database type memoization, now at connection instance le…

…vel. Fix #execute_procedure for :dblib mode to return indifferent access rows too.
  • Loading branch information...
1 parent 582bbbe commit f157664005d1ffb95997f655a559d8e5d2cd8a2f @metaskills metaskills committed Oct 31, 2010
View
@@ -1,6 +1,11 @@
* master *
+
+* 3.0.5 *
+
+* Fixed native database type memoization, now at connection instance level. Fix #execute_procedure for :dblib mode to return indifferent access rows too.
+
* Make login timeout and query timeout backward database.yml friendly for :dblib mode.
View
@@ -31,13 +31,6 @@ namespace :test do
end
end
-
- desc 'Test without unicode types enabled, uses ODBC mode.'
- task :non_unicode_types do
- ENV['ENABLE_DEFAULT_UNICODE_TYPES'] = 'false'
- test = Rake::Task['test:odbc']
- test.invoke
- end
end
@@ -80,7 +80,7 @@ def execute_procedure(proc_name, *variables)
r = row.with_indifferent_access
yield(r) if block_given?
end
- result.each
+ result.each.map{ |row| row.is_a?(Hash) ? row.with_indifferent_access : row }
when :odbc
results = []
raw_connection_run(sql) do |handle|
@@ -4,7 +4,7 @@ module Sqlserver
module SchemaStatements
def native_database_types
- ActiveRecord::ConnectionAdapters::SQLServerAdapter::NATIVE_DATABASE_TYPES
+ @native_database_types ||= initialize_native_database_types.freeze
end
def tables(name = nil)
@@ -148,8 +148,7 @@ def views(name = nil)
# === SQLServer Specific ======================================== #
def initialize_native_database_types
- return if defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter::NATIVE_DATABASE_TYPES)
- ActiveRecord::ConnectionAdapters::SQLServerAdapter.const_set(:NATIVE_DATABASE_TYPES,{
+ {
:primary_key => "int NOT NULL IDENTITY(1,1) PRIMARY KEY",
:string => { :name => native_string_database_type, :limit => 255 },
:text => { :name => native_text_database_type },
@@ -170,7 +169,7 @@ def initialize_native_database_types
:nvarchar_max => { :name => "nvarchar(max)" },
:ntext => { :name => "ntext" },
:ss_timestamp => { :name => 'timestamp' }
- })
+ }
end
def column_definitions(table_name)
@@ -180,7 +180,6 @@ def initialize(logger,config)
super(@connection, logger)
@database_version = info_schema_query { select_value('SELECT @@version') }
@database_year = DATABASE_VERSION_REGEXP.match(@database_version)[1].to_i rescue 0
- initialize_native_database_types
initialize_sqlserver_caches
use_database
unless SUPPORTED_VERSIONS.include?(@database_year)
@@ -1,4 +1,4 @@
-print "Using SQLServer via DBLIB\n"
+print "Using SQLServer via DBLIB to #{ENV['TINYTDS_UNIT_DATASERVER']}\n"
require_dependency 'models/course'
require 'logger'
@@ -1,4 +1,4 @@
-print "Using SQLServer via ODBC\n"
+print "Using SQLServer via ODBC to #{ENV['ACTIVERECORD_UNITTEST_DSN'] || 'activerecord_unittest'}\n"
require_dependency 'models/course'
require 'logger'

0 comments on commit f157664

Please sign in to comment.