You are here

public function Schema::getFieldTypeMap in Drupal 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Database/Schema.php \Drupal\Core\Database\Schema::getFieldTypeMap()
  2. 8 core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php \Drupal\Core\Database\Driver\sqlite\Schema::getFieldTypeMap()
  3. 8 core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema::getFieldTypeMap()
  4. 8 core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::getFieldTypeMap()
Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema::getFieldTypeMap()

Returns a mapping of Drupal schema field names to DB-native field types.

Because different field types do not map 1:1 between databases, Drupal has its own normalized field type names. This function returns a driver-specific mapping table from Drupal names to the native names for each database.

Return value

array An array of Schema API field types to driver-specific field types.

Overrides Schema::getFieldTypeMap

1 call to Schema::getFieldTypeMap()
Schema::processField in core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
Set database-engine specific properties for a field.

File

core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php, line 416

Class

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

Namespace

Drupal\Core\Database\Driver\pgsql

Code

public function getFieldTypeMap() {

  // Put :normal last so it gets preserved by array_flip. This makes
  // it much easier for modules (such as schema.module) to map
  // database types back into schema types.
  // $map does not use drupal_static as its value never changes.
  static $map = [
    'varchar_ascii:normal' => 'varchar',
    'varchar:normal' => 'varchar',
    'char:normal' => 'character',
    'text:tiny' => 'text',
    'text:small' => 'text',
    'text:medium' => 'text',
    'text:big' => 'text',
    'text:normal' => 'text',
    'int:tiny' => 'smallint',
    'int:small' => 'smallint',
    'int:medium' => 'int',
    'int:big' => 'bigint',
    'int:normal' => 'int',
    'float:tiny' => 'real',
    'float:small' => 'real',
    'float:medium' => 'real',
    'float:big' => 'double precision',
    'float:normal' => 'real',
    'numeric:normal' => 'numeric',
    'blob:big' => 'bytea',
    'blob:normal' => 'bytea',
    'serial:tiny' => 'serial',
    'serial:small' => 'serial',
    'serial:medium' => 'serial',
    'serial:big' => 'bigserial',
    'serial:normal' => 'serial',
  ];
  return $map;
}