protected function Schema::processField

protected Schema::processField($field)

Set database-engine specific properties for a field.

Parameters

$field: A field description array, as specified in the schema documentation.

File

core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php, line 118

Class

Schema
SQLite implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\Core\Database\Driver\sqlite

Code

protected function processField($field) {
  if (!isset($field['size'])) {
    $field['size'] = 'normal';
  }

  // Set the correct database-engine specific datatype.
  // In case one is already provided, force it to uppercase.
  if (isset($field['sqlite_type'])) {
    $field['sqlite_type'] = Unicode::strtoupper($field['sqlite_type']);
  }
  else {
    $map = $this->getFieldTypeMap();
    $field['sqlite_type'] = $map[$field['type'] . ':' . $field['size']];

    // Numeric fields with a specified scale have to be stored as floats.
    if ($field['sqlite_type'] === 'NUMERIC' && isset($field['scale'])) {
      $field['sqlite_type'] = 'FLOAT';
    }
  }

  if (isset($field['type']) && $field['type'] == 'serial') {
    $field['auto_increment'] = TRUE;
  }

  return $field;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Database!Driver!sqlite!Schema.php/function/Schema::processField/8.1.x