Drop reverseTypeMap from schemas; we're now doing the forward-mapping on the canonical def before comparing
This commit is contained in:
parent
e44f1fe989
commit
a923ef9719
@ -96,13 +96,6 @@ class MysqlSchema extends Schema
|
|||||||
|
|
||||||
// warning -- 'unsigned' attr on numbers isn't given in DATA_TYPE and friends.
|
// warning -- 'unsigned' attr on numbers isn't given in DATA_TYPE and friends.
|
||||||
// It is stuck in on COLUMN_TYPE though (eg 'bigint(20) unsigned')
|
// It is stuck in on COLUMN_TYPE though (eg 'bigint(20) unsigned')
|
||||||
/*
|
|
||||||
list($type, $size) = $this->reverseMapType($row['DATA_TYPE']);
|
|
||||||
$field['type'] = $type;
|
|
||||||
if ($size !== null) {
|
|
||||||
$field['size'] = $size;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$field['type'] = $type = $row['DATA_TYPE'];
|
$field['type'] = $type = $row['DATA_TYPE'];
|
||||||
|
|
||||||
if ($type == 'char' || $type == 'varchar') {
|
if ($type == 'char' || $type == 'varchar') {
|
||||||
@ -487,37 +480,6 @@ class MysqlSchema extends Schema
|
|||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map a MySQL native type back to an independent type + size
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
* @return array ($type, $size) -- $size may be null
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
protected function reverseMapType($type)
|
|
||||||
{
|
|
||||||
$type = strtolower($type);
|
|
||||||
$map = array(
|
|
||||||
'decimal' => array('numeric', null),
|
|
||||||
'tinyint' => array('int', 'tiny'),
|
|
||||||
'smallint' => array('int', 'small'),
|
|
||||||
'mediumint' => array('int', 'medium'),
|
|
||||||
'bigint' => array('int', 'big'),
|
|
||||||
'tinyblob' => array('blob', 'tiny'),
|
|
||||||
'mediumblob' => array('blob', 'medium'),
|
|
||||||
'longblob' => array('blob', 'long'),
|
|
||||||
'tinytext' => array('text', 'tiny'),
|
|
||||||
'mediumtext' => array('text', 'medium'),
|
|
||||||
'longtext' => array('text', 'long'),
|
|
||||||
);
|
|
||||||
if (isset($map[$type])) {
|
|
||||||
return $map[$type];
|
|
||||||
} else {
|
|
||||||
return array($type, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
function typeAndSize($column)
|
function typeAndSize($column)
|
||||||
{
|
{
|
||||||
if ($column['type'] == 'enum') {
|
if ($column['type'] == 'enum') {
|
||||||
|
@ -81,15 +81,6 @@ class PgsqlSchema extends Schema
|
|||||||
$orderedFields[$row['ordinal_position']] = $name;
|
$orderedFields[$row['ordinal_position']] = $name;
|
||||||
|
|
||||||
$field = array();
|
$field = array();
|
||||||
|
|
||||||
// ??
|
|
||||||
/*
|
|
||||||
list($type, $size) = $this->reverseMapType($row['udt_name']);
|
|
||||||
$field['type'] = $type;
|
|
||||||
if ($size !== null) {
|
|
||||||
$field['size'] = $size;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$field['type'] = $row['udt_name'];
|
$field['type'] = $row['udt_name'];
|
||||||
|
|
||||||
if ($type == 'char' || $type == 'varchar') {
|
if ($type == 'char' || $type == 'varchar') {
|
||||||
@ -366,12 +357,16 @@ class PgsqlSchema extends Schema
|
|||||||
$type = $map[$type];
|
$type = $map[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($column['size'])) {
|
if ($type == 'int') {
|
||||||
$size = $column['size'];
|
if (!empty($column['size'])) {
|
||||||
if ($type == 'int' &&
|
$size = $column['size'];
|
||||||
in_array($size, array('small', 'big'))) {
|
if ($size == 'small') {
|
||||||
$type = $size . 'int';
|
return 'int2';
|
||||||
|
} else if ($size == 'big') {
|
||||||
|
return 'int8';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return 'int4';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $type;
|
return $type;
|
||||||
@ -388,27 +383,6 @@ class PgsqlSchema extends Schema
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map a native type back to an independent type + size
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
* @return array ($type, $size) -- $size may be null
|
|
||||||
*/
|
|
||||||
protected function reverseMapType($type)
|
|
||||||
{
|
|
||||||
$type = strtolower($type);
|
|
||||||
$map = array(
|
|
||||||
'int4' => array('int', null),
|
|
||||||
'int8' => array('int', 'big'),
|
|
||||||
'bytea' => array('blob', null),
|
|
||||||
);
|
|
||||||
if (isset($map[$type])) {
|
|
||||||
return $map[$type];
|
|
||||||
} else {
|
|
||||||
return array($type, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the given table definition array to match features available
|
* Filter the given table definition array to match features available
|
||||||
* in this database.
|
* in this database.
|
||||||
|
@ -772,23 +772,6 @@ class Schema
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Map a native type back to an independent type + size
|
|
||||||
*
|
|
||||||
* @param string $type
|
|
||||||
* @return array ($type, $size) -- $size may be null
|
|
||||||
*/
|
|
||||||
protected function reverseMapType($type)
|
|
||||||
{
|
|
||||||
$sizes = array('tiny', 'small', 'medium', 'big');
|
|
||||||
foreach ($sizes as $prefix) {
|
|
||||||
if (substr($type, 0, strlen($prefix)) == $prefix) {
|
|
||||||
return array(substr($type, strlen($prefix)), $prefix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return array($type, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an old-style set of ColumnDef objects into the current
|
* Convert an old-style set of ColumnDef objects into the current
|
||||||
* Drupal-style schema definition array, for backwards compatibility
|
* Drupal-style schema definition array, for backwards compatibility
|
||||||
|
Loading…
x
Reference in New Issue
Block a user