diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 35ac87c38..e85d9caec 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -291,7 +291,11 @@ class SqlWalker implements TreeWalker $tableName .= ($dqlAlias) ? '@[' . $dqlAlias . ']' : ''; if ( ! isset($this->tableAliasMap[$tableName])) { - $this->tableAliasMap[$tableName] = strtolower(substr($tableName, 0, 1)) . $this->tableAliasCounter++ . '_'; + $tablePrefixAlias = strtolower(substr($tableName, 0, 1)); + if( ! preg_match("/[a-z]/", $tablePrefixAlias)) { + $tablePrefixAlias = 't'; + } + $this->tableAliasMap[$tableName] = $tablePrefixAlias . $this->tableAliasCounter++ . '_'; } return $this->tableAliasMap[$tableName];