Skip to content
This repository

Fix: port PR #302 from Propel #169

Merged
merged 1 commit into from over 2 years ago

2 participants

Kévin Gomez William Durand
Kévin Gomez

Propel2 issue: #146
Original PR: propelorm/Propel#302

William Durand willdurand merged commit f7e1af9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 30, 2012
Kévin Gomez K-Phoen Fix: port PR #302 from Propel c658cc0
This page is out of date. Refresh to see the latest.
23 src/Propel/Generator/Platform/MysqlPlatform.php
@@ -249,17 +249,22 @@ protected function getTableOptions(Table $table)
249 249 'RowFormat' => 'ROW_FORMAT',
250 250 'Union' => 'UNION',
251 251 );
  252 +
252 253 foreach ($supportedOptions as $name => $sqlName) {
  254 + $parameterValue = NULL;
  255 +
253 256 if ($vi->hasParameter($name)) {
254   - $tableOptions[] = sprintf('%s=%s',
255   - $sqlName,
256   - $this->quote($vi->getParameter($name))
257   - );
258   - } elseif ($vi->hasParameter($sqlName)) {
259   - $tableOptions[] = sprintf('%s=%s',
260   - $sqlName,
261   - $this->quote($vi->getParameter($sqlName))
262   - );
  257 + $parameterValue = $vi->getParameter( $name );
  258 + } else if ($vi->hasParameter($sqlName)) {
  259 + $parameterValue = $vi->getParameter( $sqlName );
  260 + }
  261 +
  262 + // if we have a param value, then parse it out
  263 + if (!is_null($parameterValue)) {
  264 + // if the value is numeric, then there is no need for quotes
  265 + $parameterValue = is_numeric($parameterValue) ? $parameterValue : $this->quote($parameterValue);
  266 +
  267 + $tableOptions [] = sprintf('%s=%s', $sqlName, $parameterValue);
263 268 }
264 269 }
265 270
3  tests/Propel/Tests/Generator/Platform/MysqlPlatformTest.php
@@ -369,6 +369,7 @@ public function testGetAddTableDDLVendor()
369 369 <vendor type="mysql">
370 370 <parameter name="Engine" value="InnoDB"/>
371 371 <parameter name="Charset" value="utf8"/>
  372 + <parameter name="AutoIncrement" value="1000"/>
372 373 </vendor>
373 374 </table>
374 375 </database>
@@ -379,7 +380,7 @@ public function testGetAddTableDDLVendor()
379 380 (
380 381 `id` INTEGER NOT NULL AUTO_INCREMENT,
381 382 PRIMARY KEY (`id`)
382   -) ENGINE=InnoDB CHARACTER SET='utf8';
  383 +) ENGINE=InnoDB AUTO_INCREMENT=1000 CHARACTER SET='utf8';
383 384 ";
384 385 $this->assertEquals($expected, $this->getPlatform()->getAddTableDDL($table));
385 386 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.