single table inheritance with archivable PROBLEM #578

miszyman opened this Issue Jan 25, 2013 · 6 comments

3 participants


I'm want to use the single table inheritance and archivable on one table, but when i do so i receive an error with dependencies:
it looks like propel doesn't add:

use MyNamespace\MyClassQuery;
use MyNamespace\MyClassPeer;

to the base classes that inherit from MyClass (after i add these usings by myself its ok)

but that is not the only problem, after I add these usings and run the code i receive:
Call to undefined method: setArchivedAt
its on
BaseMyClass.php(4498): MyNamespace\MyOtherClass->setArchivedAt(1358894792)

line 4498 is $archive->setArchivedAt(time()); inside the archive() method

where MyOtherClass extends MyClass


I can confirm this issue. Is there any work-around without adding the use statements manuallly to the base class?

Propel member

Can you provide a schema.xml, please?


here is my schema:

    <table name="article">
        <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true"/>
        <column name="user_id" type="INTEGER" required="true"/>
        <column name="slug" type="VARCHAR" size="255"/>
        <column name="title" type="VARCHAR" size="255" required="true" primaryString="true"/>
        <column name="description" type="LONGVARCHAR"/>
        <column name="source" type="VARCHAR" size="255"/>
        <column name="score" type="INTEGER" required="true" defaultValue="0"/>
        <column name="score_sum" type="INTEGER" defaultValue="0"/>
        <column name="comment_count" type="INTEGER" defaultValue="0"/>
        <column name="has_image" type="BOOLEAN" required="true" defaultValue="false"/>
        <column name="image_identifier" type="VARCHAR" size="64"/>
        <column name="timestamp" type="INTEGER" required="true"/>

        <column name="type" type="VARCHAR" size="16" inheritance="single">
            <inheritance key="DEFAULT" class="Article"/>
            <inheritance key="SPONSORED" class="SponsoredArticle" extends="Article"/>

        <behavior name="aggregate_column_1">
            <parameter name="name" value="comment_count"/>
            <parameter name="foreign_table" value="article_comment"/>
            <parameter name="expression" value="COUNT(id)"/>

        <behavior name="aggregate_column_2">
            <parameter name="name" value="score_sum"/>
            <parameter name="foreign_table" value="article_vote"/>
            <parameter name="expression" value="SUM(score)"/>

        <behavior name="timestampable"/>
        <behavior name="query_cache"/>

        <behavior name="sluggable">
            <parameter name="slug_column" value="slug"/>
            <parameter name="slug_pattern" value="{Title}"/>
            <parameter name="permanent" value="true"/>

        <behavior name="archivable">
            <parameter name="archive_on_insert" value="false"/>
            <parameter name="archive_on_update" value="false"/>
            <parameter name="archive_on_delete" value="true"/>

        <foreign-key foreignTable="user">
            <reference local="user_id" foreign="id"/>

        <unique name="unique_slug">
            <unique-column name="slug"/>

i have to add manually the following into my BaseSponsoredArticleQuery

use Company\Bundle\ArticleBundle\Propel\ArticlePeer;
use Company\Bundle\ArticleBundle\Propel\ArticleQuery;
Propel member

@icyevilfantasy, I only see one table without the sponsored_article one. Can you provide please a full schema, so we can reproduce it easily?


i don't have a schema for sponsored_article because of inheritance="single" behavior. The table generates automatically in fact of this behavior.

Propel member

Ah, sorry overlooked that part. 😋

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