Revision: 297
http://sourceforge.net/p/beeframework/code/297
Author: m_plomer
Date: 2015-03-04 11:41:59 +0000 (Wed, 04 Mar 2015)
Log Message:
-----------
Persistence:
- GenericDaoBase: fixed handling of already-prefixed fields / function expressions during field disaggregation / canonicalization
Modified Paths:
--------------
trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php
Modified: trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php
===================================================================
--- trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2015-03-04 11:14:17 UTC (rev 296)
+++ trunk/framework/Bee/Persistence/Doctrine2/GenericDaoBase.php 2015-03-04 11:41:59 UTC (rev 297)
@@ -196,18 +196,18 @@
*/
protected final function internalizeFieldExpression($fieldExpr, QueryBuilder $queryBuilder, $join = false) {
// ex: $fieldExpr = 'e.hochschultyp.kategorie.promotionsrecht'
- $dotPos = strrpos($fieldExpr, '.'); // 24
- $fieldName = substr($fieldExpr, $dotPos + 1); // 'promotionsrecht'
- $pathExpr = substr($fieldExpr, 0, $dotPos); // 'e.hochschultyp.kategorie'
+ preg_match('#^(?:([\w.]*)\.)?(.*?)$#', $fieldExpr, $matches);
+ $pathExpr = $matches[1]; // 'e.hochschultyp.kategorie'
+ $fieldName = $matches[2]; // 'promotionsrecht'
- if($pathExpr != $this->getEntityAlias()) {
+ if ($pathExpr && $pathExpr != $this->getEntityAlias()) {
Assert::isTrue(array_key_exists($pathExpr, $this->reverseAliases), 'Unknown path expression "' . $pathExpr . '"');
$this->internalizePathExpression($pathExpr, $queryBuilder, $join);
$pathExpr = $this->reverseAliases[$pathExpr];
}
// ex: return e4.promotionsrecht
- return $pathExpr . '.' . $fieldName;
+ return ($pathExpr ? $pathExpr . '.' : '') . $fieldName;
}
/**
@@ -221,10 +221,10 @@
// ex (Rc2): $pathExpr = 'e.hochschultyp'
// ex (Rc3): $pathExpr = 'e'
- if(($dotPos = strrpos($pathExpr, '.')) !== false) {
+ if (($dotPos = strrpos($pathExpr, '.')) !== false) {
$currentAlias = $this->reverseAliases[$pathExpr];
- if(!array_key_exists($currentAlias, $this->addedAliases)) {
+ if (!array_key_exists($currentAlias, $this->addedAliases)) {
$currentAssociation = substr($pathExpr, $dotPos + 1);
$pathExpr = substr($pathExpr, 0, $dotPos);
@@ -250,7 +250,7 @@
// ex (Rc1): $currentAssociation = 'e1.kategorie'
$queryBuilder->leftJoin($currentAssociation, $currentAlias);
- if($fetchJoin) {
+ if ($fetchJoin) {
$queryBuilder->addSelect($currentAlias);
}
$this->addedAliases[$currentAlias] = $currentAssociation;
@@ -448,7 +448,7 @@
*/
protected function getFieldDisaggregation($aggregateFieldName) {
// prefix only if simple path expression not prefixed with entity alias and not a function expression
- if(!preg_match('#^(?:' . $this->getEntityAlias() . '\.|\w+\()#', $aggregateFieldName)) {
+ if (!preg_match('#^(?:' . $this->getEntityAlias() . '\.|\w+\()#', $aggregateFieldName)) {
$aggregateFieldName = $this->getEntityAlias() . '.' . $aggregateFieldName;
}
if (array_key_exists($aggregateFieldName, $this->fieldDisaggregations)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|