From 4f1f9bb4a23281a8088385b8065cfba64c8acc09 Mon Sep 17 00:00:00 2001 From: Darshan Date: Sat, 26 Apr 2025 16:06:53 +0530 Subject: [PATCH] add: filter for latest changes. --- app/controllers/general.php | 3 +- src/Appwrite/Utopia/Request/Filters/V19.php | 32 +++++++++++++++------ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 889571fe62..bf048be9d6 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -805,7 +805,8 @@ App::init() if (version_compare($requestFormat, '1.6.0', '<')) { $request->addFilter(new RequestV18()); } - if (version_compare($requestFormat, '1.7.0', '<')) { + // alias filters on 1.7.x, so we use `<=` and not just `<` + if (version_compare($requestFormat, '1.7.0', '<=')) { $request->addFilter(new RequestV19()); } } diff --git a/src/Appwrite/Utopia/Request/Filters/V19.php b/src/Appwrite/Utopia/Request/Filters/V19.php index 041c126a69..9597f40570 100644 --- a/src/Appwrite/Utopia/Request/Filters/V19.php +++ b/src/Appwrite/Utopia/Request/Filters/V19.php @@ -6,18 +6,32 @@ use Appwrite\Utopia\Request\Filter; class V19 extends Filter { - // Convert 1.6 params to 1.7 public function parse(array $content, string $model): array { - /* - Uncomment with first request filter; current is just a copy of V18 - switch ($model) { - case 'functions.create': - $content['something'] = $content['somethingElse'] ?? ""; - unset($content['something']); - break; + return $this->overrideDatabaseParams($content, $model); + } + + // Database terminology change handling. + protected function overrideDatabaseParams(array $content, string $model): array + { + if (!str_starts_with($model, 'databases.')) { + return $content; + } + + $map = [ + 'collectionId' => 'tableId', + 'attributeId' => 'columnId', + 'attributes' => 'columns', + 'documentId' => 'rowId', + 'relatedCollectionId' => 'relatedTableId' + ]; + + foreach ($map as $oldKey => $newKey) { + if (isset($content[$oldKey])) { + $content[$newKey] = $content[$oldKey]; + unset($content[$oldKey]); + } } - */ return $content; }