rsim/oracle-enhanced — Issue #134: Logging 'sql.active_record' events fail for statements with :returning_id columns
Author: techsplicer
Created: 2011-12-05 19:03:11+00:00
State: open

I have encountered an issue when using the 1.4.0 tagged adapter.

Specifically, we have tables that use triggers/sequences to generate ids for inserted records. When looking through the logging output of rails, i discoverd that our INSERT statements were not being logged. Below is the message in my logs..

2011-12-05 10:11:06 default: ERROR [pid: 713] log_subscriber.rb:92:in `call' - Could not log "sql.active_record" event. NoMethodError: undefined method `name' for :returning_id:Symbol

I have narrowed this down to how the methods 'sql_for_insert' and 'exec_insert' add a :returning_id column to the binds array. When ActiveRecord:: LogSubscriber attempts to log the sql, the following is executed and it fails for our :returning_id column as the symbol has no #name signature while the other column for the record do. I would propose a fix, but i am still digging through the oracle adapter code and am not quite sure how to define a column type for the returning_id.

unless (payload[:binds] || []).empty?
binds = " " + payload[:binds].map { |col,v|
[col.name, v]
}.inspect
end