Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/Database/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Utopia\Database\Exception\Restricted as RestrictedException;
use Utopia\Database\Exception\Structure as StructureException;
use Utopia\Database\Exception\Timeout as TimeoutException;
use Utopia\Database\Exception\Type as TypeException;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
Expand Down Expand Up @@ -4975,7 +4976,7 @@ public function createOrUpdateDocumentsWithIncrease(
->setAttribute('$id', empty($document->getId()) ? ID::unique() : $document->getId())
->setAttribute('$collection', $collection->getId())
->setAttribute('$updatedAt', empty($updatedAt) || !$this->preserveDates ? $time : $updatedAt)
->removeAttribute('$internalId');
->removeAttribute('$sequence');

if ($old->isEmpty()) {
$createdAt = $document->getCreatedAt();
Expand Down Expand Up @@ -5143,11 +5144,11 @@ public function increaseDocumentAttribute(string $collection, string $id, string
*/
$attr = \end($attr);
if (!in_array($attr->getAttribute('type'), $whiteList)) {
throw new DatabaseException('Attribute type must be one of: ' . implode(',', $whiteList));
throw new TypeException('Attribute type must be one of: ' . implode(',', $whiteList));
}

if ($max && ($document->getAttribute($attribute) + $value > $max)) {
throw new DatabaseException('Attribute value exceeds maximum limit: ' . $max);
throw new LimitException('Attribute value exceeds maximum limit: ' . $max);
}

$time = DateTime::now();
Expand Down Expand Up @@ -5234,11 +5235,11 @@ public function decreaseDocumentAttribute(string $collection, string $id, string
*/
$attr = \end($attr);
if (!in_array($attr->getAttribute('type'), $whiteList)) {
throw new DatabaseException('Attribute type must be one of: ' . implode(',', $whiteList));
throw new TypeException('Attribute type must be one of: ' . \implode(',', $whiteList));
}

if ($min && ($document->getAttribute($attribute) - $value < $min)) {
throw new DatabaseException('Attribute value Exceeds minimum limit ' . $min);
throw new LimitException('Attribute value exceeds minimum limit: ' . $min);
}

$time = DateTime::now();
Expand Down
9 changes: 9 additions & 0 deletions src/Database/Exception/Type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Utopia\Database\Exception;

use Utopia\Database\Exception;

class Type extends Exception
{
}