diff options
author | Joas Schilling <coding@schilljs.com> | 2020-02-26 14:44:45 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-02-26 14:44:45 +0100 |
commit | 9c9f8fa5f7bb66ba1cb294705e11dc4f8ea315fc (patch) | |
tree | 73c2e0456d58f925de4542b427e0401f644ef565 /lib | |
parent | 0cf76aa2e8a66cd9b772be462fbb9b6633f32b32 (diff) | |
download | nextcloud-server-9c9f8fa5f7bb66ba1cb294705e11dc4f8ea315fc.tar.gz nextcloud-server-9c9f8fa5f7bb66ba1cb294705e11dc4f8ea315fc.zip |
Allow non integer ids in Entity Mapper
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Db/QBMapper.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index a6c8ac27acb..5fa367491b0 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -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(); |