Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7969

Show
Ignore:
Timestamp:
10/18/07 23:53:08 (1 year ago)
Author:
lawrence
Message:

SQL Server: test for affected row count. Closes #9558 [lawrence, ryepup]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • adapters/sqlserver/lib/active_record/connection_adapters/sqlserver_adapter.rb

    r7953 r7969  
    305305      end 
    306306 
    307       def update_sql(sql, name = nil) 
    308         execute(sql, name) do |handle| 
    309           handle.rows 
    310         end || select_value("SELECT @@ROWCOUNT AS AffectedRows") 
     307      def update_sql(sql, name = nil)           
     308        autoCommiting = @connection["AutoCommit"] 
     309        begin 
     310          begin_db_transaction if autoCommiting 
     311          execute(sql, name) 
     312          affectedRows = select_value("SELECT @@ROWCOUNT AS AffectedRows") 
     313          commit_db_transaction if autoCommiting 
     314          affectedRows 
     315        rescue 
     316          rollback_db_transaction if autoCommiting 
     317          raise 
     318        end                     
    311319      end 
    312320