From a2d7c3c138ef9563df945d319c6aa17b8b6c8905 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 20 Aug 2025 16:53:22 +1200 Subject: [PATCH] Remove redundant param --- .../Databases/Http/Databases/Action.php | 23 +++++++++++++++++++ .../Databases/Http/Databases/Create.php | 5 +--- .../Databases/Http/TablesDB/Create.php | 1 - 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php new file mode 100644 index 0000000000..74de531d32 --- /dev/null +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Action.php @@ -0,0 +1,23 @@ +context; + } + + public function setHttpPath(string $path): UtopiaAction + { + if (\str_contains($path, '/tablesdb')) { + $this->context = 'tablesdb'; + } + return parent::setHttpPath($path); + } +} \ No newline at end of file diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php index 21f76c8ecb..2e9c947696 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Create.php @@ -19,11 +19,9 @@ use Utopia\Database\Exception\Index as IndexException; use Utopia\Database\Exception\Limit as LimitException; use Utopia\Database\Exception\Structure as StructureException; use Utopia\Database\Helpers\ID; -use Utopia\Platform\Action; use Utopia\Swoole\Response as SwooleResponse; use Utopia\Validator\Boolean; use Utopia\Validator\Text; -use Utopia\Validator\WhiteList; class Create extends Action { @@ -67,7 +65,6 @@ class Create extends Action ->param('databaseId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Database name. Max length: 128 chars.') ->param('enabled', true, new Boolean(), 'Is the database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true) - ->param('type', 'tablesdb', new WhiteList(['tablesdb','legacy']), 'Database type.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents') @@ -84,7 +81,7 @@ class Create extends Action 'name' => $name, 'enabled' => $enabled, 'search' => implode(' ', [$databaseId, $name]), - 'type' => $type + 'type' => $this->getDatabaseType(), ])); } catch (DuplicateException) { throw new Exception(Exception::DATABASE_ALREADY_EXISTS); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php index 762be79590..b57b5074d5 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/TablesDB/Create.php @@ -50,7 +50,6 @@ class Create extends DatabaseCreate ->param('databaseId', '', new CustomId(), 'Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', '', new Text(128), 'Database name. Max length: 128 chars.') ->param('enabled', true, new Boolean(), 'Is the database enabled? When set to \'disabled\', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled.', true) - ->param('type', 'tablesdb', new WhiteList(['tablesdb','legacy']), 'Database type.', true) ->inject('response') ->inject('dbForProject') ->inject('queueForEvents')