doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.45k stars 1.33k forks source link

oracle 12.1 autoincrement feature #2695

Open brettmc opened 7 years ago

brettmc commented 7 years ago

Oracle 12.1 introduced the IDENTITY feature, which is some syntactic sugar around sequence/default, and could be used instead of the current 'create sequence' and 'create trigger' implementation:

CREATE TABLE identity_test_tab ( id NUMBER GENERATED ALWAYS AS IDENTITY, description VARCHAR2(30) );

(see https://oracle-base.com/articles/12c/identity-columns-in-oracle-12cr1)

I'd like to implement this feature, but just wanted to run the idea past the maintainers before I start coding anything. Using the postgresql platform as a guide, I'm imagining that I would:

In some quick playing with just hacking some changes into OraclePlatform, I was able to generate: CREATE TABLE test_table(id NUMBER(10) GENERATED ALWAYS AS IDENTITY NOT NULL, type VARCHAR2(32) NOT NULL); which can be created and works as expected in an Oracle 12.1 db.

Is there anything else I should consider, aside from unit tests? :)

Ocramius commented 7 years ago

create Oracle121Platform which extends OraclePlatform

Sounds like yet another platform to add - a bit messy for just one tiny feature that already works via existing sequences.

brettmc commented 7 years ago

couple of minor points:

also, there are other features in recent oracle versions that might be useful (although I wouldn't call any of them "killer" features):