Skip to content

Commit 1358f4b

Browse files
committed
Ajusting update behaviour
1 parent e27d7b1 commit 1358f4b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Infrastructure/Model/Repository/Sql/SqlWriteRepository.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,22 @@ protected function updateQuery(Identity $value)
6666

6767
$this->populateQuery($query, $value, false);
6868

69-
$query
69+
$affectedRows = $query
7070
->update($this->mapping->name())
7171
->where($query->expr()->eq($this->mapping->identity(), ':id'))
7272
->setParameter(':id', $value->id())
7373
->execute();
74+
75+
if (0 === $affectedRows && false === $this->queryBuilder()->getConnection()->isTransactionActive()) {
76+
throw new PDOException(
77+
sprintf(
78+
'Could not update %s where %s = %s',
79+
$this->mapping->name(),
80+
$this->mapping->identity(),
81+
$value->id()
82+
)
83+
);
84+
}
7485
}
7586

7687
/**

0 commit comments

Comments
 (0)