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

Already on GitHub? Sign in to your account

IDENTITY() Support composite primary key #538

Merged
merged 3 commits into from Dec 24, 2012

Conversation

Projects
None yet
4 participants
Owner

FabioBatSilva commented Dec 16, 2012

This patch add support for composite primary key to identity function

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DDC-2202

@stof stof commented on an outdated diff Dec 17, 2012

...Doctrine/ORM/Query/AST/Functions/IdentityFunction.php
- $qComp = $sqlWalker->getQueryComponent($dqlAlias);
- $class = $qComp['metadata'];
- $assoc = $class->associationMappings[$assocField];
+ if ($this->fieldMapping !== null) {
+ if ( ! isset($targetEntity->fieldMappings[$this->fieldMapping])) {
+ throw new QueryException(sprintf('Undefined reference field mapping "%s"', $this->fieldMapping));
+ }
+
+ $field = $targetEntity->fieldMappings[$this->fieldMapping];
+ $joinColumn = null;
+
+ foreach ($assoc['joinColumns'] as $mapping) {
+ if($mapping['referencedColumnName'] === $field['columnName']) {
@stof

stof Dec 17, 2012

Member

missing space

@stof stof commented on an outdated diff Dec 17, 2012

...Doctrine/ORM/Query/AST/Functions/IdentityFunction.php
{
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->pathExpression = $parser->SingleValuedAssociationPathExpression();
+ if ($parser->getLexer()->lookahead['type'] == Lexer::T_COMMA) {
+ $parser->match(Lexer::T_COMMA);
+ $parser->match(Lexer::T_STRING);
+
+ $this->fieldMapping = $parser->getLexer()->token['value'];
@stof

stof Dec 17, 2012

Member

Shouldn't you use the parser here instead of accessing directly the lexer API ?

@beberlei beberlei added a commit that referenced this pull request Dec 24, 2012

@beberlei beberlei Merge pull request #538 from FabioBatSilva/identity-composite-key
IDENTITY() Support composite primary key
904effc

@beberlei beberlei merged commit 904effc into doctrine:master Dec 24, 2012

Owner

beberlei commented Dec 24, 2012

Awesome!

@FabioBatSilva FabioBatSilva deleted the FabioBatSilva:identity-composite-key branch Dec 24, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment