function Schema::processField

Same name in this branch
  1. 11.x core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::processField()
  2. 11.x core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::processField()
Same name in other branches
  1. 9 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::processField()
  2. 9 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::processField()
  3. 9 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::processField()
  4. 8.9.x core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::processField()
  5. 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::processField()
  6. 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema::processField()
  7. 10 core/modules/sqlite/src/Driver/Database/sqlite/Schema.php \Drupal\sqlite\Driver\Database\sqlite\Schema::processField()
  8. 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::processField()
  9. 10 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::processField()

Set database-engine specific properties for a field.

Parameters

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

2 calls to Schema::processField()
Schema::addField in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Schema::createColumnsSql in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Build the SQL expression for creating columns.

File

core/modules/sqlite/src/Driver/Database/sqlite/Schema.php, line 124

Class

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

Namespace

Drupal\sqlite\Driver\Database\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'] = mb_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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.