[2.0][DDC-524] Fixed issue with UPDATE/DELETE statements generating wrong SQL when using Association Paths.
This commit is contained in:
parent
9f15acdb25
commit
5ecca4f5e0
@ -478,8 +478,12 @@ class SqlWalker implements TreeWalker
|
|||||||
if (count($assoc->sourceToTargetKeyColumns) > 1) {
|
if (count($assoc->sourceToTargetKeyColumns) > 1) {
|
||||||
throw QueryException::associationPathCompositeKeyNotSupported();
|
throw QueryException::associationPathCompositeKeyNotSupported();
|
||||||
}
|
}
|
||||||
$sql .= $this->getSqlTableAlias($class->table['name'], $dqlAlias) . '.'
|
|
||||||
. reset($assoc->targetToSourceKeyColumns);
|
if ($this->_useSqlTableAliases) {
|
||||||
|
$sql .= $this->getSqlTableAlias($class->table['name'], $dqlAlias) . '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= reset($assoc->targetToSourceKeyColumns);
|
||||||
} else {
|
} else {
|
||||||
// 2- Inverse side: NOT (YET?) SUPPORTED
|
// 2- Inverse side: NOT (YET?) SUPPORTED
|
||||||
throw QueryException::associationPathInverseSideNotSupported();
|
throw QueryException::associationPathInverseSideNotSupported();
|
||||||
|
@ -159,4 +159,12 @@ class UpdateSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
|
|||||||
'UPDATE cms_users SET status = ? WHERE id BETWEEN ? AND ?'
|
'UPDATE cms_users SET status = ? WHERE id BETWEEN ? AND ?'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSingleValuedAssociationFieldInWhere()
|
||||||
|
{
|
||||||
|
$this->assertSqlGeneration(
|
||||||
|
"UPDATE Doctrine\Tests\Models\CMS\CmsPhonenumber p SET p.phonenumber = 1234 WHERE p.user = ?1",
|
||||||
|
"UPDATE cms_phonenumbers SET phonenumber = 1234 WHERE user_id = ?"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user