doctrine/doctrine2 — pull request #202 by warezthebeef (2011-11-22 23:22:50+00:00)
Title: Fixed array flip breaking discriminator map SQL generation

If you setup an entity discriminator map that maps multiple types to one class the SQL generation is broken. For example a mapping such as

@ORM\DiscriminatorMap({"developer" = "Employee", "salesperson" = "Employee", "manager" = "Employee", "ceo" = "FearlessLeader"})

The meta data is correctly loaded as

Array
(
[developer] => Employee
[salesperson] => Employee
[manager] => Employee
[ceo] => FearlessLeader
)

However within SingleTablePersister::_getSelectConditionSQL() as part of the generation of the appropriate IN clause a call is made to array_flip() to retrieve the array keys by class, leading to an array structure of

Array
(
[Employee] => manager
[FearlessLeader] => ceo
)

This ultimately leads to an incorrect IN clause such as

IN ('manager', 'manager', 'manager', 'ceo')

This patch simply replaces the array_flip() with a call to array_keys() and retrieves them by index, leading to the correct statement

IN ('developer', 'salesperson', 'manager', 'ceo')