You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The rails commit [1] changes how values are returned from insert statements. The worthy goal is to use the RETURNING statement in postgres to set all the database generated attribute values as a direct result of the insert statement. Oracle supports the RETURNING statement too and may ultimately benefit from this change! As part of this change, the ActiveRecord::Persistence#_create_record now looks for a set of returning_columns instead of assuming that the primary key is being returned.
The challenge with this in the oracle adapter is the way this returning_columns list is built via
ActiveRecord::ConnectionAdapters::Column#auto_incremented_by_db? which defaults to a literal false. (or slightly higher up the callstack connection.return_value_after_insert?(c) where c is a Column)
The oracle enhanced adapter does not appear to have knowledge about if a column is a primary key or not on the Column record itself (at least not on that record, or within the sql_type_metadata). It is unclear to me how best to identify which columns are the primary key, and thus should be included in the returning_columns collection.
Overview
The rails commit [1] changes how values are returned from insert statements. The worthy goal is to use the RETURNING statement in postgres to set all the database generated attribute values as a direct result of the insert statement. Oracle supports the RETURNING statement too and may ultimately benefit from this change! As part of this change, the ActiveRecord::Persistence#_create_record now looks for a set of
returning_columns
instead of assuming that the primary key is being returned.The challenge with this in the oracle adapter is the way this
returning_columns
list is built viaActiveRecord::ConnectionAdapters::Column#auto_incremented_by_db? which defaults to a literal false. (or slightly higher up the callstack
connection.return_value_after_insert?(c)
where c is a Column)The oracle enhanced adapter does not appear to have knowledge about if a column is a primary key or not on the Column record itself (at least not on that record, or within the sql_type_metadata). It is unclear to me how best to identify which columns are the primary key, and thus should be included in the
returning_columns
collection.[1] rails/rails@3421e89
Steps to reproduce
You can see the barest implementation of the parameters for the rails change, and the problem in the tests here:
andynu@336d04b
Expected behavior
insert should return the id of the new record
Actual behavior
insert returns nil
System configuration
Rails version: not quite 7.1.0 - 3421e892afa532a254e54379ac2ce9bef138cf3f
Oracle enhanced adapter version: a little ways off master, 4707dfa
Ruby version: 3.2.2
Oracle Database version: 23.0.0
The text was updated successfully, but these errors were encountered: