Skip to content

Commit

Permalink
Fixed #564 - build crashes when no primaryKey on autoIncrement column
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc J. Schmidt authored and Gregor Panek committed Aug 8, 2014
1 parent f64191b commit 295f828
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Expand Up @@ -5596,23 +5596,25 @@ protected function addDoInsertBodyRaw()

// if auto-increment, get the id after
if ($platform->isNativeIdMethodAutoIncrement() && $table->getIdMethod() == "native") {
$column = $table->getFirstPrimaryKeyColumn();
$script .= "
try {";
$script .= $platform->getIdentifierPhp('$pk', '$con', $primaryKeyMethodInfo);
$script .= "
} catch (Exception \$e) {
throw new PropelException('Unable to get autoincrement id.', 0, \$e);
}";
if ($table->isAllowPkInsert()) {
$script .= "
$column = $table->getFirstPrimaryKeyColumn();
if ($column) {
if ($table->isAllowPkInsert()) {
$script .= "
if (\$pk !== null) {
\$this->set".$column->getPhpName()."(\$pk);
}";
} else {
$script .= "
} else {
$script .= "
\$this->set".$column->getPhpName()."(\$pk);";
}
}
}
$script .= "
";
}
Expand Down

0 comments on commit 295f828

Please sign in to comment.