|
11 | 11 | use Utopia\Database\Exception as DatabaseException; |
12 | 12 | use Utopia\Database\Exception\Duplicate as DuplicateException; |
13 | 13 | use Utopia\Database\Exception\NotFound as NotFoundException; |
| 14 | +use Utopia\Database\Exception\Query as QueryException; |
14 | 15 | use Utopia\Database\Exception\Transaction as TransactionException; |
15 | 16 | use Utopia\Database\Query; |
16 | 17 |
|
@@ -426,10 +427,20 @@ public function updateDocuments(string $collection, Document $updates, array $do |
426 | 427 | $attributes['_createdAt'] = $updates->getCreatedAt(); |
427 | 428 | } |
428 | 429 |
|
429 | | - if (!empty($updates->getPermissions())) { |
| 430 | + if ($updates->offsetExists('$permissions')) { |
430 | 431 | $attributes['_permissions'] = json_encode($updates->getPermissions()); |
431 | 432 | } |
432 | 433 |
|
| 434 | +// if ($updatePermissions) { |
| 435 | +// $originalPermissions = $document->getPermissions(); |
| 436 | +// $currentPermissions = $updates->getPermissions(); |
| 437 | +// |
| 438 | +// sort($originalPermissions); |
| 439 | +// sort($currentPermissions); |
| 440 | +// |
| 441 | +// $skipPermissionsUpdate = ($originalPermissions === $currentPermissions); |
| 442 | +// } |
| 443 | + |
433 | 444 | if (empty($attributes)) { |
434 | 445 | return 0; |
435 | 446 | } |
@@ -484,15 +495,14 @@ public function updateDocuments(string $collection, Document $updates, array $do |
484 | 495 | $affected = $stmt->rowCount(); |
485 | 496 |
|
486 | 497 | // Permissions logic |
487 | | - if (!empty($updates->getPermissions())) { |
| 498 | + if ($updates->offsetExists('$permissions')) { |
488 | 499 | $removeQueries = []; |
489 | 500 | $removeBindValues = []; |
490 | 501 |
|
491 | 502 | $addQuery = ''; |
492 | 503 | $addBindValues = []; |
493 | 504 |
|
494 | 505 | foreach ($documents as $index => $document) { |
495 | | - // Permissions logic |
496 | 506 | $sql = " |
497 | 507 | SELECT _type, _permission |
498 | 508 | FROM {$this->getSQLTable($name . '_perms')} |
|
0 commit comments