fix(databases): support text, varchar and format column types inline

Creating a table/collection with its schema in one call rejected every
non-legacy string type. The shared Attributes validator's supported-type
list was never updated when the text/varchar family was introduced, so
`text`, `varchar`, `mediumtext` and `longtext` all failed with
"Invalid type for attribute '<key>': text" even though the dedicated
per-column endpoints create those exact types. The metadata row is
written before validation runs, so callers got a partially executed
request and had to fall back to createTable + N column calls.

The size defaults that make those types work only lived in the dedicated
endpoints, so widening the type list alone was not enough. Move the
type/format to size mapping into Appwrite\Utopia\Database\Attribute and
consume it from both the validator and the inline attribute builder, so
the two surfaces produce identical attribute documents and cannot drift
again. The format shorthands (email, url, ip, enum) are now accepted as
a `type` too, mirroring createEmailColumn and friends, and a string with
an explicit `format` no longer needs a `size`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ClaudearandClaude Opus 5 committed 2026-08-10 13:06:46 +00:00
1 parent 0b2f62d461
commit 7130cb40ac
6 files changed
+414 -36

No files matched your search

@@ -9,6 +9,7 @@ use Appwrite\SDK\ContentType;
use Appwrite\SDK\Deprecated;
use Appwrite\SDK\Method;
use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Utopia\Database\Attribute;
use Appwrite\Utopia\Database\Validator\Attributes as AttributesValidator;
use Appwrite\Utopia\Database\Validator\CustomId;
use Appwrite\Utopia\Database\Validator\Indexes as IndexesValidator;
@@ -81,7 +82,7 @@ class Create extends Action
->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
->param('documentSecurity', false, new Boolean(true), 'Enables configuring permissions for individual documents. A user needs one of document or collection level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
->param('enabled', true, new Boolean(), 'Is collection enabled? When set to \'disabled\', users cannot access the collection but Server SDKs with and API key can still read and write to the collection. No data is lost when this is toggled.', true)
->param('attributes', [], new ArrayList(new JSONObject(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, integer, float, boolean, datetime), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options.', true)
->param('attributes', [], new ArrayList(new JSONObject(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of attribute definitions to create. Each attribute should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, float, boolean, datetime, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options.', true)
->param('indexes', [], new ArrayList(new JSONObject(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of attribute keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional).', true)
->inject('response')
->inject('dbForProject')
@@ -279,13 +280,12 @@ class Create extends Action
Document $collection,
array $attribute,
): array {
['type' => $type, 'format' => $format, 'size' => $size] = Attribute::resolve($attribute);
$key = $attribute['key'];
$type = $attribute['type'];
$size = $attribute['size'] ?? 0;
$required = $attribute['required'] ?? false;
$signed = $attribute['signed'] ?? true;
$array = $attribute['array'] ?? false;
$format = $attribute['format'] ?? '';
$formatOptions = [];
$filters = $attribute['filters'] ?? [];
$default = $attribute['default'] ?? null;
@@ -64,7 +64,7 @@ class Create extends CollectionCreate
->param('permissions', null, new Nullable(new Permissions(APP_LIMIT_ARRAY_PARAMS_SIZE)), 'An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
->param('rowSecurity', false, new Boolean(true), 'Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions).', true)
->param('enabled', true, new Boolean(), 'Is table enabled? When set to \'disabled\', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled.', true)
->param('columns', [], new ArrayList(new JSONObject(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of column definitions to create. Each column should contain: key (string), type (string: string, integer, float, boolean, datetime, relationship), size (integer, required for string type), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options.', true)
->param('columns', [], new ArrayList(new JSONObject(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of column definitions to create. Each column should contain: key (string), type (string: string, varchar, text, mediumtext, longtext, integer, bigint, float, boolean, datetime, email, url, ip, enum), size (integer, required for string and varchar types), required (boolean, optional), default (mixed, optional), array (boolean, optional), and type-specific options.', true)
->param('indexes', [], new ArrayList(new JSONObject(), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of index definitions to create. Each index should contain: key (string), type (string: key, fulltext, unique, spatial), attributes (array of column keys), orders (array of ASC/DESC, optional), and lengths (array of integers, optional).', true)
->inject('response')
->inject('dbForProject')
+100
View File
@@ -0,0 +1,100 @@
<?php
namespace Appwrite\Utopia\Database;
use Utopia\Database\Database;
/**
* Shared definition of the attribute types the API exposes.
*
* The dedicated per-attribute endpoints hardcode a type, a format and a size
* each. This holds the same mapping so the inline `attributes`/`columns` array
* on create collection/table produces identical attribute documents.
*/
class Attribute
{
/**
* Types whose size is fixed by the type itself.
*
* @var array<string, int>
*/
public const SIZES = [
Database::VAR_TEXT => 65535,
Database::VAR_MEDIUMTEXT => 16777215,
Database::VAR_LONGTEXT => 2147483647,
];
/**
* String formats, mapped to the size their dedicated endpoint uses. Each
* format is also accepted as a shorthand type, mirroring the endpoints
* (`createEmailColumn` and friends) that create a string with that format.
*
* @var array<string, int>
*/
public const FORMAT_SIZES = [
APP_DATABASE_ATTRIBUTE_EMAIL => 254,
APP_DATABASE_ATTRIBUTE_ENUM => Database::LENGTH_KEY,
APP_DATABASE_ATTRIBUTE_IP => 39,
APP_DATABASE_ATTRIBUTE_URL => 2000,
];
/**
* Types accepted in an inline definition, including the format shorthands.
*
* @return array<string>
*/
public static function types(): array
{
return [
Database::VAR_STRING,
Database::VAR_VARCHAR,
Database::VAR_TEXT,
Database::VAR_MEDIUMTEXT,
Database::VAR_LONGTEXT,
Database::VAR_INTEGER,
Database::VAR_BIGINT,
Database::VAR_FLOAT,
Database::VAR_BOOLEAN,
Database::VAR_DATETIME,
Database::VAR_POINT,
Database::VAR_LINESTRING,
Database::VAR_POLYGON,
...\array_keys(self::FORMAT_SIZES),
];
}
/**
* Resolve an inline definition into the type, format and size stored on the
* attribute document. A format shorthand becomes a string of that format,
* and a size is filled in from the type or format when the caller omits it.
*
* @param array<string, mixed> $attribute
* @return array{type: string, format: string, size: int}
*/
public static function resolve(array $attribute): array
{
$type = $attribute['type'] ?? '';
$format = $attribute['format'] ?? '';
if (isset(self::FORMAT_SIZES[$type])) {
$format = $type;
$type = Database::VAR_STRING;
}
$size = $attribute['size'] ?? 0;
$size = \is_int($size) ? $size : 0;
if (isset(self::SIZES[$type])) {
// Fixed width types ignore any size the caller sent.
$size = self::SIZES[$type];
} elseif ($size < 1) {
$size = self::FORMAT_SIZES[$format] ?? $size;
}
return [
'type' => $type,
'format' => $format,
'size' => $size,
];
}
}
@@ -2,6 +2,7 @@
namespace Appwrite\Utopia\Database\Validator;
use Appwrite\Utopia\Database\Attribute;
use Utopia\Database\Database;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\Database\Validator\Key;
@@ -17,21 +18,6 @@ class Attributes extends Validator
protected int $maxAttributes;
protected string $message = 'Invalid attributes';
/**
* @var array<string> Supported attribute types
*/
protected array $supportedTypes = [
Database::VAR_STRING,
Database::VAR_INTEGER,
Database::VAR_BIGINT,
Database::VAR_FLOAT,
Database::VAR_BOOLEAN,
Database::VAR_DATETIME,
Database::VAR_POINT,
Database::VAR_LINESTRING,
Database::VAR_POLYGON,
];
/**
* @var array<string> Supported formats for string attributes
*/
@@ -92,6 +78,7 @@ class Attributes extends Validator
}
$keyValidator = new Key();
$supportedTypes = Attribute::types();
$keys = [];
foreach ($value as $index => $attribute) {
@@ -132,34 +119,44 @@ class Attributes extends Validator
}
// Validate type
if (!\in_array($attribute['type'], $this->supportedTypes)) {
if (!\in_array($attribute['type'], $supportedTypes)) {
$this->message = "Invalid type for attribute '" . $attribute['key'] . "': " . $attribute['type'];
return false;
}
// Resolve format shorthands and implicit sizes the same way the
// attribute document is built, so both agree on what was asked for.
['type' => $type, 'format' => $format, 'size' => $size] = Attribute::resolve($attribute);
// Validate spatial type support
if (\in_array($attribute['type'], Database::SPATIAL_TYPES) && !$this->supportForSpatialAttributes) {
if (\in_array($type, Database::SPATIAL_TYPES) && !$this->supportForSpatialAttributes) {
$this->message = "Spatial attributes are not supported by the current database";
return false;
}
// Validate size for string types
if ($attribute['type'] === Database::VAR_STRING) {
if (!isset($attribute['size']) || !is_int($attribute['size']) || $attribute['size'] < 1 || $attribute['size'] > APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH) {
if (isset($attribute['size']) && !\is_int($attribute['size'])) {
$this->message = "Invalid size for attribute '" . $attribute['key'] . "': must be an integer";
return false;
}
// Validate size for the types that take one. The remaining string
// types (text, mediumtext, longtext) are fixed width.
if (\in_array($type, [Database::VAR_STRING, Database::VAR_VARCHAR])) {
if ($size < 1 || $size > APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH) {
$this->message = "Invalid or missing size for string attribute '" . $attribute['key'] . "'. Size must be between 1 and " . APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH;
return false;
}
}
// Validate format if provided
if (isset($attribute['format']) && $attribute['format'] !== '') {
// Format is only allowed for string type
if ($attribute['type'] !== Database::VAR_STRING) {
if ($format !== '') {
// Format is only allowed for sized string types
if (!\in_array($type, [Database::VAR_STRING, Database::VAR_VARCHAR])) {
$this->message = "Format is only allowed for string type for attribute '" . $attribute['key'] . "'";
return false;
}
if (!in_array($attribute['format'], $this->supportedFormats)) {
$this->message = "Invalid format for attribute '" . $attribute['key'] . "': " . $attribute['format'];
if (!in_array($format, $this->supportedFormats)) {
$this->message = "Invalid format for attribute '" . $attribute['key'] . "': " . $format;
return false;
}
}
@@ -183,7 +180,7 @@ class Attributes extends Validator
}
// Validate signed only for integer/bigint/float types
if (isset($attribute['signed']) && !in_array($attribute['type'], [Database::VAR_INTEGER, Database::VAR_BIGINT, Database::VAR_FLOAT])) {
if (isset($attribute['signed']) && !in_array($type, [Database::VAR_INTEGER, Database::VAR_BIGINT, Database::VAR_FLOAT])) {
$this->message = "Attribute '" . $attribute['key'] . "': 'signed' can only be used with integer, bigint or float types";
return false;
}
@@ -202,7 +199,7 @@ class Attributes extends Validator
// Validate min/max range for integer/bigint/float
if (isset($attribute['min']) || isset($attribute['max'])) {
if (!in_array($attribute['type'], [Database::VAR_INTEGER, Database::VAR_BIGINT, Database::VAR_FLOAT])) {
if (!in_array($type, [Database::VAR_INTEGER, Database::VAR_BIGINT, Database::VAR_FLOAT])) {
$this->message = "Attribute '" . $attribute['key'] . "': min/max can only be used with integer, bigint or float types";
return false;
}
@@ -216,15 +213,18 @@ class Attributes extends Validator
// Validate default value matches attribute type
if (isset($attribute['default'])) {
switch ($attribute['type']) {
switch ($type) {
case Database::VAR_STRING:
case Database::VAR_VARCHAR:
case Database::VAR_TEXT:
case Database::VAR_MEDIUMTEXT:
case Database::VAR_LONGTEXT:
if (!is_string($attribute['default'])) {
$this->message = "Default value for string attribute '" . $attribute['key'] . "' must be a string";
return false;
}
// Validate string size
$size = $attribute['size'] ?? 0;
if ($size > 0) {
$textValidator = new Text($size, 0);
if (!$textValidator->isValid($attribute['default'])) {
@@ -234,7 +234,6 @@ class Attributes extends Validator
}
// Validate format-specific defaults
$format = $attribute['format'] ?? '';
if ($format === APP_DATABASE_ATTRIBUTE_EMAIL) {
$emailValidator = new Email();
if (!$emailValidator->isValid($attribute['default'])) {
@@ -330,7 +329,7 @@ class Attributes extends Validator
}
// Validate enum elements if format is enum
if (isset($attribute['format']) && $attribute['format'] === APP_DATABASE_ATTRIBUTE_ENUM) {
if ($format === APP_DATABASE_ATTRIBUTE_ENUM) {
if (!isset($attribute['elements']) || !is_array($attribute['elements']) || empty($attribute['elements'])) {
$this->message = "Attribute '" . $attribute['key'] . "' with enum format must have 'elements' array";
return false;
@@ -0,0 +1,142 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\TablesDB;
use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
final class TablesDBColumnsTest extends Scope
{
use ProjectCustom;
use SideServer;
/**
* Every column type the dedicated endpoints expose must also be creatable
* inline on create table.
*/
public function testCreateTableColumns(): void
{
$headers = [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
];
$database = $this->client->call(Client::METHOD_POST, '/tablesdb', $headers, [
'databaseId' => ID::unique(),
'name' => 'Inline Columns',
]);
$this->assertEquals(201, $database['headers']['status-code']);
$databaseId = $database['body']['$id'];
$table = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', $headers, [
'tableId' => ID::unique(),
'name' => 'Modules',
'permissions' => [
Permission::create(Role::any()),
Permission::read(Role::any()),
],
'columns' => [
['key' => 'title', 'type' => 'string', 'size' => 128, 'required' => true],
['key' => 'slug', 'type' => 'varchar', 'size' => 64],
['key' => 'modulePath', 'type' => 'text'],
['key' => 'summary', 'type' => 'mediumtext'],
['key' => 'archive', 'type' => 'longtext'],
['key' => 'email', 'type' => 'email'],
['key' => 'website', 'type' => 'url'],
['key' => 'address', 'type' => 'ip'],
['key' => 'status', 'type' => 'enum', 'elements' => ['on', 'off'], 'default' => 'on'],
],
]);
$this->assertEquals(201, $table['headers']['status-code']);
$tableId = $table['body']['$id'];
$columns = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/columns', $headers);
$this->assertEquals(200, $columns['headers']['status-code']);
$this->assertEquals(9, $columns['body']['total']);
$byKey = [];
foreach ($columns['body']['columns'] as $column) {
$this->assertEquals('available', $column['status']);
$byKey[$column['key']] = $column;
}
// Sizes must match the dedicated per-column endpoints
$this->assertEquals('string', $byKey['title']['type']);
$this->assertEquals(128, $byKey['title']['size']);
$this->assertEquals('varchar', $byKey['slug']['type']);
$this->assertEquals(64, $byKey['slug']['size']);
$this->assertEquals('text', $byKey['modulePath']['type']);
$this->assertEquals(65535, $byKey['modulePath']['size']);
$this->assertEquals('mediumtext', $byKey['summary']['type']);
$this->assertEquals(16777215, $byKey['summary']['size']);
$this->assertEquals('longtext', $byKey['archive']['type']);
$this->assertEquals(2147483647, $byKey['archive']['size']);
// Format shorthands become a string of that format
$this->assertEquals('string', $byKey['email']['type']);
$this->assertEquals('email', $byKey['email']['format']);
$this->assertEquals('string', $byKey['website']['type']);
$this->assertEquals('url', $byKey['website']['format']);
$this->assertEquals('string', $byKey['address']['type']);
$this->assertEquals('ip', $byKey['address']['format']);
$this->assertEquals('string', $byKey['status']['type']);
$this->assertEquals('enum', $byKey['status']['format']);
$this->assertEquals(['on', 'off'], $byKey['status']['elements']);
$this->assertEquals('on', $byKey['status']['default']);
$row = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows', $headers, [
'rowId' => ID::unique(),
'data' => [
'title' => 'Appwrite',
'modulePath' => 'src/Appwrite/Platform/Modules/Databases',
'email' => 'team@appwrite.io',
'website' => 'https://appwrite.io',
'address' => '127.0.0.1',
'status' => 'off',
],
]);
$this->assertEquals(201, $row['headers']['status-code']);
$this->assertEquals('src/Appwrite/Platform/Modules/Databases', $row['body']['modulePath']);
$this->assertEquals('off', $row['body']['status']);
}
public function testCreateTableUnsupportedColumnType(): void
{
$headers = [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
];
$database = $this->client->call(Client::METHOD_POST, '/tablesdb', $headers, [
'databaseId' => ID::unique(),
'name' => 'Inline Columns Invalid',
]);
$this->assertEquals(201, $database['headers']['status-code']);
$databaseId = $database['body']['$id'];
$table = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables', $headers, [
'tableId' => ID::unique(),
'name' => 'Invalid',
'columns' => [
['key' => 'unknown', 'type' => 'blob'],
],
]);
$this->assertEquals(400, $table['headers']['status-code']);
$this->assertStringContainsString("Invalid type for attribute 'unknown': blob", (string) $table['body']['message']);
}
}
@@ -0,0 +1,137 @@
<?php
declare(strict_types=1);
namespace Tests\Unit\Utopia\Database\Validator;
use Appwrite\Utopia\Database\Attribute;
use Appwrite\Utopia\Database\Validator\Attributes;
use PHPUnit\Framework\TestCase;
use Utopia\Database\Database;
final class AttributesTest extends TestCase
{
protected Attributes $object;
public function setUp(): void
{
$this->object = new Attributes();
}
public function testStringTypes(): void
{
$this->assertTrue($this->object->isValid([
['key' => 'title', 'type' => Database::VAR_STRING, 'size' => 128],
['key' => 'slug', 'type' => Database::VAR_VARCHAR, 'size' => 128],
['key' => 'body', 'type' => Database::VAR_TEXT],
['key' => 'summary', 'type' => Database::VAR_MEDIUMTEXT],
['key' => 'archive', 'type' => Database::VAR_LONGTEXT],
]), $this->object->getDescription());
}
public function testStringTypeDefaults(): void
{
$this->assertTrue($this->object->isValid([
['key' => 'body', 'type' => Database::VAR_TEXT, 'default' => 'hello'],
]), $this->object->getDescription());
$this->assertFalse($this->object->isValid([
['key' => 'body', 'type' => Database::VAR_TEXT, 'default' => 1],
]));
$this->assertFalse($this->object->isValid([
['key' => 'slug', 'type' => Database::VAR_VARCHAR, 'size' => 4, 'default' => 'toolong'],
]));
}
public function testVarcharRequiresSize(): void
{
$this->assertFalse($this->object->isValid([
['key' => 'slug', 'type' => Database::VAR_VARCHAR],
]));
}
public function testFormatTypes(): void
{
$this->assertTrue($this->object->isValid([
['key' => 'email', 'type' => APP_DATABASE_ATTRIBUTE_EMAIL, 'required' => true],
['key' => 'website', 'type' => APP_DATABASE_ATTRIBUTE_URL],
['key' => 'address', 'type' => APP_DATABASE_ATTRIBUTE_IP],
['key' => 'status', 'type' => APP_DATABASE_ATTRIBUTE_ENUM, 'elements' => ['on', 'off'], 'default' => 'on'],
]), $this->object->getDescription());
$this->assertFalse($this->object->isValid([
['key' => 'email', 'type' => APP_DATABASE_ATTRIBUTE_EMAIL, 'default' => 'not-an-email'],
]));
$this->assertFalse($this->object->isValid([
['key' => 'status', 'type' => APP_DATABASE_ATTRIBUTE_ENUM],
]));
}
public function testEmailWithoutSize(): void
{
$this->assertTrue($this->object->isValid([
['key' => 'email', 'type' => Database::VAR_STRING, 'format' => APP_DATABASE_ATTRIBUTE_EMAIL],
]), $this->object->getDescription());
}
public function testUnsupportedType(): void
{
$this->assertFalse($this->object->isValid([
['key' => 'rel', 'type' => Database::VAR_RELATIONSHIP],
]));
$this->assertSame("Invalid type for attribute 'rel': relationship", $this->object->getDescription());
}
public function testResolveMatchesDedicatedEndpoints(): void
{
$this->assertEquals(
['type' => Database::VAR_TEXT, 'format' => '', 'size' => 65535],
Attribute::resolve(['key' => 'body', 'type' => Database::VAR_TEXT])
);
$this->assertEquals(
['type' => Database::VAR_MEDIUMTEXT, 'format' => '', 'size' => 16777215],
Attribute::resolve(['key' => 'body', 'type' => Database::VAR_MEDIUMTEXT])
);
$this->assertEquals(
['type' => Database::VAR_LONGTEXT, 'format' => '', 'size' => 2147483647],
Attribute::resolve(['key' => 'body', 'type' => Database::VAR_LONGTEXT])
);
$this->assertEquals(
['type' => Database::VAR_STRING, 'format' => APP_DATABASE_ATTRIBUTE_EMAIL, 'size' => 254],
Attribute::resolve(['key' => 'email', 'type' => APP_DATABASE_ATTRIBUTE_EMAIL])
);
$this->assertEquals(
['type' => Database::VAR_STRING, 'format' => APP_DATABASE_ATTRIBUTE_IP, 'size' => 39],
Attribute::resolve(['key' => 'ip', 'type' => APP_DATABASE_ATTRIBUTE_IP])
);
$this->assertEquals(
['type' => Database::VAR_STRING, 'format' => APP_DATABASE_ATTRIBUTE_URL, 'size' => 2000],
Attribute::resolve(['key' => 'url', 'type' => APP_DATABASE_ATTRIBUTE_URL])
);
$this->assertEquals(
['type' => Database::VAR_STRING, 'format' => APP_DATABASE_ATTRIBUTE_ENUM, 'size' => Database::LENGTH_KEY],
Attribute::resolve(['key' => 'enum', 'type' => APP_DATABASE_ATTRIBUTE_ENUM])
);
}
public function testResolveKeepsExplicitSize(): void
{
$this->assertEquals(
['type' => Database::VAR_STRING, 'format' => APP_DATABASE_ATTRIBUTE_EMAIL, 'size' => 512],
Attribute::resolve(['key' => 'email', 'type' => APP_DATABASE_ATTRIBUTE_EMAIL, 'size' => 512])
);
$this->assertEquals(
['type' => Database::VAR_VARCHAR, 'format' => '', 'size' => 128],
Attribute::resolve(['key' => 'slug', 'type' => Database::VAR_VARCHAR, 'size' => 128])
);
}
}