-
Notifications
You must be signed in to change notification settings - Fork 326
Description
Steps to reproduce
So I have Oracle v12 which means I can use as identity
in column definition to get autogenerated id. I have the following table:
create table t_text_file
(
text_file_id number(12) generated always as identity
constraint t_text_file_pk
primary key,
name varchar2(20),
data clob
)
My model is:
module Database
class TextFile < ActiveRecord::Base
self.table_name = 't_text_file'
self.primary_key = 'text_file_id'
# self.sequence_name = :autogenerated
end
end
The code I execute is:
Database::TextFile.create(name: 'file.csv', data: "line1\nline2")
Expected behavior
Database insert without errors
Actual behavior
I get the following error:
OCIError: ORA-02289: sequence does not exist
What is going on in logs at the same time:
D, [2020-09-14T19:17:12.205496 #52369] DEBUG -- : next sequence value (113.6ms) SELECT "T_TEXT_FILE_SEQ".NEXTVAL FROM dual
It tries guess sequence name T_TEXT_FILE_SEQ
and use it.
If I uncomment self.sequence_name = :autogenerated
, the error is:
ArgumentError: Trigger based primary key is not supported
Obviously I am not trying to use trigger. I just want to disable using sequence and rely on a new mechanism of using Identity available from Oracle 12. I see the change comes from #1669, :autogenerated
can not be used anymore since 6.x. But how am I supped to use as identity
columns? self.sequence_name = :autogenerated
will not work too and will lead to null pointer error.
System configuration
I use ActiveRecord without Rails:
gem 'activerecord', '~> 6.0.3', :require => "active_record"
Oracle enhanced adapter version:
gem 'activerecord-oracle_enhanced-adapter', '~> 6.0.4'
Ruby version:
2.6.6
Oracle Database version:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0