Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving related objects #1485

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/Propel/Generator/Behavior/Archivable/ArchivableBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class ArchivableBehavior extends Behavior
'archive_table' => '',
'archive_phpname' => null,
'archive_class' => '',
'archive_foreign_keys' => 'false',
'archive_foreign_keys_skip_sql' => 'true',
'log_archived_at' => 'true',
'archived_at_column' => 'archived_at',
'archive_on_insert' => 'false',
Expand Down Expand Up @@ -99,7 +101,15 @@ protected function addArchiveTable()
'type' => 'TIMESTAMP'
]);
}
// do not copy foreign keys
// copy foreign keys if enabled in parameters
if ($this->getParameter('archive_foreign_keys') == 'true') {
foreach ($table->getForeignKeys() as $foreignKey) {
$copiedForeignKey = clone $foreignKey;
// database foreing keys are not required
$copiedForeignKey->setSkipSql($this->getParameter('archive_foreign_keys_skip_sql') == 'true');
$archiveTable->addForeignKey($copiedForeignKey);
}
}
// copy the indices
foreach ($table->getIndices() as $index) {
$copiedIndex = clone $index;
Expand Down
2 changes: 2 additions & 0 deletions src/Propel/Generator/Builder/Om/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4258,6 +4258,8 @@ public function set{$relatedName}(Collection \${$inputCollection}, ConnectionInt
\$this->{$collName} = \${$inputCollection};
\$this->{$collName}Partial = false;

\$this->modifiedColumns[\"{$collName}\"] = true;

return \$this;
}
";
Expand Down