Login | Register
My pages Projects Community openCollabNet

Discussions > dev > Peer::doDelete() fails when using inheritance

Discussion topic

Back to topic list

Peer::doDelete() fails when using inheritance


Author noel guilbert <noelguilbert at gmail dot com>
Full name noel guilbert <noelguilbert at gmail dot com>
Date 2008-05-07 06:43:37 PDT
Message Hello,

I wanted to post this bug report in Trac, but it gets rejected as spam. So
I hope someone could post this bug report for me ;)

I'm using Propel with the symfony framework, and I'm annoyed with a bug when
I'm using inheritance.

Here is my schema.xml:

<?xml version="1.0" encoding="UTF-8"?>
<database package="lib.model.mail" name="propel" defaultIdMethod="native"

  <table name="mail_template" phpName="MailTemplate" isI18N="true"
    <column name="id" type="integer" required="true" primaryKey="true"
    <column name="status" type="char" size="3" required="true"/>
    <column name="plugin" type="integer" required="true"/>
    <column name="class_key" type="integer" inheritance="single">
      <inheritance key="1" class="AdminMailTemplate"/>
      <inheritance key="2" class="AffiliateMail​Template"/>
      <inheritance key="3" class="CustomerMailT​emplate"/>

  <table name="mail_template_i18n">
    <column name="id" type="integer" required="true" primaryKey="true"/>
    <column name="culture" type="varchar" size="7" required="true"
primaryKey="true" isCulture="true"/>
    <column name="subject" type="varchar" size="256"/>
    <column name="body" type="longvarchar"/>
    <column name="alternative_body" type="longvarchar"/>

    <foreign-key foreignTable="mail_t​emplate">
      <reference local="id" foreign="id" onDelete="CASCADE"/>


And here is my code:
$mailTemplate = new MailTemplate();


    // Deleting the object

My problem comes from the delete query, which is:

DELETE FROM mail_template WHERE mail_template.ID IN

As you can see, the query is performing a delete on a set of ids, instead of
the object id (14). The problem comes from the doDelete() method, which is
testing the object type before delete. In my case, $values is an
"AdminMailTemplate" object, which extends BaseMailTemplate, so it does a

public static function doDelete($values, $con = null)
  if ($con === null) {
    $con = Propel::getConnectio​n(MailTemplatePeer::​DATABASE_NAME);

  if ($values instanceof Criteria) {
    $criteria = clone $values;
  } elseif ($values instanceof MailTemplate) { // Should do this

    $criteria = $values->buildPk​eyCriteria();
  } else { // But does this
    $criteria = new Criteria(self::DATABASE_NAME);
    $criteria->add(M​ailTemplatePeer::ID,​ (array) $values, Criteria::IN);

I don't know what should be the best solution to fix this bug, but we could
change the test of the object type:

if ($value instanceof MailTemplate)


if ($value instanceof BaseMailTemplate)

Thank you!


« Previous message in topic | 1 of 1 | Next message in topic »


Show all messages in topic

Peer::doDelete() fails when using inheritance noel guilbert <noelguilbert at gmail dot com> noel guilbert <noelguilbert at gmail dot com> 2008-05-07 06:43:37 PDT
Messages per page: