Issue Details (XML | Word | Printable)

Key: ACTIVERECORD_JDBC-30
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Unassigned
Reporter: karthikvkrishnan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
activerecord-jdbc

JDBC Oracle - query cache not invalidated on INSERT

Created: 14/Aug/09 04:19 AM   Updated: 01/Oct/09 08:41 PM   Resolved: 01/Oct/09 08:41 PM
Component/s: Oracle
Affects Version/s: None
Fix Version/s: 0.9.2

Time Tracking:
Not Specified

Tags:


 Description  « Hide

In jdbc_oracle, to implement the Sequence as part of "insert", the insert method of Active Record is overridden.

But this effectively negates the query cache logic. The impact is as follows

a = SomeModel.find(:all)

  1. outputs no records

SomeModel.insert(...)

a = SomeModel.find(:all)

  1. outputs no records

In the above scenario, after an insert, query cache logic in AR base ensures that the cache is invalidated so that subsequent find is not read from cache

But, in Oracle's case, since the insert method itself is overridden, this logic is eaten.

I have fixed the same and have tested in my project. I am attaching the code snippet below. It would be good to have this fix made available in your code base.

Step 1: put the following code snippet in jdbc_oracle.rb

def self.extended(object)
object.class_eval do
alias_chained_method :insert, :query_dirty, :jdbc_insert
end
end

Step 2: Rename the "insert" method to "jdbc_insert"



Nick Sieger added a comment - 01/Oct/09 08:41 PM

Thanks, applied in 62c96d7.