diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index cf6aee730475a..681d98f69f658 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -95,6 +95,11 @@ public function delete(Entity $entity): Entity { * @since 14.0.0 */ public function insert(Entity $entity): Entity { + if ($entity instanceof SnowflakeAwareEntity) { + /** @psalm-suppress DocblockTypeContradiction */ + $entity->generateId(); + } + // get updated fields to save, fields have to be set using a setter to // be saved $properties = $entity->getUpdatedFields(); @@ -115,11 +120,7 @@ public function insert(Entity $entity): Entity { $qb->setValue($column, $qb->createNamedParameter($value, $type)); } - if ($entity instanceof SnowflakeAwareEntity) { - /** @psalm-suppress DocblockTypeContradiction */ - $entity->generateId(); - $qb->executeStatement(); - } elseif ($entity->id === null) { + if ($entity->id === null) { $qb->executeStatement(); // When autoincrement is used id is always an int $entity->setId($qb->getLastInsertId());