Skip to content

Instantly share code, notes, and snippets.

@doctrinebot
Created December 13, 2015 18:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save doctrinebot/b10c16f18d33a285a18d to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-481 - https://github.com/doctrine/doctrine2/issues/4985
--- ORM/Persisters/StandardEntityPersister.php (revision 7479)
+++ ORM/Persisters/StandardEntityPersister.php (working copy)
@@ -967,7 +967,14 @@
if (isset($this->_sqlTableAliases[$class->name])) {
return $this->_sqlTableAliases[$class->name];
}
- $tableAlias = $class->primaryTable['name'][0] . $this->_sqlAliasCounter++;
+
+ // Loop until we see the first eligible alias character
+ $i = 0;
+ do {
+ $aliasChar = $class->primaryTable['name'][$i++];
+ } while(!preg_match("/[a-z]/i", $aliasChar));
+
+ $tableAlias = $aliasChar . $this->_sqlAliasCounter++;
$this->_sqlTableAliases[$class->name] = $tableAlias;
return $tableAlias;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment