Skip to content

Commit

Permalink
Fixed native database type memoization, now at connection instance le…
Browse files Browse the repository at this point in the history
…vel. Fix #execute_procedure for :dblib mode to return indifferent access rows too.
  • Loading branch information
metaskills committed Oct 31, 2010
1 parent 582bbbe commit f157664
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
@@ -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.


Expand Down
7 changes: 0 additions & 7 deletions Rakefile
Expand Up @@ -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

Expand Down
Expand Up @@ -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|
Expand Down
Expand Up @@ -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)
Expand Down Expand Up @@ -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 },
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion lib/active_record/connection_adapters/sqlserver_adapter.rb
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/connections/native_sqlserver_dblib/connection.rb
@@ -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'

Expand Down
2 changes: 1 addition & 1 deletion test/connections/native_sqlserver_odbc/connection.rb
@@ -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'

Expand Down

0 comments on commit f157664

Please sign in to comment.