From 229c7726344714187dad2641879cb9c4211cc85d Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 13 Oct 2010 16:04:28 -0700 Subject: Filter table definitions to scrub out unsupported features before trying to alter a table. This lets us skip those where we end up trying to change unsupported features. --- lib/pgsqlschema.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/pgsqlschema.php') diff --git a/lib/pgsqlschema.php b/lib/pgsqlschema.php index a8ce21b38..e8711a6f8 100644 --- a/lib/pgsqlschema.php +++ b/lib/pgsqlschema.php @@ -406,4 +406,29 @@ class PgsqlSchema extends Schema } } + /** + * Filter the given table definition array to match features available + * in this database. + * + * This lets us strip out unsupported things like comments, foreign keys, + * or type variants that we wouldn't get back from getTableDef(). + * + * @param array $tableDef + */ + function filterDef(array $tableDef) + { + foreach (array_keys($tableDef['fields']) as $name => &$col) { + // No convenient support for field descriptions + unset($col['description']); + + if (isset($col['size'])) { + // Don't distinguish between tinyint and int. + if ($col['size'] == 'tiny' && $col['type'] == 'int') { + unset($col['size']); + } + } + } + return $tableDef; + } + } -- cgit v1.2.3-54-g00ecf