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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Aaron Patterson
2011-May-11 18:16 UTC
Re: Issue with Arel::SelectManager and insert Method
On Wed, May 11, 2011 at 12:57:32AM -0700, Consu wrote:> 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?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/
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 On 11 Mai, 20:16, Aaron Patterson <aa...@tenderlovemaking.com> wrote:> On Wed, May 11, 2011 at 12:57:32AM -0700, Consu wrote: > > 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? > > 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 Pattersonhttp://tenderlovemaking.com/ > > application_pgp-signature_part > < 1 KBAnzeigenHerunterladen-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Maybe Matching Threads
- [Arel]Building query, but can't get a proper output
- Rails 3.1 : Complex database query with Arel 2
- A "strict Arel" mode for ActiveRecord to prevent SQL injection vulnerabilities
- Can Arel handle UPPER and LIKE condition?
- [threadsafe] Arel ToSql visitor is not threadsafe