Skip to content

Commit

Permalink
Update execute_procedure method a bit to remove excess code.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaskills committed Jan 9, 2009
1 parent e798bab commit 66ecd2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 2000-2005-adapter.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = "2000-2005-adapter"
s.version = "2.2.7"
s.version = "2.2.8"
s.date = "2009-01-09"
s.summary = "SQL Server 2000 & 2005 Adapter For Rails."
s.email = "ken@metaskills.net"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ MASTER
*


* 2.2.8 (January 9th, 2009)

* Update execute_procedure method a bit to remove excess code. [Ken Collins]


* 2.2.7 (January 9th, 2009)

* Created a connection#execute_procedure method that takes can take any number of ruby objects as variables
Expand Down
9 changes: 4 additions & 5 deletions lib/active_record/connection_adapters/sqlserver_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def simplified_datetime
class SQLServerAdapter < AbstractAdapter

ADAPTER_NAME = 'SQLServer'.freeze
VERSION = '2.2.7'.freeze
VERSION = '2.2.8'.freeze
DATABASE_VERSION_REGEXP = /Microsoft SQL Server\s+(\d{4})/
SUPPORTED_VERSIONS = [2000,2005].freeze
LIMITABLE_TYPES = ['string','integer','float','char','nchar','varchar','nvarchar'].freeze
Expand Down Expand Up @@ -335,10 +335,9 @@ def execute(sql, name = nil, &block)
end

def execute_procedure(proc_name, *variables)
holders = (1..variables.size).to_a.map{|n|'?'}.join(', ')
statement = "EXEC #{proc_name} #{holders}".strip
sql = statement.gsub('?') { quote(variables.shift) }
select(sql,'PROCEDURE',true).inject([]) do |results,row|
vars = variables.map{ |v| quote(v) }.join(', ')
sql = "EXEC #{proc_name} #{vars}".strip
select(sql,'Execute Procedure',true).inject([]) do |results,row|
results << row.with_indifferent_access
end
end
Expand Down

0 comments on commit 66ecd2e

Please sign in to comment.