Skip to content

Commit 15b4597

Browse files
Merge pull request #57410 from nextcloud/bugfix/noid/fix-generate-id
fix(snowflake): Fix generateId() call for SnowflakeEntity
2 parents f42493b + fe393c5 commit 15b4597

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/public/AppFramework/Db/QBMapper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public function delete(Entity $entity): Entity {
9595
* @since 14.0.0
9696
*/
9797
public function insert(Entity $entity): Entity {
98+
if ($entity instanceof SnowflakeAwareEntity) {
99+
/** @psalm-suppress DocblockTypeContradiction */
100+
$entity->generateId();
101+
}
102+
98103
// get updated fields to save, fields have to be set using a setter to
99104
// be saved
100105
$properties = $entity->getUpdatedFields();
@@ -115,11 +120,7 @@ public function insert(Entity $entity): Entity {
115120
$qb->setValue($column, $qb->createNamedParameter($value, $type));
116121
}
117122

118-
if ($entity instanceof SnowflakeAwareEntity) {
119-
/** @psalm-suppress DocblockTypeContradiction */
120-
$entity->generateId();
121-
$qb->executeStatement();
122-
} elseif ($entity->id === null) {
123+
if ($entity->id === null) {
123124
$qb->executeStatement();
124125
// When autoincrement is used id is always an int
125126
$entity->setId($qb->getLastInsertId());

0 commit comments

Comments
 (0)