Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Database/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,26 @@ abstract public function getInternalIndexesKeys(): array;
*/
abstract public function getSchemaAttributes(string $collection): array;

/**
* Get the expected column type for a given attribute type.
*
* Returns the database-native column type string (e.g. "VARCHAR(255)", "BIGINT")
* that would be used when creating a column for the given attribute parameters.
* Returns an empty string if the adapter does not support this operation.
*
* @param string $type
* @param int $size
* @param bool $signed
* @param bool $array
* @param bool $required
* @return string
* @throws \Utopia\Database\Exception For unknown types on adapters that support column-type resolution.
*/
public function getColumnType(string $type, int $size, bool $signed = true, bool $array = false, bool $required = false): string
{
return '';
}

/**
* Get the query to check for tenant when in shared tables mode
*
Expand Down
8 changes: 8 additions & 0 deletions src/Database/Adapter/SQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,14 @@ abstract protected function getSQLType(
bool $required = false
): string;

/**
* @throws DatabaseException For unknown type values.
*/
public function getColumnType(string $type, int $size, bool $signed = true, bool $array = false, bool $required = false): string
{
return $this->getSQLType($type, $size, $signed, $array, $required);
}

/**
* Get SQL Index Type
*
Expand Down
Loading