Merge pull request #11338 from appwrite/fix/response-model-key

fix: add missing string type models to AttributeList and Collection
This commit is contained in:
Luke B. Silver
2026-02-16 20:40:12 +00:00
committed by GitHub
3 changed files with 65 additions and 0 deletions
@@ -30,6 +30,10 @@ class AttributeList extends Model
Response::MODEL_ATTRIBUTE_POINT,
Response::MODEL_ATTRIBUTE_LINE,
Response::MODEL_ATTRIBUTE_POLYGON,
Response::MODEL_ATTRIBUTE_VARCHAR,
Response::MODEL_ATTRIBUTE_TEXT,
Response::MODEL_ATTRIBUTE_MEDIUMTEXT,
Response::MODEL_ATTRIBUTE_LONGTEXT,
Response::MODEL_ATTRIBUTE_STRING // needs to be last, since its condition would dominate any other string attribute
],
'description' => 'List of attributes.',
@@ -73,6 +73,10 @@ class Collection extends Model
Response::MODEL_ATTRIBUTE_POINT,
Response::MODEL_ATTRIBUTE_LINE,
Response::MODEL_ATTRIBUTE_POLYGON,
Response::MODEL_ATTRIBUTE_VARCHAR,
Response::MODEL_ATTRIBUTE_TEXT,
Response::MODEL_ATTRIBUTE_MEDIUMTEXT,
Response::MODEL_ATTRIBUTE_LONGTEXT,
Response::MODEL_ATTRIBUTE_STRING, // needs to be last, since its condition would dominate any other string attribute
],
'description' => 'Collection attributes.',
@@ -514,6 +514,63 @@ class DatabasesStringTypesTest extends Scope
/**
* @depends testCreateLongtextAttribute
*/
public function testListStringTypeAttributes(array $data): array
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
// Wait for attributes to be created
sleep(2);
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]);
$this->assertEquals(200, $response['headers']['status-code']);
$attributes = $response['body']['attributes'];
$types = array_column($attributes, 'type');
$this->assertContains('varchar', $types);
$this->assertContains('text', $types);
$this->assertContains('mediumtext', $types);
$this->assertContains('longtext', $types);
return $data;
}
/**
* @depends testListStringTypeAttributes
*/
public function testGetCollectionWithStringTypeAttributes(array $data): array
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]);
$this->assertEquals(200, $response['headers']['status-code']);
$attributes = $response['body']['attributes'];
$types = array_column($attributes, 'type');
$this->assertContains('varchar', $types);
$this->assertContains('text', $types);
$this->assertContains('mediumtext', $types);
$this->assertContains('longtext', $types);
return $data;
}
/**
* @depends testGetCollectionWithStringTypeAttributes
*/
public function testUpdateVarcharAttribute(array $data): array
{
$this->markTestSkipped('Skipped until utopia-php/database updateAttribute supports VARCHAR type');