This commit is contained in:
Mojmir Fendek 2020-02-10 09:17:34 +13:00
parent 660f80d284
commit 448147c2f1

View File

@ -933,7 +933,7 @@ class DataQuery
$joinExpression = "{$foreignKeyIDColumn} = {$localIDColumn}"; $joinExpression = "{$foreignKeyIDColumn} = {$localIDColumn}";
} }
$this->query->addLeftJoin( $this->query->addLeftJoin(
$this->augmentTable($foreignClass, $foreignTable), $this->getJoinTableName($foreignClass, $foreignTable),
$joinExpression, $joinExpression,
$foreignTableAliased $foreignTableAliased
); );
@ -947,7 +947,7 @@ class DataQuery
if ($ancestorTable !== $foreignTable) { if ($ancestorTable !== $foreignTable) {
$ancestorTableAliased = $foreignPrefix . $ancestorTable; $ancestorTableAliased = $foreignPrefix . $ancestorTable;
$this->query->addLeftJoin( $this->query->addLeftJoin(
$this->augmentTable($ancestor, $ancestorTable), $this->getJoinTableName($ancestor, $ancestorTable),
"\"{$foreignTableAliased}\".\"ID\" = \"{$ancestorTableAliased}\".\"ID\"", "\"{$foreignTableAliased}\".\"ID\" = \"{$ancestorTableAliased}\".\"ID\"",
$ancestorTableAliased $ancestorTableAliased
); );
@ -993,7 +993,7 @@ class DataQuery
$foreignIDColumn = $schema->sqlColumnForField($foreignBaseClass, 'ID', $foreignPrefix); $foreignIDColumn = $schema->sqlColumnForField($foreignBaseClass, 'ID', $foreignPrefix);
$localColumn = $schema->sqlColumnForField($localClass, "{$localField}ID", $localPrefix); $localColumn = $schema->sqlColumnForField($localClass, "{$localField}ID", $localPrefix);
$this->query->addLeftJoin( $this->query->addLeftJoin(
$this->augmentTable($foreignClass, $foreignBaseTable), $this->getJoinTableName($foreignClass, $foreignBaseTable),
"{$foreignIDColumn} = {$localColumn}", "{$foreignIDColumn} = {$localColumn}",
$foreignPrefix . $foreignBaseTable $foreignPrefix . $foreignBaseTable
); );
@ -1008,7 +1008,7 @@ class DataQuery
if ($ancestorTable !== $foreignBaseTable) { if ($ancestorTable !== $foreignBaseTable) {
$ancestorTableAliased = $foreignPrefix . $ancestorTable; $ancestorTableAliased = $foreignPrefix . $ancestorTable;
$this->query->addLeftJoin( $this->query->addLeftJoin(
$this->augmentTable($ancestor, $ancestorTable), $this->getJoinTableName($ancestor, $ancestorTable),
"{$foreignIDColumn} = \"{$ancestorTableAliased}\".\"ID\"", "{$foreignIDColumn} = \"{$ancestorTableAliased}\".\"ID\"",
$ancestorTableAliased $ancestorTableAliased
); );
@ -1044,11 +1044,11 @@ class DataQuery
if (class_exists($relationClassOrTable)) { if (class_exists($relationClassOrTable)) {
// class is provided // class is provided
$relationTable = $schema->tableName($relationClassOrTable); $relationTable = $schema->tableName($relationClassOrTable);
$relationTableAugmented = $this->augmentTable($relationClassOrTable, $relationTable); $relationTableUpdated = $this->getJoinTableName($relationClassOrTable, $relationTable);
} else { } else {
// table is provided // table is provided
$relationTable = $relationClassOrTable; $relationTable = $relationClassOrTable;
$relationTableAugmented = $relationClassOrTable; $relationTableUpdated = $relationClassOrTable;
} }
// Check if already joined to component alias (skip join table for the check) // Check if already joined to component alias (skip join table for the check)
@ -1063,7 +1063,7 @@ class DataQuery
$relationAliasedTable = $componentPrefix . $relationTable; $relationAliasedTable = $componentPrefix . $relationTable;
$parentIDColumn = $schema->sqlColumnForField($parentClass, 'ID', $parentPrefix); $parentIDColumn = $schema->sqlColumnForField($parentClass, 'ID', $parentPrefix);
$this->query->addLeftJoin( $this->query->addLeftJoin(
$relationTableAugmented, $relationTableUpdated,
"\"{$relationAliasedTable}\".\"{$parentField}\" = {$parentIDColumn}", "\"{$relationAliasedTable}\".\"{$parentField}\" = {$parentIDColumn}",
$relationAliasedTable $relationAliasedTable
); );
@ -1071,7 +1071,7 @@ class DataQuery
// Join on base table of component class // Join on base table of component class
$componentIDColumn = $schema->sqlColumnForField($componentBaseClass, 'ID', $componentPrefix); $componentIDColumn = $schema->sqlColumnForField($componentBaseClass, 'ID', $componentPrefix);
$this->query->addLeftJoin( $this->query->addLeftJoin(
$this->augmentTable($componentBaseClass, $componentBaseTable), $this->getJoinTableName($componentBaseClass, $componentBaseTable),
"\"{$relationAliasedTable}\".\"{$componentField}\" = {$componentIDColumn}", "\"{$relationAliasedTable}\".\"{$componentField}\" = {$componentIDColumn}",
$componentAliasedTable $componentAliasedTable
); );
@ -1085,7 +1085,7 @@ class DataQuery
if ($ancestorTable !== $componentBaseTable) { if ($ancestorTable !== $componentBaseTable) {
$ancestorTableAliased = $componentPrefix . $ancestorTable; $ancestorTableAliased = $componentPrefix . $ancestorTable;
$this->query->addLeftJoin( $this->query->addLeftJoin(
$this->augmentTable($ancestor, $ancestorTable), $this->getJoinTableName($ancestor, $ancestorTable),
"{$componentIDColumn} = \"{$ancestorTableAliased}\".\"ID\"", "{$componentIDColumn} = \"{$ancestorTableAliased}\".\"ID\"",
$ancestorTableAliased $ancestorTableAliased
); );
@ -1101,12 +1101,12 @@ class DataQuery
* @param $table * @param $table
* @return mixed * @return mixed
*/ */
protected function augmentTable($class, $table) protected function getJoinTableName($class, $table)
{ {
$augmented = $table; $updated = $table;
$this->invokeWithExtensions('augmentJoinTable', $class, $table, $augmented); $this->invokeWithExtensions('updateJoinTableName', $class, $table, $updated);
return $augmented; return $updated;
} }
/** /**