Skip to content

Commit

Permalink
Merge pull request #22472 from nextcloud/fix/contacts-interaction-blo…
Browse files Browse the repository at this point in the history
…b-postgres

Fix writing BLOBs to postgres with recent contacts interaction
  • Loading branch information
blizzz committed Aug 31, 2020
2 parents 7c8a8dc + 3bc54bf commit 849c13f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/contactsinteraction/lib/Db/RecentContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function __construct() {
$this->addType('uid', 'string');
$this->addType('email', 'string');
$this->addType('federatedCloudId', 'string');
$this->addType('card', 'string');
$this->addType('card', 'blob');
$this->addType('lastContact', 'int');
}
}
7 changes: 6 additions & 1 deletion lib/public/AppFramework/Db/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,12 @@ protected function setter($name, $args) {

// if type definition exists, cast to correct type
if ($args[0] !== null && array_key_exists($name, $this->_fieldTypes)) {
settype($args[0], $this->_fieldTypes[$name]);
$type = $this->_fieldTypes[$name];
if ($type === 'blob') {
// (B)LOB is treated as string when we read from the DB
$type = 'string';
}
settype($args[0], $type);
}
$this->$name = $args[0];
} else {
Expand Down
2 changes: 2 additions & 0 deletions lib/public/AppFramework/Db/QBMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ protected function getParameterTypeForProperty(Entity $entity, string $property)
case 'bool':
case 'boolean':
return IQueryBuilder::PARAM_BOOL;
case 'blob':
return IQueryBuilder::PARAM_LOB;
}

return IQueryBuilder::PARAM_STR;
Expand Down

0 comments on commit 849c13f

Please sign in to comment.