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>
This commit is contained in:
Daniel Kesselberg 2018-12-15 14:05:11 +01:00 committed by Roeland Jago Douma
parent 027f69df3f
commit 21b80a89b0
No known key found for this signature in database
GPG key ID: F941078878347C0C

View file

@ -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;
}