Created
April 18, 2018 12:17
-
-
Save yahonda/8ed018ef744b2e136484fa9e7f96cb9b to your computer and use it in GitHub Desktop.
Request to make `self.partial_writes` configurable per database adapter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Summary | |
Make `self.partial_writes` configurable per database adapter, not per model | |
or always write primary key attribute name per database adapter in the next major version of Rails 6. | |
* Background for this idea | |
Identity data type support for Oracle database 12.2 or higher. | |
It is a kind of standard auto_increment support for Oracle database. | |
Oracle database had not support auto increment type primary key, | |
then Oracle ehnanced adapter `prefetch_primary_key` returns `true` | |
then the adapter needs to select primary key value from the associated sequence. | |
Once supporting identity data type, `prefetch_primary_key` value can be `false`. | |
but there is a problem. Once we do not have to prefetch primary key, | |
Many sql statements will not specify any column names then `empty_insert_statement_value` method executed | |
it raises `NotImplementedError` finally. | |
Because unfortunately, Oracle database does not support `insert into default values` statement then | |
`empty_insert_statement_value` method raises `NotImplementedError`. | |
Still there is no plan that Oracle database support `INSERT .. DEFAULT VALUES`. | |
Ryuta Kamizono aka @kamipo suggested setting `self.partial_writes` can workaround this problem. | |
And actually it does. partial_writes belongs to each Active Record model. | |
I'd like that the next major version of Rails can make `self.partial_writes` default configuable | |
per database adapter or always write primary key attribute name per database adapter. | |
* Reference | |
[Identity Columns in Oracle Database 12c Release 1 (12.1)](https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1) | |
[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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is the repository for Oracle identity type script files https://github.com/yahonda/sample_app_for_oracle_identity