Created
August 30, 2010 20:21
-
-
Save metaskills/557991 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/active_record/connection_adapters/sqlserver/database_statements.rb b/lib/active_record/connection_adapters/sqlserver/database_statements.rb | |
index f7f2101..9bab632 100644 | |
--- a/lib/active_record/connection_adapters/sqlserver/database_statements.rb | |
+++ b/lib/active_record/connection_adapters/sqlserver/database_statements.rb | |
@@ -256,25 +256,16 @@ module ActiveRecord | |
def handle_to_names_and_values_odbc(handle, options={}) | |
case options[:fetch] | |
when :all, :one | |
- rows = if options[:fetch] == :all | |
- handle.fetch_all || [] | |
- else | |
- row = handle.fetch | |
- row ? [row] : [[]] | |
- end | |
- names = handle.columns(true).map{ |c| c.name } | |
- names_and_values = [] | |
- rows.each do |row| | |
- h = {} | |
- i = 0 | |
- while i < row.size | |
- v = row[i] | |
- h[names[i]] = v.respond_to?(:to_sqlserver_string) ? v.to_sqlserver_string : v | |
- i += 1 | |
+ if options[:fetch] == :all | |
+ names_and_values = [] | |
+ while row = handle.fetch_hash do | |
+ names_and_values << row | |
end | |
- names_and_values << h | |
+ names_and_values | |
+ else | |
+ row = handle.fetch_hash | |
+ row ? [row] : [[]] | |
end | |
- names_and_values | |
when :rows | |
rows = handle.fetch_all || [] | |
rows.each do |row| | |
diff --git a/test/profile/helper.rb b/test/profile/helper.rb | |
index 15fce30..c10a59c 100644 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread ID: 2148303280 | |
Total: 1.452341 | |
%self total self wait child calls name | |
52.20 0.81 0.76 0.00 0.05 5000 ODBC::Statement#fetch_hash (ruby_runtime:0} | |
6.58 0.10 0.10 0.00 0.00 1000 ODBC::Database#run (ruby_runtime:0} | |
3.59 0.05 0.05 0.00 0.00 56000 Hash#key? (ruby_runtime:0} | |
2.32 0.38 0.03 0.00 0.35 2000 Array#each (ruby_runtime:0} | |
2.01 0.06 0.03 0.00 0.03 1000 ActiveSupport::Notifications::Event#initialize (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/notifications/instrumenter.rb:39} | |
1.76 0.25 0.03 0.00 0.22 1000 ActiveRecord::LogSubscriber#sql (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/log_subscriber.rb:21} | |
1.65 0.84 0.02 0.00 0.82 1000 ActiveRecord::ConnectionAdapters::Sqlserver::DatabaseStatements#handle_to_names_and_values_odbc (./lib/active_record/connection_adapters/sqlserver/database_statements.rb:256} | |
1.28 1.38 0.02 0.00 1.36 1000 ActiveSupport::Notifications::Instrumenter#instrument (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/notifications/instrumenter.rb:17} | |
1.27 0.13 0.02 0.00 0.11 1000 Logger#add (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/logger.rb:312} | |
1.24 0.02 0.02 0.00 0.00 16000 String#=~ (ruby_runtime:0} | |
1.08 0.02 0.02 0.00 0.00 1500 ActiveSupport::LogSubscriber#color (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/log_subscriber.rb:115} | |
0.97 0.01 0.01 0.00 0.00 1000 IO#write (ruby_runtime:0} | |
0.96 0.08 0.01 0.00 0.07 1000 MonitorMixin#synchronize (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:239} | |
0.94 0.03 0.01 0.00 0.02 1000 MonitorMixin#mon_exit (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:223} | |
0.84 0.02 0.01 0.00 0.01 4000 ActiveRecord::LogSubscriber#logger (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/log_subscriber.rb:42} | |
0.81 0.11 0.01 0.00 0.10 1000 ActiveRecord::ConnectionAdapters::SQLServerAdapter#with_auto_reconnect (./lib/active_record/connection_adapters/sqlserver_adapter.rb:390} | |
0.79 0.33 0.01 0.00 0.32 1000 ActiveSupport::LogSubscriber#call (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/log_subscriber.rb:88} | |
0.67 0.03 0.01 0.00 0.02 1000 ActiveRecord::ConnectionAdapters::Sqlserver::DatabaseStatements#finish_statement_handle (./lib/active_record/connection_adapters/sqlserver/database_statements.rb:313} | |
0.65 0.01 0.01 0.00 0.00 1000 ODBC::Statement#drop (ruby_runtime:0} | |
0.64 0.02 0.01 0.00 0.02 1000 String#% (/Users/kencollins/.rvm/gems/ruby-1.8.7-p302@sqlserver/gems/i18n-0.4.1/lib/i18n/core_ext/string/interpolate.rb:79} | |
0.58 0.02 0.01 0.00 0.01 1000 MonitorMixin#mon_enter (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:212} | |
0.58 0.02 0.01 0.00 0.01 3000 <Class::Time>#now (ruby_runtime:0} | |
0.58 0.01 0.01 0.00 0.00 3000 ActiveRecord::ConnectionAdapters::SQLServerAdapter#connection_mode (./lib/active_record/connection_adapters/sqlserver_adapter.rb:415} | |
0.55 0.01 0.01 0.00 0.00 8000 Hash#[] (ruby_runtime:0} | |
0.52 1.44 0.01 0.00 1.44 1000 ActiveRecord::ConnectionAdapters::SQLServerAdapter#raw_select (./test/cases/sqlserver_helper.rb:85} | |
0.51 0.02 0.01 0.00 0.01 1000 Time#- (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:266} | |
0.48 0.01 0.01 0.00 0.00 1000 Logger::LogDevice#check_shift_log (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/logger.rb:539} | |
0.47 0.85 0.01 0.00 0.85 1000 ActiveRecord::ConnectionAdapters::Sqlserver::DatabaseStatements#handle_to_names_and_values (./lib/active_record/connection_adapters/sqlserver/database_statements.rb:247} | |
0.47 0.01 0.01 0.00 0.00 4000 <Class::ActiveRecord::Base>#logger (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb:36} | |
0.45 0.15 0.01 0.00 0.14 1000 ActiveSupport::LogSubscriber#debug (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/log_subscriber.rb:103} | |
0.45 1.45 0.01 0.00 1.45 3000 Kernel#send (ruby_runtime:0} | |
0.44 1.39 0.01 0.00 1.38 1000 ActiveRecord::ConnectionAdapters::AbstractAdapter#log (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:193} | |
0.41 0.01 0.01 0.00 0.00 1000 String#interpolate_without_ruby_19_syntax (ruby_runtime:0} | |
0.38 0.01 0.01 0.00 0.00 1000 Time#minus_without_coercion (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:253} | |
0.36 0.01 0.01 0.00 0.00 1000 String#split (ruby_runtime:0} | |
0.33 0.00 0.00 0.00 0.00 5000 Array#<< (ruby_runtime:0} | |
0.33 0.01 0.00 0.00 0.00 1000 Logger::SimpleFormatter#call (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/logger.rb:78} | |
0.31 0.01 0.00 0.00 0.00 1000 MonitorMixin#mon_check_owner (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:276} | |
0.31 0.01 0.00 0.00 0.00 1000 MonitorMixin#mon_release (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:292} | |
0.30 1.45 0.00 0.00 1.44 1000 ActiveRecord::ConnectionAdapters::Sqlserver::DatabaseStatements#select (./lib/active_record/connection_adapters/sqlserver/database_statements.rb:177} | |
0.30 0.01 0.00 0.00 0.00 1000 ActiveRecord::ConnectionAdapters::Sqlserver::CoreExt::ODBC::Statement#finished? (./lib/active_record/connection_adapters/sqlserver/core_ext/odbc.rb:18} | |
0.30 0.00 0.00 0.00 0.00 4500 Kernel#is_a? (ruby_runtime:0} | |
0.28 0.01 0.00 0.00 0.00 1000 <Class::ActiveRecord::LogSubscriber>#runtime (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/log_subscriber.rb:7} | |
0.27 0.01 0.00 0.00 0.01 1000 Logger#format_message (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/logger.rb:91} | |
0.27 0.35 0.00 0.00 0.35 1000 ActiveSupport::Notifications::Fanout#publish (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/notifications/fanout.rb:24} | |
0.26 0.01 0.00 0.00 0.00 1000 <Class::ActiveRecord::LogSubscriber>#runtime= (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/log_subscriber.rb:3} | |
0.26 0.34 0.00 0.00 0.33 1000 ActiveSupport::Notifications::Fanout::Subscriber#publish (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/notifications/fanout.rb:46} | |
0.26 0.00 0.00 0.00 0.00 3000 Kernel#respond_to? (ruby_runtime:0} | |
0.25 0.00 0.00 0.00 0.00 1000 MonitorMixin#mon_acquire (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:282} | |
0.25 0.00 0.00 0.00 0.00 3000 <Class::Time>#allocate (ruby_runtime:0} | |
0.25 0.00 0.00 0.00 0.00 4000 <Class::Thread>#current (ruby_runtime:0} | |
0.24 0.00 0.00 0.00 0.00 3000 Time#initialize (ruby_runtime:0} | |
0.24 0.00 0.00 0.00 0.00 4000 Symbol#=== (ruby_runtime:0} | |
0.24 0.00 0.00 0.00 0.00 4000 <Class::Thread>#critical= (ruby_runtime:0} | |
0.21 0.13 0.00 0.00 0.13 1000 Logger#debug (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/logger.rb:347} | |
0.21 1.39 0.00 0.00 1.39 1000 ActiveRecord::ConnectionAdapters::Sqlserver::DatabaseStatements#raw_select_without_query_record (./lib/active_record/connection_adapters/sqlserver/database_statements.rb:216} | |
0.21 0.00 0.00 0.00 0.00 1000 Logger#format_severity (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/logger.rb:426} | |
0.21 0.06 0.00 0.00 0.06 1000 Class#new (ruby_runtime:0} | |
0.20 0.12 0.00 0.00 0.11 1000 ActiveRecord::ConnectionAdapters::Sqlserver::DatabaseStatements#raw_connection_run (./lib/active_record/connection_adapters/sqlserver/database_statements.rb:227} | |
0.20 0.09 0.00 0.00 0.08 1000 Logger::LogDevice#write (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/logger.rb:495} | |
0.19 0.01 0.00 0.00 0.00 1000 Kernel#dup (ruby_runtime:0} | |
0.19 0.00 0.00 0.00 0.00 1000 Logger#debug? (/Users/kencollins/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/logger.rb:217} | |
0.19 0.00 0.00 0.00 0.00 1000 ActiveSupport::Notifications::Fanout#listeners_for (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/notifications/fanout.rb:28} | |
0.19 0.00 0.00 0.00 0.00 1000 String#gsub (ruby_runtime:0} | |
0.19 0.00 0.00 0.00 0.00 1000 <Class::ActiveSupport::Duration>#=== (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/duration.rb:53} | |
0.17 0.00 0.00 0.00 0.00 1500 ActiveSupport::LogSubscriber#colorize_logging (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb:17} | |
0.16 1.45 0.00 0.00 1.45 1 Integer#times (ruby_runtime:0} | |
0.16 0.00 0.00 0.00 0.00 1000 String#squeeze (ruby_runtime:0} | |
0.15 0.04 0.00 0.00 0.04 1000 Enumerable#any? (ruby_runtime:0} | |
0.15 0.00 0.00 0.00 0.00 1000 Hash#initialize_copy (ruby_runtime:0} | |
0.13 0.00 0.00 0.00 0.00 2000 Kernel#== (ruby_runtime:0} | |
0.13 0.00 0.00 0.00 0.00 1000 ActiveRecord::LogSubscriber#odd? (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/log_subscriber.rb:38} | |
0.13 0.00 0.00 0.00 0.00 1000 Logger#formatter (/Users/kencollins/Repositories/rails/activesupport/lib/active_support/core_ext/logger.rb:71} | |
0.13 0.00 0.00 0.00 0.00 1000 ActiveRecord::ConnectionAdapters::AbstractAdapter#raw_connection (/Users/kencollins/Repositories/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:157} | |
0.12 0.00 0.00 0.00 0.00 2000 Kernel#block_given? (ruby_runtime:0} | |
0.12 0.00 0.00 0.00 0.00 2000 Array#shift (ruby_runtime:0} | |
0.09 0.00 0.00 0.00 0.00 1000 Thread#[] (ruby_runtime:0} | |
0.08 0.00 0.00 0.00 0.00 1000 Thread#[]= (ruby_runtime:0} | |
0.08 0.00 0.00 0.00 0.00 1000 <Class::Hash>#allocate (ruby_runtime:0} | |
0.08 0.00 0.00 0.00 0.00 1000 Kernel#kind_of? (ruby_runtime:0} | |
0.07 0.00 0.00 0.00 0.00 1000 ODBC::Database#connected? (ruby_runtime:0} | |
0.07 0.00 0.00 0.00 0.00 1000 Time#minus_without_duration (ruby_runtime:0} | |
0.07 0.00 0.00 0.00 0.00 1000 <Class::Thread>#pass (ruby_runtime:0} | |
0.07 0.00 0.00 0.00 0.00 1000 Kernel#object_id (ruby_runtime:0} | |
0.07 0.00 0.00 0.00 0.00 1000 Kernel#class (ruby_runtime:0} | |
0.07 0.00 0.00 0.00 0.00 1000 Kernel#nil? (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Array#[] (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Fixnum#+ (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Array#first (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Fixnum#<= (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Float#* (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Float#+ (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 <Class::Object>#allocate (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Module#=== (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Fixnum#- (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Fixnum#< (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 NilClass#nil? (ruby_runtime:0} | |
0.06 0.00 0.00 0.00 0.00 1000 Fixnum#> (ruby_runtime:0} | |
0.05 0.00 0.00 0.00 0.00 1000 Fixnum#== (ruby_runtime:0} | |
0.04 0.00 0.00 0.00 0.00 500 NilClass#to_s (ruby_runtime:0} | |
0.00 1.45 0.00 0.00 1.45 1 ActiveRecord::TestCase#ruby_profile (./test/profile/helper.rb:17} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment