Permalink
Browse files

Fix MySQL quote issue for table options. Closes #301

  • Loading branch information...
rncain authored and willdurand committed Feb 25, 2012
1 parent 2923a3b commit 841448e08dd7898a7dd57504f4a602283770bb30
@@ -235,18 +235,20 @@ protected function getTableOptions(Table $table)
'Union' => 'UNION',
);
foreach ($supportedOptions as $name => $sqlName) {
+ $parameterValue = NULL;
+
if ($vi->hasParameter($name)) {
- $tableOptions []= sprintf('%s=%s',
- $sqlName,
- $this->quote($vi->getParameter($name))
- );
+ $parameterValue = $vi->getParameter($name);
} elseif ($vi->hasParameter($sqlName)) {
- $tableOptions []= sprintf('%s=%s',
- $sqlName,
- $this->quote($vi->getParameter($sqlName))
- );
+ $parameterValue = $vi->getParameter($sqlName);
+ }
+
+ if (!is_null($parameterValue)) {
+ $parameterValue = is_numeric($parameterValue) ? $parameterValue : $this->quote($parameterValue);
+ $tableOptions[] = sprintf('%s=%s', $sqlName, $parameterValue);
}
}
+
return $tableOptions;
}
@@ -363,6 +363,7 @@ public function testGetAddTableDDLVendor()
<vendor type="mysql">
<parameter name="Engine" value="InnoDB"/>
<parameter name="Charset" value="utf8"/>
+ <parameter name="AutoIncrement" value="1000"/>
</vendor>
</table>
</database>
@@ -373,7 +374,7 @@ public function testGetAddTableDDLVendor()
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB CHARACTER SET='utf8';
+) ENGINE=InnoDB AUTO_INCREMENT=1000 CHARACTER SET='utf8';
";
$this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table));
}

0 comments on commit 841448e

Please sign in to comment.