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

Already on GitHub? Sign in to your account

Duplicate fields while using concrete_inheritance #448

Open
grisha87 opened this Issue Aug 15, 2012 · 0 comments

Comments

Projects
None yet
1 participant

Hi,

got an error at runtime

Fatal error: Cannot redeclare BaseUser::$collTransactionsRelatedByUserId

Tested on Propel 1.6.7

Type hierarchy

abstract class Entity

abstract class Transaction extends Entity

class Income extends Transaction

class Outcome extends Transaction

The User class is related (one to many) to Income and Outcome by Transaction and this - I think - is the reason of duplication.

I've also tried to reduce the abstraction level by reducing the hierarchy to the one shown below:

abstract class Transaction

class Income extends Transaction

class Outcome extends Transaction

The schema was processed with no errors and no duplication is occurs.

The failing schema

This one reproduces the problem (removed the abstraction attributes, since they're not the cause):

<?xml version="1.0" encoding="UTF-8"?>
<database name="foo">

    <table name="user">
        <column name="id" type="integer" primaryKey="true" autoIncrement="true" />
        <column name="login" type="varchar" size="256" />
        <column name="password" type="varchar" size="256" />
        <column name="name" type="varchar" size="256" />
        <column name="registered_at" type="timestamp" />
    </table>

    <table name="entity">
        <column name="id" type="integer" primaryKey="true" autoIncrement="true" />
        <column name="name" type="varchar" size="256" />
        <column name="description" type="varchar" size="512" />
        <column name="user_id" type="integer" />
        <foreign-key foreignTable="user">
            <reference local="user_id" foreign="id" />
        </foreign-key>
    </table>

    <table name="transaction">
        <column name="amount" type="float" />
        <column name="date" type="date" />
        <column name="user_id" type="integer" />
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="entity" />
        </behavior>
        <foreign-key foreignTable="user">
            <reference local="user_id" foreign="id" />
        </foreign-key>
        <behavior name="timestampable" />
    </table>

    <table name="outcome">
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="transaction" />
        </behavior>
    </table>

    <table name="income">
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="transaction" />
        </behavior>
    </table>

</database>

Reduced schema

This one works fine (reduced abstraction level)

<?xml version="1.0" encoding="UTF-8"?>
<database name="foo">

    <table name="user">
        <column name="id" type="integer" primaryKey="true" autoIncrement="true" />
        <column name="login" type="varchar" size="256" />
        <column name="password" type="varchar" size="256" />
        <column name="name" type="varchar" size="256" />
        <column name="registered_at" type="timestamp" />
    </table>

    <table name="transaction">
        <column name="id" type="integer" primaryKey="true" autoIncrement="true" />
        <column name="amount" type="float" />
        <column name="date" type="date" />
        <column name="user_id" type="integer" />
        <foreign-key foreignTable="user">
            <reference local="user_id" foreign="id" />
        </foreign-key>
        <behavior name="timestampable" />
    </table>

    <table name="outcome">
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="transaction" />
        </behavior>
    </table>

    <table name="income">
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="transaction" />
        </behavior>
    </table>

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