1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Added support to subselects in update item.

This commit is contained in:
Guilherme Blanco 2012-11-27 14:36:56 -05:00
parent 46e6753649
commit f4c0fd1744
2 changed files with 9 additions and 1 deletions

View File

@ -1488,7 +1488,7 @@ class Parser
return new AST\InputParameter($this->lexer->token['value']);
}
return $this->SimpleArithmeticExpression();
return $this->ArithmeticExpression();
}
/**

View File

@ -202,4 +202,12 @@ class UpdateSqlGenerationTest extends \Doctrine\Tests\OrmTestCase
'UPDATE customtype_parents SET customInteger = 1 WHERE id = 1'
);
}
public function testUpdateWithSubselectAsNewValue()
{
$this->assertSqlGeneration(
"UPDATE Doctrine\Tests\Models\Company\CompanyFixContract fc SET fc.fixPrice = (SELECT ce2.salary FROM Doctrine\Tests\Models\Company\CompanyEmployee ce2 WHERE ce2.id = 2) WHERE fc.id = 1",
"UPDATE company_contracts SET fixPrice = (SELECT c0_.salary FROM company_employees c0_ INNER JOIN company_persons c1_ ON c0_.id = c1_.id LEFT JOIN company_managers c2_ ON c0_.id = c2_.id WHERE c1_.id = 2) WHERE (id = 1) AND discr IN ('fix')"
);
}
}