Development

#1108 (sfPropelData::dumpData() ignores data from tables with composite PKs)

You must first sign up to be able to contribute.

Ticket #1108 (new defect)

Opened 2 years ago

Last modified 1 year ago

sfPropelData::dumpData() ignores data from tables with composite PKs

Reported by: donharold Assigned to: fabien
Priority: major Milestone:
Component: model Version:
Keywords: Cc:
Qualification:

Description

Tables with composite primary keys, or tables where a PK is also an FK, are not dumped by the sfPropelData::dumpData() method.

The source of the problem seems to be the handling of PKs and FKs in this part of sfPropelData (r2730, starting at line 298):

if ($column->isPrimaryKey())
{o
  $pk .= '_' .$rs->get($col);
  continue;
}
else if ($column->isForeignKey())
{
  $relatedTable = $this->maps[$table]->getDatabaseMap()->getTable($column->getRelatedTableName());

  $dumpData[$table][$table.$pk][$col] = $relatedTable->getPhpName().'_'.$rs->get($col);
}
else
{
  $dumpData[$table][$table.$pk][$col] = $rs->get($col);
}

Changing this will require changing the corresponding part of the loadData() method as well.

Parsing composite PKs back from the current dump format might be ambiguous. At the moment, the PK is appended to the class name after an underscore in the YML file. since PKs and class names can contain underscores, extracting composite PKs from the current dump format would not be possible in these cases.

Change History

11/17/06 15:28:04 changed by donharold

Correction: As long as no part of a composite PKs is also an FK, the data is dumped correctly, although the comment about PK ambiguity when parsing the YML back still stands.

The dump is skipped when a PK is also an FK - a good example is a simple n:m table as described in http://propel.phpdb.org/trac/wiki/Users/Documentation/1.2/ManyToManyRelationships.

02/21/07 14:45:08 changed by francois

  • owner set to fabien.
  • version deleted.
  • component set to model.