Skip to content

Commit b6678c0

Browse files
committed
Merge branch 'main' of github.com:utopia-php/database into joins8
2 parents adf0df4 + aa80f86 commit b6678c0

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/Database/Database.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,6 +2670,22 @@ public function updateAttribute(string $collection, string $id, ?string $type =
26702670
}
26712671
break;
26722672

2673+
case self::VAR_VARCHAR:
2674+
if (empty($size)) {
2675+
throw new DatabaseException('Size length is required');
2676+
}
2677+
2678+
if ($size > $this->adapter->getMaxVarcharLength()) {
2679+
throw new DatabaseException('Max size allowed for varchar is: ' . number_format($this->adapter->getMaxVarcharLength()));
2680+
}
2681+
break;
2682+
2683+
case self::VAR_TEXT:
2684+
case self::VAR_MEDIUMTEXT:
2685+
case self::VAR_LONGTEXT:
2686+
// Text types don't require size validation as they have fixed max sizes
2687+
break;
2688+
26732689
case self::VAR_INTEGER:
26742690
$limit = ($signed) ? $this->adapter->getLimitForInt() / 2 : $this->adapter->getLimitForInt();
26752691
if ($size > $limit) {
@@ -2737,6 +2753,10 @@ public function updateAttribute(string $collection, string $id, ?string $type =
27372753
default:
27382754
$supportedTypes = [
27392755
self::VAR_STRING,
2756+
self::VAR_VARCHAR,
2757+
self::VAR_TEXT,
2758+
self::VAR_MEDIUMTEXT,
2759+
self::VAR_LONGTEXT,
27402760
self::VAR_INTEGER,
27412761
self::VAR_FLOAT,
27422762
self::VAR_BOOLEAN,
@@ -5699,6 +5719,10 @@ public function updateDocument(string $collection, string $id, Document $documen
56995719

57005720
$this->purgeCachedDocument($collection->getId(), $id);
57015721

5722+
if ($document->getId() !== $id) {
5723+
$this->purgeCachedDocument($collection->getId(), $document->getId());
5724+
}
5725+
57025726
// If operators were used, refetch document to get computed values
57035727
$hasOperators = false;
57045728
foreach ($document->getArrayCopy() as $value) {

0 commit comments

Comments
 (0)