Skip to content

Commit

Permalink
Prevents incorrect table aliases
Browse files Browse the repository at this point in the history
When one uses a discriminator map with a valid, but incorrectly cased,
class name (Foo\\Bar\\baz instead of Foo\\Bar\\baz) for instance, the
class metadata won't complain (php being case insensitive when it comes
to class name). However, it will complain if the class does not exist.

This will lead to "exotic" table alias being generated when querying the
parent class because the sqlTableAliases won't contain the wrongly typed
classname.

Example:

SELECT t0.id as id_0, ..., t1.name as name_10, t11.thing as thing_11...
  • Loading branch information
gquemener committed Apr 17, 2020
1 parent 8c259ea commit 698f125
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -1605,13 +1605,13 @@ protected function getSQLTableAlias($tableName, $assocName = '')
$tableName .= '#' . $assocName;
}

if (isset($this->currentPersisterContext->sqlTableAliases[$tableName])) {
return $this->currentPersisterContext->sqlTableAliases[$tableName];
if (isset($this->currentPersisterContext->sqlTableAliases[strtolower($tableName)])) {
return $this->currentPersisterContext->sqlTableAliases[strtolower($tableName)];
}

$tableAlias = 't' . $this->currentPersisterContext->sqlAliasCounter++;

$this->currentPersisterContext->sqlTableAliases[$tableName] = $tableAlias;
$this->currentPersisterContext->sqlTableAliases[strtolower($tableName)] = $tableAlias;

return $tableAlias;
}
Expand Down

0 comments on commit 698f125

Please sign in to comment.