Skip to content

Commit

Permalink
Fix generation of sequence based identifiers (CO-2623)
Browse files Browse the repository at this point in the history
  • Loading branch information
benno authored Mar 30, 2023
1 parent 0727b54 commit 7b2ec6b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/src/Lib/Identifier/Sequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ class Sequence extends ReferenceIdService {

public function generate(\App\Model\Entity\Matchgrid $mgConfig, DBALConnection $dbc) {
// The prefix is optional and configured by the admin
$prefix = $mgConfig->matchgrid_setting->getReferenceIdPrefix($mgConfig->id);
$MatchgridSettings = TableRegistry::getTableLocator()->get('MatchgridSettings');

$prefix = $MatchgridSettings->getReferenceIdPrefix($mgConfig->id);
$seqName = $mgConfig->matchgrid_setting->ref_id_sequence_name;

$sql = "SELECT nextval(' . $mgConfig->matchgrid_setting->ref_id_sequence_name . ')";
$sql = "SELECT nextval('$seqName')";

$stmt = $dbc->Prepare($sql);

$resultSet = $stmt->executeQuery();

return $prefix . $resultSet->fetchOne();
}
}
}

0 comments on commit 7b2ec6b

Please sign in to comment.