Skip to content
Browse files

Merge pull request #169 from K-Phoen/port-pr-302

Fix: port PR #302 from Propel
  • Loading branch information...
2 parents beae90b + c658cc0 commit f7e1af99939a5034b625554d57a79ab5822116c9 @willdurand willdurand committed Mar 30, 2012
View
23 src/Propel/Generator/Platform/MysqlPlatform.php
@@ -249,17 +249,22 @@ protected function getTableOptions(Table $table)
'RowFormat' => 'ROW_FORMAT',
'Union' => 'UNION',
);
+
foreach ($supportedOptions as $name => $sqlName) {
+ $parameterValue = NULL;
+
if ($vi->hasParameter($name)) {
- $tableOptions[] = sprintf('%s=%s',
- $sqlName,
- $this->quote($vi->getParameter($name))
- );
- } elseif ($vi->hasParameter($sqlName)) {
- $tableOptions[] = sprintf('%s=%s',
- $sqlName,
- $this->quote($vi->getParameter($sqlName))
- );
+ $parameterValue = $vi->getParameter( $name );
+ } else if ($vi->hasParameter($sqlName)) {
+ $parameterValue = $vi->getParameter( $sqlName );
+ }
+
+ // if we have a param value, then parse it out
+ if (!is_null($parameterValue)) {
+ // if the value is numeric, then there is no need for quotes
+ $parameterValue = is_numeric($parameterValue) ? $parameterValue : $this->quote($parameterValue);
+
+ $tableOptions [] = sprintf('%s=%s', $sqlName, $parameterValue);
}
}
View
3 tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php
@@ -369,6 +369,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>
@@ -379,7 +380,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 f7e1af9

Please sign in to comment.
Something went wrong with that request. Please try again.