|
I need this fix badly. How can I get a build of AR-JDBC 886?
David:
You can check out the ARJDBC trunk from http://jruby-extras.rubyforge.org/svn/trunk/activerecord-jdbc And run the rake on top of JRuby 1.1 RC1 to build. You can just copy the dir http://jruby-extras.rubyforge.org/svn/trunk/activerecord-jdbc/lib Thanks K V. I did the check out and copy earlier to patch my existing gem.
Marking bugs with invalid "fixed for release" as fixed in 1.1.
|
|||||||||||||||||||||||||||||||||||||||||||||||
In file jdbc_adapter.rb,the following method adds the bind variable where pk will be generated and assigned from a sequence:
alias :attributes_with_quotes_pre_oracle :attributes_with_quotes
def attributes_with_quotes(*args) #:nodoc:
aq = attributes_with_quotes_pre_oracle(*args)
if connection.class == ConnectionAdapters::JdbcAdapter && (connection.is_a?(JdbcSpec::Oracle) || connection.is_a?(JdbcSpec::Mimer))
aq[self.class.primary_key] = "?" if args.first && aq[self.class.primary_key].nil?
end
aq
end
The code will never add a bind variable when no arguments are supplied to the method "attributes_with_quotes". This is due the fact that in the method attributes_with_quotes, the first argument "include_primary_key" is true by default when no value is passed. Many methods in AR::Base, call this method without supplying arguments and going by default behavior.
The line " aq[self.class.primary_key] = "?" if args.first && aq[self.class.primary_key].nil?
" should be modified as follows to make this work:
aq[self.class.primary_key] = "?" if (args.size == 0 || args.first) && aq[self.class.primary_key].nil?
The above code assumes the first argument to be true by default.
Hope this helps.