Skip to content

Commit f157664

Browse files
committed
Fixed native database type memoization, now at connection instance level. Fix #execute_procedure for :dblib mode to return indifferent access rows too.
1 parent 582bbbe commit f157664

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

22
* master *
33

4+
5+
* 3.0.5 *
6+
7+
* Fixed native database type memoization, now at connection instance level. Fix #execute_procedure for :dblib mode to return indifferent access rows too.
8+
49
* Make login timeout and query timeout backward database.yml friendly for :dblib mode.
510

611

Rakefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ namespace :test do
3131
end
3232

3333
end
34-
35-
desc 'Test without unicode types enabled, uses ODBC mode.'
36-
task :non_unicode_types do
37-
ENV['ENABLE_DEFAULT_UNICODE_TYPES'] = 'false'
38-
test = Rake::Task['test:odbc']
39-
test.invoke
40-
end
4134

4235
end
4336

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def execute_procedure(proc_name, *variables)
8080
r = row.with_indifferent_access
8181
yield(r) if block_given?
8282
end
83-
result.each
83+
result.each.map{ |row| row.is_a?(Hash) ? row.with_indifferent_access : row }
8484
when :odbc
8585
results = []
8686
raw_connection_run(sql) do |handle|

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Sqlserver
44
module SchemaStatements
55

66
def native_database_types
7-
ActiveRecord::ConnectionAdapters::SQLServerAdapter::NATIVE_DATABASE_TYPES
7+
@native_database_types ||= initialize_native_database_types.freeze
88
end
99

1010
def tables(name = nil)
@@ -148,8 +148,7 @@ def views(name = nil)
148148
# === SQLServer Specific ======================================== #
149149

150150
def initialize_native_database_types
151-
return if defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter::NATIVE_DATABASE_TYPES)
152-
ActiveRecord::ConnectionAdapters::SQLServerAdapter.const_set(:NATIVE_DATABASE_TYPES,{
151+
{
153152
:primary_key => "int NOT NULL IDENTITY(1,1) PRIMARY KEY",
154153
:string => { :name => native_string_database_type, :limit => 255 },
155154
:text => { :name => native_text_database_type },
@@ -170,7 +169,7 @@ def initialize_native_database_types
170169
:nvarchar_max => { :name => "nvarchar(max)" },
171170
:ntext => { :name => "ntext" },
172171
:ss_timestamp => { :name => 'timestamp' }
173-
})
172+
}
174173
end
175174

176175
def column_definitions(table_name)

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ def initialize(logger,config)
180180
super(@connection, logger)
181181
@database_version = info_schema_query { select_value('SELECT @@version') }
182182
@database_year = DATABASE_VERSION_REGEXP.match(@database_version)[1].to_i rescue 0
183-
initialize_native_database_types
184183
initialize_sqlserver_caches
185184
use_database
186185
unless SUPPORTED_VERSIONS.include?(@database_year)

test/connections/native_sqlserver_dblib/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
print "Using SQLServer via DBLIB\n"
1+
print "Using SQLServer via DBLIB to #{ENV['TINYTDS_UNIT_DATASERVER']}\n"
22
require_dependency 'models/course'
33
require 'logger'
44

test/connections/native_sqlserver_odbc/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
print "Using SQLServer via ODBC\n"
1+
print "Using SQLServer via ODBC to #{ENV['ACTIVERECORD_UNITTEST_DSN'] || 'activerecord_unittest'}\n"
22
require_dependency 'models/course'
33
require 'logger'
44

0 commit comments

Comments
 (0)