Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DBAL-563] Add definition of sequence emulated identity platforms #428

Merged
merged 1 commit into from
Dec 22, 2013

Conversation

deeky666
Copy link
Member

Currently identity columns on Oracle are implemented with a trigger and sequence workaround to be compatible with IDENTITY generator strategy in ORM. However, using this strategy, the last insert ID is never returned when persisting, as the sequence name generated by DBAL is not passed to the ID-Generator instance in ORM and thus not passed to the driver when calling IdentityGenerator::generate(). Therefore the Oracle driver always returns null in this case. This makes this strategy unusable.
A similar case is given in PostgreSQL where SERIAL identity columns need a sequence in order to work. There is a hackish implementation available in ORM for this case which makes it work.
It is possible that other vendors (when implemented) encounter the same issue. For this reason I tried to create a general solution with this PR.
ORM needs to know which platforms do not have native support for identity columns but can emulate them with sequences. To prepare this I added platform methods that identify a platform being able to do so. Platforms supporting this have to return the name of the sequence used for an identity column in a table. ORM can later make use of this and pass it to the IdentityGenerator so that the underlying driver in return is able to supply the last insert ID.
Current supporting platforms are PostgreSQL and Oracle.

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DBAL-680

We use Jira to track the state of pull requests and the versions they got
included in.

* @since 2.5
* @link www.doctrine-project.org
*/
interface SequenceEmulatedIdentityPlatform
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inconsistent with the way other methods are implemented. You should add a new method in AbstractPlatform instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof I know that. I talked with @guilhermeblanco about this and he suggested to do it like this. In fact I think extracting an interface for vendor specific features/behaviours like this is not a bad idea instead of bloating the AbstractPlatform more and more. But if this is not desired I can change that back of course...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deeky666 For now we bloat the AbstractPlatform and use a not implemented exception. At somepoint in the future we can think about refactoring approaches. No need to start introducing two ways and make itinconsistent imho.

@deeky666
Copy link
Member Author

@beberlei Applied the desired changes.

@deeky666
Copy link
Member Author

@beberlei rebased. What's your opinion of this approach?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants