Skip to content

Commit

Permalink
Merge pull request #281 from c0ntax/feature/280-hardcoded-rev-column
Browse files Browse the repository at this point in the history
#280 Removal of hardcoded revision field name
  • Loading branch information
DavidBadura committed May 9, 2017
2 parents 04528a5 + b48af42 commit a731857
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/SimpleThings/EntityAudit/AuditReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function find($className, $id, $revision, array $options = array())
$rootClass = $this->em->getClassMetadata($class->rootEntityName);
$rootTableName = $this->config->getTableName($rootClass);
$joinSql = "INNER JOIN {$rootTableName} re ON";
$joinSql .= " re.rev = e.rev";
$joinSql .= " re.".$this->config->getRevisionFieldName()." = e.".$this->config->getRevisionFieldName();
foreach ($class->getIdentifierColumnNames() as $name) {
$joinSql .= " AND re.$name = e.$name";
}
Expand All @@ -316,7 +316,7 @@ public function find($className, $id, $revision, array $options = array())
}
}

$query = "SELECT " . implode(', ', $columnList) . " FROM " . $tableName . " e " . $joinSql . " WHERE " . $whereSQL . " ORDER BY e.rev DESC";
$query = "SELECT " . implode(', ', $columnList) . " FROM " . $tableName . " e " . $joinSql . " WHERE " . $whereSQL . " ORDER BY e.".$this->config->getRevisionFieldName()." DESC";

$row = $this->em->getConnection()->fetchAssoc($query, $values);

Expand Down Expand Up @@ -615,7 +615,7 @@ public function findEntitiesChangedAtRevision($revision)
$rootTableName = $this->config->getTableName($rootClass);

$joinSql = "INNER JOIN {$rootTableName} re ON";
$joinSql .= " re.rev = e.rev";
$joinSql .= " re.".$this->config->getRevisionFieldName()." = e.".$this->config->getRevisionFieldName();
foreach ($class->getIdentifierColumnNames() as $name) {
$joinSql .= " AND re.$name = e.$name";
}
Expand Down Expand Up @@ -865,7 +865,7 @@ public function getEntityHistory($className, $id)

$values = array_values($id);

$query = "SELECT " . implode(', ', $columnList) . " FROM " . $tableName . " e WHERE " . $whereSQL . " ORDER BY e.rev DESC";
$query = "SELECT " . implode(', ', $columnList) . " FROM " . $tableName . " e WHERE " . $whereSQL . " ORDER BY e.".$this->config->getRevisionFieldName()." DESC";
$stmt = $this->em->getConnection()->executeQuery($query, $values);

$result = array();
Expand Down

0 comments on commit a731857

Please sign in to comment.