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
# Using MySQL2 Gem | |
data = Topic.connection.send(:select,"SELECT `topics`.* FROM `topics`") | |
data # => [{"group"=>nil, "author_name"=>"David", "title"=>"The First Topic", "parent_title"=>nil, "approved"=>0, "id"=>1, "type"=>nil, "replies_count"=>1, "bonus_time"=>Sat Jan 01 09:28:00 UTC 2000, "parent_id"=>nil, "content"=>"Have a nice day", "last_read"=>Thu, 15 Apr 2004, "written_on"=>Wed Jul 16 10:28:11 UTC 2003, "author_email_address"=>"[email protected]"}, | |
{"group"=>nil, "author_name"=>"Mary", "title"=>"The Second Topic of the day", "parent_title"=>nil, "approved"=>1, "id"=>2, "type"=>"Reply", "replies_count"=>0, "bonus_time"=>nil, "parent_id"=>1, "content"=>"Have a nice day", "last_read"=>nil, "written_on"=>Thu Jul 15 10:28:00 UTC 2004, "author_email_address"=>nil}, | |
{"group"=>nil, "author_name"=>"Carl", "title"=>"The Third Topic of the day", "parent_title"=>nil, "approved"=>1, "id"=>3, "type"=>nil, "replies_count"=>1, "bonus_time"=>nil, "parent_id"=>nil, "content"=>"I'm a troll" |
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
require 'bench_press' | |
extend BenchPress | |
author 'Ken Collins' | |
summary 'Iterate over rows of array data.' | |
reps 10_000 | |
ROWS = [ | |
[1, 'Test', 'Body copy', Time.now], |
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
require 'bench_press' | |
extend BenchPress | |
author 'Ken Collins' | |
summary "Check and populate a options hash" | |
reps 100_000 | |
measure "Hash#key?" do | |
o = {} |
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
require 'bench_press' | |
extend BenchPress | |
author 'Ken Collins' | |
summary 'Object class inspection vs duck typing.' | |
reps 100_000 | |
module Foo | |
class Bar |
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
require 'bench_press' | |
require 'odbc' | |
extend BenchPress | |
author 'Ken Collins' | |
summary 'Best way to get column names from an ODBC statement handle.' | |
reps 1000 |
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
require 'bench_press' | |
require 'odbc' | |
extend BenchPress | |
author 'Ken Collins' | |
summary 'Best way to fetch results from an ODBC statement handle.' | |
reps 1000 |
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
module ActiveRecord | |
module ConnectionAdapters | |
module Sqlserver | |
module DatabaseStatements | |
def select_one(sql, name = nil) | |
result = raw_select sql, name, :fetch => :one | |
(result && result.first.present?) ? result.first : nil | |
end | |
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: 2148403500 | |
Total: 2.844094 | |
%self total self wait child calls name | |
26.76 1.34 0.76 0.00 0.58 2000 Array#each (ruby_runtime:0} | |
21.82 0.62 0.62 0.00 0.00 1000 ODBC::Statement#fetch_all (ruby_runtime:0} | |
7.28 0.22 0.21 0.00 0.02 1000 ODBC::Statement#columns (ruby_runtime:0} | |
4.24 0.12 0.12 0.00 0.00 113000 Array#[] (ruby_runtime:0} | |
4.09 0.12 0.12 0.00 0.00 1000 ODBC::Database#run (ruby_runtime:0} | |
2.71 0.08 0.08 0.00 0.00 58000 Kernel#respond_to? (ruby_runtime:0} |
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 || [] |
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
(kencollins@station) - (~) | |
∴ tsql -C | |
Compile-time settings (established with the "configure" script) | |
Version: freetds v0.82 | |
freetds.conf directory: /opt/local/etc/freetds | |
MS db-lib source compatibility: no | |
Sybase binary compatibility: no | |
Thread safety: yes | |
iconv library: yes | |
TDS version: 5.0 |