aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb22
-rwxr-xr-xactiverecord/test/abstract_unit.rb6
2 files changed, 14 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
index 341a388121..a19da5a545 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -504,22 +504,22 @@ module ActiveRecord
private
def select(sql, name = nil)
- rows = []
repair_special_columns(sql)
- log(sql, name) do
- @connection.select_all(sql) do |row|
- record = {}
- row.column_names.each do |col|
- record[col] = row[col]
- if record[col].is_a? DBI::Timestamp
- ts = record[col]
- record[col] = DateTime.new(ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.sec)
+
+ result = []
+ execute(sql) do |handle|
+ handle.each do |row|
+ row_hash = {}
+ row.each_with_index do |value, i|
+ if value.is_a? DBI::Timestamp
+ value = DateTime.new(value.year, value.month, value.day, value.hour, value.minute, value.sec)
end
+ row_hash[handle.column_names[i]] = value
end
- rows << record
+ result << row_hash
end
end
- rows
+ result
end
# Turns IDENTITY_INSERT ON for table during execution of the block
diff --git a/activerecord/test/abstract_unit.rb b/activerecord/test/abstract_unit.rb
index 4628293449..f30e190fc9 100755
--- a/activerecord/test/abstract_unit.rb
+++ b/activerecord/test/abstract_unit.rb
@@ -60,12 +60,12 @@ ActiveRecord::Base.connection.class.class_eval do
cattr_accessor :query_count
# Array of regexes of queries that are not counted against query_count
- @@ignore_list = [/^SELECT currval/, /^SELECT CAST/]
+ @@ignore_list = [/^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/]
alias_method :execute_without_query_counting, :execute
- def execute_with_query_counting(sql, name = nil)
+ def execute_with_query_counting(sql, name = nil, &block)
self.query_count += 1 unless @@ignore_list.any? { |r| sql =~ r }
- execute_without_query_counting(sql, name)
+ execute_without_query_counting(sql, name, &block)
end
end