Commit 250b4a41 authored by Jasper N. Brouwer's avatar Jasper N. Brouwer Committed by Alexander

Add support for all MySql BLOB type declarations

Choose between TINYBLOB, BLOB, MEDIUMBLOB and LONGBLOB based on the length of the field.
Behaves the same way as the TEXT type declaration.
parent 930ec9af
...@@ -710,10 +710,34 @@ class MySqlPlatform extends AbstractPlatform ...@@ -710,10 +710,34 @@ class MySqlPlatform extends AbstractPlatform
} }
/** /**
* {@inheritDoc} * Gets the SQL Snippet used to declare a BLOB column type.
* TINYBLOB : 2 ^ 8 - 1 = 255
* BLOB : 2 ^ 16 - 1 = 65535
* MEDIUMBLOB : 2 ^ 24 - 1 = 16777215
* LONGBLOB : 2 ^ 32 - 1 = 4294967295
*
* @param array $field
*
* @return string
*/ */
public function getBlobTypeDeclarationSQL(array $field) public function getBlobTypeDeclarationSQL(array $field)
{ {
if ( ! empty($field['length']) && is_numeric($field['length'])) {
$length = $field['length'];
if ($length <= 255) {
return 'TINYBLOB';
}
if ($length <= 65535) {
return 'BLOB';
}
if ($length <= 16777215) {
return 'MEDIUMBLOB';
}
}
return 'LONGBLOB'; return 'LONGBLOB';
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment