Issue with Arel::SelectManager and insert Method

60 views
Skip to first unread message

Consu

unread,
May 11, 2011, 3:57:32 AM5/11/11
to Ruby on Rails: Core
Hello,


Arel::SelectManager (arel 2.0.9) uses following statement to insert a
new record:


@engine.connection.insert im.to_sql, 'AREL', primary_key_name,
primary_key_value


But in DatabaseStatements insert ist defined as:

insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)

Actually, Arel::SelectManager does not use the sequence name. This
leads to issues for instance with
activerecord-jdbc-adapter and Oracle, when you use sequence names
ignoring rails conventions.

Is it possible to fix this issue?

Regards
Dieter

Aaron Patterson

unread,
May 11, 2011, 2:16:15 PM5/11/11
to rubyonra...@googlegroups.com

Can you provide a test case to reproduce the problem? We run a CI
against Oracle, and all the tests are green. If you could give us a
test to show the problem, I could fix it.

--
Aaron Patterson
http://tenderlovemaking.com/

Consu

unread,
May 12, 2011, 3:28:28 AM5/12/11
to Ruby on Rails: Core
class MyModel < ActiveRecord::Base
set_table_name "some_table_name"
set_sequence_name "my_sequnce_name"
end

MyModel.new(:attr1 => 1, attr2 => 2).save!

leads to a exception. With:

jruby 1.6.1
gem 'rails', '3.0.7'
gem 'activerecord-jdbc-adapter', '1.1.1'


In this case prefetch_primary_key? returns false.
So the insert method in activerecord-jdbc-adapter-1.1.1/lib/arjdbc/
oracle/adapter.rb needs the sequence-name to determine the next id,
but arel doesn't use this
parameter. Without a sequence-name the default sequence-name
table_name_id is
used. This sequence doesn't exists.

Regards
Dieter
>  application_pgp-signature_part
> < 1 KBAnzeigenHerunterladen
Reply all
Reply to author
Forward
0 new messages