Propel archivable behavior doesn't work properly (archived_at column doesn't get updated on insert) #309

Closed
melekes opened this Issue Mar 6, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@melekes
Contributor

melekes commented Mar 6, 2012

I have some problems with the Propel's archivable behavior. For some reasons, Propel doesn't set archived_at field to the current datetime when the object is being archived.

My schema:

SeminarCustomer:
  tableName:          seminar_customer
  columns:
    id:              { type: integer, required: true, primaryKey: true, foreignClass: Customer, foreignReference: id, onDelete: cascade }
    ...
   office_id:       { type: integer, required: false, foreignTable: office, foreignReference: id }
   entity_id:       { type: integer, required: true, default: 1 }
   propel_behaviors:
     timestampable:   ~
     archivable:      ~

SeminarCustomer::archive method:

public function archive(PropelPDO $con = null)
{
  if ($this->isNew()) {
    throw new PropelException('New objects cannot be archived. You must save the current object before calling archive().');
  }
  if (!$archive = $this->getArchive($con)) {
    $archive = new SeminarCustomerArchive();
    $archive->setPrimaryKey($this->getPrimaryKey());
  }
  $this->copyInto($archive, $deepCopy = false, $makeNew = false);
  // NOTE: here should be $archive->setArchivedAt(time());
  $archive->save($con);

  return $archive;
}

archived_at column definitely exists in my seminar_customer_archive table.

Symfony: 1.4.17-DEV
Propel: 1.6.3

melekes added a commit to melekes/Propel that referenced this issue Mar 6, 2012

@melekes

This comment has been minimized.

Show comment Hide comment
@melekes

melekes Mar 6, 2012

Contributor

I've attached unit test and the bugfix. Could you please take a look at it. Thank you for your time.

Contributor

melekes commented Mar 6, 2012

I've attached unit test and the bugfix. Could you please take a look at it. Thank you for your time.

@willdurand

This comment has been minimized.

Show comment Hide comment
@willdurand

willdurand Mar 6, 2012

Member

Can you open a PR with your fix? We'll be able to discuss it in a better way then

Member

willdurand commented Mar 6, 2012

Can you open a PR with your fix? We'll be able to discuss it in a better way then

melekes added a commit to melekes/Propel that referenced this issue Mar 8, 2012

@willdurand willdurand closed this Dec 28, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment