mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Merge pull request #11230 from appwrite/fix-responses
This commit is contained in:
commit
c04353bd38
4 changed files with 85 additions and 8 deletions
14
composer.lock
generated
14
composer.lock
generated
|
|
@ -3961,16 +3961,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "5.0.0",
|
||||
"version": "5.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "221794bd7de027f9177cd325209e8162ca2520cb"
|
||||
"reference": "2783f07e74ddd86dda6e711d79212dd34158540d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/221794bd7de027f9177cd325209e8162ca2520cb",
|
||||
"reference": "221794bd7de027f9177cd325209e8162ca2520cb",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/2783f07e74ddd86dda6e711d79212dd34158540d",
|
||||
"reference": "2783f07e74ddd86dda6e711d79212dd34158540d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -4013,9 +4013,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/5.0.0"
|
||||
"source": "https://github.com/utopia-php/database/tree/5.0.1"
|
||||
},
|
||||
"time": "2026-01-30T06:17:53+00:00"
|
||||
"time": "2026-02-03T10:31:12+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
|
|
@ -9076,5 +9076,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "8.3"
|
||||
},
|
||||
"plugin-api-version": "2.6.0"
|
||||
"plugin-api-version": "2.9.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,11 @@ class ColumnList extends Model
|
|||
Response::MODEL_COLUMN_POINT,
|
||||
Response::MODEL_COLUMN_LINE,
|
||||
Response::MODEL_COLUMN_POLYGON,
|
||||
Response::MODEL_COLUMN_STRING // needs to be last, since its condition would dominate any other string attribute
|
||||
Response::MODEL_COLUMN_VARCHAR,
|
||||
Response::MODEL_COLUMN_TEXT,
|
||||
Response::MODEL_COLUMN_MEDIUMTEXT,
|
||||
Response::MODEL_COLUMN_LONGTEXT,
|
||||
Response::MODEL_COLUMN_STRING, // needs to be last, since its condition would dominate any other string attribute
|
||||
],
|
||||
'description' => 'List of columns.',
|
||||
'default' => [],
|
||||
|
|
|
|||
|
|
@ -74,6 +74,10 @@ class Table extends Model
|
|||
Response::MODEL_COLUMN_POINT,
|
||||
Response::MODEL_COLUMN_LINE,
|
||||
Response::MODEL_COLUMN_POLYGON,
|
||||
Response::MODEL_COLUMN_VARCHAR,
|
||||
Response::MODEL_COLUMN_TEXT,
|
||||
Response::MODEL_COLUMN_MEDIUMTEXT,
|
||||
Response::MODEL_COLUMN_LONGTEXT,
|
||||
Response::MODEL_COLUMN_STRING, // needs to be last, since its condition would dominate any other string attribute
|
||||
],
|
||||
'description' => 'Table columns.',
|
||||
|
|
|
|||
|
|
@ -760,6 +760,75 @@ class DatabasesStringTypesTest extends Scope
|
|||
/**
|
||||
* @depends testGetLongtextColumn
|
||||
*/
|
||||
public function testGetTableWithStringTypeColumns(array $data): array
|
||||
{
|
||||
$databaseId = $data['databaseId'];
|
||||
$tableId = $data['tableId'];
|
||||
|
||||
// Test SUCCESS: Get full table - verifies Table model serializes all string column types
|
||||
$table = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId, [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $table['headers']['status-code']);
|
||||
$this->assertEquals($tableId, $table['body']['$id']);
|
||||
$this->assertIsArray($table['body']['columns']);
|
||||
|
||||
// Extract column types from the response
|
||||
$columnTypes = array_map(fn ($col) => $col['type'], $table['body']['columns']);
|
||||
|
||||
// Verify all new string types are present and properly serialized
|
||||
$this->assertContains('varchar', $columnTypes, 'Table response should contain varchar columns');
|
||||
$this->assertContains('text', $columnTypes, 'Table response should contain text columns');
|
||||
$this->assertContains('mediumtext', $columnTypes, 'Table response should contain mediumtext columns');
|
||||
$this->assertContains('longtext', $columnTypes, 'Table response should contain longtext columns');
|
||||
|
||||
// Verify column keys are present
|
||||
$columnKeys = array_map(fn ($col) => $col['key'], $table['body']['columns']);
|
||||
$this->assertContains('varchar_field', $columnKeys);
|
||||
$this->assertContains('text_field', $columnKeys);
|
||||
$this->assertContains('mediumtext_field', $columnKeys);
|
||||
$this->assertContains('longtext_field', $columnKeys);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetTableWithStringTypeColumns
|
||||
*/
|
||||
public function testListColumnsWithStringTypes(array $data): array
|
||||
{
|
||||
$databaseId = $data['databaseId'];
|
||||
$tableId = $data['tableId'];
|
||||
|
||||
// Test SUCCESS: List all columns - verifies ColumnList model serializes all string column types
|
||||
$columns = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns', [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $columns['headers']['status-code']);
|
||||
$this->assertIsArray($columns['body']['columns']);
|
||||
$this->assertGreaterThan(0, $columns['body']['total']);
|
||||
|
||||
// Extract column types from the response
|
||||
$columnTypes = array_map(fn ($col) => $col['type'], $columns['body']['columns']);
|
||||
|
||||
// Verify all new string types are present and properly serialized
|
||||
$this->assertContains('varchar', $columnTypes, 'Column list should contain varchar columns');
|
||||
$this->assertContains('text', $columnTypes, 'Column list should contain text columns');
|
||||
$this->assertContains('mediumtext', $columnTypes, 'Column list should contain mediumtext columns');
|
||||
$this->assertContains('longtext', $columnTypes, 'Column list should contain longtext columns');
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testListColumnsWithStringTypes
|
||||
*/
|
||||
public function testDeleteStringTypeColumns(array $data): void
|
||||
{
|
||||
$databaseId = $data['databaseId'];
|
||||
|
|
|
|||
Loading…
Reference in a new issue