summaryrefslogtreecommitdiffstats
path: root/lib/public/AppFramework/Db
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2018-12-15 14:05:11 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2018-12-24 14:21:39 +0100
commit21b80a89b0d34318c257cc93eba9333228f1854e (patch)
tree6498ba4ecc940040857a32c2558df28263c60ea3 /lib/public/AppFramework/Db
parent027f69df3f669df1d30f0dc32f7c29b9f4603ed8 (diff)
downloadnextcloud-server-21b80a89b0d34318c257cc93eba9333228f1854e.tar.gz
nextcloud-server-21b80a89b0d34318c257cc93eba9333228f1854e.zip
Fetch lastInsertId only when id null
When id column has no autoincrement flag query for lastInsertId fails on postgres because no value has been generated. Call lastInsertId only if id is null. Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'lib/public/AppFramework/Db')
-rw-r--r--lib/public/AppFramework/Db/QBMapper.php4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php
index dbc47d2d43d..3e0a3c206e7 100644
--- a/lib/public/AppFramework/Db/QBMapper.php
+++ b/lib/public/AppFramework/Db/QBMapper.php
@@ -119,7 +119,9 @@ abstract class QBMapper {
$qb->execute();
- $entity->setId((int) $qb->getLastInsertId());
+ if($entity->getId() === null) {
+ $entity->setId((int)$qb->getLastInsertId());
+ }
return $entity;
}