protected function Schema::getMssqlCollation in Drupal driver for SQL Server and SQL Azure 8.2
Determine what the correct sql server collation is for a specific field.
Parameters
array $field: The field specification
1 call to Schema::getMssqlCollation()
- Schema::processField in drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php - Set database-engine specific properties for a field.
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Schema.php, line 512 - Definition of Drupal\Driver\Database\sqlsrv\Schema
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
protected function getMssqlCollation(array $field) {
// The ascii_bin type is just a text field with a special collation,
// it is the fastest collation available on MSSQL Server to compare string
// as it does this at the binary level.
if (in_array($field['type'], [
'ascii_bin',
'varchar_ascii',
])) {
return self::DEFAULT_COLLATION_BINARY;
}
// The collation property is out of specification,
// but used sometimes in contrib (such as advagg).
if (!empty($field['collation'])) {
// Try to match to an SQL Server collation
switch ($field['collation']) {
case 'ascii_bin':
return self::DEFAULT_COLLATION_BINARY;
}
}
// Temporary workaround for issue in core.
// @see https://www.drupal.org/node/2580671
// TODO: Remove when this is fixed in core.
$mysqltype = $field['mysql_type'] ?? null;
if ($mysqltype === 'blob') {
return self::DEFAULT_COLLATION_BINARY;
}
// Finally, use CS or CI
$binary = $field['binary'] ?? false;
return $binary ? self::DEFAULT_COLLATION_CS : self::DEFAULT_COLLATION_CI;
}