aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/association_relation.rb
diff options
context:
space:
mode:
authorYasuo Honda <yasuo.honda@gmail.com>2018-04-19 17:46:24 +0000
committerYasuo Honda <yasuo.honda@gmail.com>2018-04-20 12:56:55 +0000
commit947c38da04ae9c57f2f29e03b9894119d21a19f6 (patch)
tree902f6ada7b56eb07b616070c18d8145303843e06 /activerecord/lib/active_record/association_relation.rb
parentdaffe03308bffc43ea343a886aab33082d83bb9c (diff)
downloadrails-947c38da04ae9c57f2f29e03b9894119d21a19f6.tar.gz
rails-947c38da04ae9c57f2f29e03b9894119d21a19f6.tar.bz2
rails-947c38da04ae9c57f2f29e03b9894119d21a19f6.zip
Allow `primary_key` argument to `empty_insert_statement_value`
to support Oracle database support identity data type Oracle database does not support `INSERT .. DEFAULT VALUES` then every insert statement needs at least one column name specified. When `prefetch_primary_key?` returns `true` insert statement always have the primary key name since the primary key value is selected from the associated sequence. However, supporting identity data type will make `prefetch_primary_key?` returns `false` then no primary key column name added. As a result, `empty_insert_statement_value` raises `NotImplementedError` To address this error `empty_insert_statement_value` can take one argument `primary_key` to generate insert statement like this. `INSERT INTO "POSTS" ("ID") VALUES(DEFAULT)` It needs arity change for the public method but no actual behavior changes for the bundled adapters. Oracle enhanced adapter `empty_insert_statement_value` implementation will be like this: ``` def empty_insert_statement_value(primary_key) raise NotImplementedError unless primary_key "(#{quote_column_name(primary_key)}) VALUES(DEFAULT)" end ``` [Raise NotImplementedError when using empty_insert_statement_value with Oracle](https://github.com/rails/rails/pull/28029) [Add support for INSERT .. DEFAULT VALUES](https://community.oracle.com/ideas/13845)
Diffstat (limited to 'activerecord/lib/active_record/association_relation.rb')
0 files changed, 0 insertions, 0 deletions