-
Notifications
You must be signed in to change notification settings - Fork 233
Add _ prefix to reserved joined table name alias #904
Conversation
…lias uses in joins.
Reserved names are already prefixed by the method The logic should not be moved outside of this method. |
I just looked a little bit deeper in the problem and I think what you should do is:
$this->entityShortName = $this->getSafeName(strtolower($metadata->getReflectionClass()->getShortName())); $currentPart = $this->getSafeName(array_shift($parts)); This should fix your issue and this is better to keep he logic in one single method. |
…served-word-joins-fix # Conflicts: # Response/DatatableQueryBuilder.php
Response/DatatableQueryBuilder.php
Outdated
$data = $this->accessor->getValue($column, 'data'); | ||
|
||
$currentPart = $this->entityShortName; | ||
$currentPart = $this->getSafeName(array_shift($parts)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not here
Response/DatatableQueryBuilder.php
Outdated
*/ | ||
private function addJoin($columnTableName, $alias, $type) | ||
{ | ||
$alias = $this->getSafeName($alias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be needed
Response/DatatableQueryBuilder.php
Outdated
/** | ||
* @var KeywordList | ||
*/ | ||
private $reservedKeywordsList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, please keep it in the dedicated method as previously
Response/DatatableQueryBuilder.php
Outdated
namespace Sg\DatatablesBundle\Response; | ||
|
||
use Doctrine\DBAL\DBALException; | ||
use Doctrine\DBAL\Platforms\Keywords\KeywordList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this use is not required anymore
Response/DatatableQueryBuilder.php
Outdated
|
||
$currentPart = array_shift($parts); | ||
$currentAlias = ($previousPart === $this->entityShortName ? '' : $previousPart.'_').$currentPart; | ||
$currentAlias = ($previousPart === $this->entityShortName ? '' : $previousPart . '_') . $currentPart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use space between concat
Response/DatatableQueryBuilder.php
Outdated
private function getSafeName($name) | ||
{ | ||
$entityShortName = strtolower($metadata->getReflectionClass()->getShortName()); | ||
$reservedKeywordsList = $this->em->getConnection()->getDatabasePlatform()->getReservedKeywordsList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should keep this line in the try to catch eventual exceptions
Response/DatatableQueryBuilder.php
Outdated
|
||
$currentPart = array_shift($parts); | ||
$currentAlias = ($previousPart === $this->entityShortName ? '' : $previousPart.'_').$currentPart; | ||
$currentAlias = ($previousPart === $this->entityShortName ? '' : $previousPart.'_') . $currentPart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forget the last concat ) . $currentPart;
You completely destroyed the code style with your last commit |
Oops, fixed it now |
This version looks good. |
Great, I just double checked and it solves my issue. |
Further improvement of pull request 736, now also prefix table name alias uses in joins.