Skip to content

Commit

Permalink
Merge pull request #601 from tractorcow-farm/revert-597-4.4-subselect…
Browse files Browse the repository at this point in the history
…-fix

Revert "Latest version issue fix"
  • Loading branch information
tractorcow authored Apr 9, 2020
2 parents dd4ae73 + 95a12d4 commit b5dcb38
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions src/Extension/FluentVersionedExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,25 +432,4 @@ public static function prepoulateIdsInLocale($locale, $dataObjectClass, $populat
self::$idsInLocaleCache[$locale][$table]['_complete'] = true;
}
}

public function augmentMaxVersionSubSelect(SQLSelect $subSelect, DataQuery $dataQuery, $shouldApplySubSelectAsCondition)
{
//gets "real" table name as it's required for getting localised
$table = $this->owner->baseTable();
//gets localised table name for given data record
$localisedTable = $this->owner->getLocalisedTable($table);
//generate localised && versioned table name
$versionedTable = $localisedTable . "_Versions";

//fetch alias from subselect
$newFrom = $subSelect->getFrom();
$alias = trim(key($newFrom), '"');
//add inner join to localised table
$subSelect->addInnerJoin($versionedTable, "\"{$alias}\".\"RecordID\" = \"{$versionedTable}\".\"RecordID\" AND \"{$alias}\".\"Version\" = \"{$versionedTable}\".\"Version\"");

//get current locale
$locale = FluentState::singleton()->getLocale();
//finally, update subselect to include requested locale
$subSelect->addWhere("\"{$versionedTable}\".\"Locale\" = '{$locale}'");
}
}

0 comments on commit b5dcb38

Please sign in to comment.