]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow non integer ids in Entity Mapper 19659/head
authorJoas Schilling <coding@schilljs.com>
Wed, 26 Feb 2020 13:44:45 +0000 (14:44 +0100)
committerJoas Schilling <coding@schilljs.com>
Wed, 26 Feb 2020 13:44:45 +0000 (14:44 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/public/AppFramework/Db/QBMapper.php

index a6c8ac27acb2231b13fd8224ddd7efed9c47b9c2..5fa367491b0cc9ee41d2b4d37761200d476a2431 100644 (file)
@@ -89,9 +89,11 @@ abstract class QBMapper {
        public function delete(Entity $entity): Entity {
                $qb = $this->db->getQueryBuilder();
 
+               $idType = $this->getParameterTypeForProperty($entity, 'id');
+
                $qb->delete($this->tableName)
                        ->where(
-                               $qb->expr()->eq('id', $qb->createNamedParameter($entity->getId()))
+                               $qb->expr()->eq('id', $qb->createNamedParameter($entity->getId(), $idType))
                        );
                $qb->execute();
                return $entity;
@@ -126,6 +128,7 @@ abstract class QBMapper {
                $qb->execute();
 
                if($entity->id === null) {
+                       // When autoincrement is used id is always an int
                        $entity->setId((int)$qb->getLastInsertId());
                }
 
@@ -191,8 +194,10 @@ abstract class QBMapper {
                        $qb->set($column, $qb->createNamedParameter($value, $type));
                }
 
+               $idType = $this->getParameterTypeForProperty($entity, 'id');
+
                $qb->where(
-                       $qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))
+                       $qb->expr()->eq('id', $qb->createNamedParameter($id, $idType))
                );
                $qb->execute();