Concrete Table Inheritance with namespace #480

Closed
rennis23 opened this Issue Oct 2, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@rennis23

rennis23 commented Oct 2, 2012

Concrete Table Inheritance with namespace doesn't work.

Test schema:

<table name="test_page">
    <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/>
    <column name="url" type="VARCHAR" size="255"/>
</table>
<table name="test_article">
    <behavior name="concrete_inheritance">
        <parameter name="extends" value="test_page" />
    </behavior>
    <column name="content" type="VARCHAR" size="255"/>
</table>

PHP code:
/**
* Prepare test data
*/
$testArticle = new \Etechnika\CoreBundle\Model\TestArticle();
$testArticle->setUrl( 'aaa'.rand( 1000, 9999 ) );
$testArticle->setContent( 'aaaaaa' );
$testArticle->save();

    /**
     * Error 1
     * 
     * Test code with missing use
     * Fatal error - Fatal error: Class 'Etechnika\CoreBundle\Model\om\PropelQuery' not found in ..../Etechnika/CoreBundle/Model/om/BaseTestPage.php 
     */
    foreach(\Etechnika\CoreBundle\Model\TestPageQuery::create()->find() as $testPage) {
        var_dump( $testPage->getChildObject() );
    }


    /**
     * Error 2 
     * 
     * Test code after fix error 1
     * Exception - Cannot find a query class for TestArticle
     */
    foreach(\Etechnika\CoreBundle\Model\TestPageQuery::create()->find() as $testPage) {
        var_dump( $testPage->getChildObject() );
    }

I think that saving name of the class within namespace in a column 'descendant_class' in Table Inheritance resolves that problem.

@rennis23

This comment has been minimized.

Show comment Hide comment
@rennis23

rennis23 Oct 11, 2012

Fix for error 1 (missing PropelQuery).

File:
generator/lib/builder/om/PHP5ObjectBuilder.php
Fix:
Add to call "declareClasses" argument "PropelQuery" in method "addClassBody":

Code after change.
$this->declareClasses(
'Propel', 'PropelException', 'PDO', 'PropelPDO', 'Criteria',
'BaseObject', 'Persistent', 'BasePeer', 'PropelCollection',
'PropelObjectCollection', 'Exception', 'PropelQuery'
);

Fix for error 1 (missing PropelQuery).

File:
generator/lib/builder/om/PHP5ObjectBuilder.php
Fix:
Add to call "declareClasses" argument "PropelQuery" in method "addClassBody":

Code after change.
$this->declareClasses(
'Propel', 'PropelException', 'PDO', 'PropelPDO', 'Criteria',
'BaseObject', 'Persistent', 'BasePeer', 'PropelCollection',
'PropelObjectCollection', 'Exception', 'PropelQuery'
);

@jpetitcolas

This comment has been minimized.

Show comment Hide comment
@jpetitcolas

jpetitcolas Oct 24, 2012

Contributor

I had the same issue, as referenced in the following closed (because of the wrong repository) ticket: propelorm/PropelBundle#162

Contributor

jpetitcolas commented Oct 24, 2012

I had the same issue, as referenced in the following closed (because of the wrong repository) ticket: propelorm/PropelBundle#162

willdurand added a commit that referenced this issue Oct 25, 2012

Merge pull request #490 from jpetitcolas/master
Fix issue #480 with concrete_inheritance and namespace

@willdurand willdurand closed this Oct 25, 2012

cedriclombardot added a commit to donkeycode/Propel that referenced this issue Oct 8, 2015

cedriclombardot added a commit to donkeycode/Propel that referenced this issue Oct 8, 2015

Merge pull request #1 from donkeycode/fix-concrete-namespace
Fix concrete inheritance with namespaces related to #480 & #490
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment