DDC-2119: Problem with inheritance type: INHERITANCE_TYPE_NONE and INHERITANCE_TYPE_TABLE_PER_CLASS #2670

Open
opened 2026-01-22 13:59:47 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 3, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user sergsw:

I tried to create inheritance entities with save policy table per class.
Simple fileds was created normally, but a field with ManyToOne type was lost.

I had found a solution.

In Doctrine\ORM\Tools\SchemaTool
...

private function _gatherRelationsSql($class, $table, $schema)
    {
        foreach ($class->associationMappings as $fieldName => $mapping) {

           // if (isset($mapping['inherited'])) { // - old version

    /****
             * SSW
             * It's the solution
             */
    if (isset($mapping['inherited']) && !$class->isInheritanceTypeNone() && !$class->isInheritanceTypeTablePerClass() ) {
                continue;
            }            

            $foreignClass = $this->_em->getClassMetadata($mapping['targetEntity']);
...

But it was enough. In DQL query a simple query was made wrong.

I had found a solution again.
In Doctrine\ORM\Query\SqlWalker
...

public function walkSelectExpression($selectExpression)
...

                // original => if (isset($mapping['inherited'])){
                // It's the solution
                if (isset($mapping['inherited']) && !$class->isInheritanceTypeNone() && !$class->isInheritanceTypeTablePerClass()) {
                    $tableName = $this->_em->getClassMetadata($mapping['inherited'])->table['name'];
                } else {
                    $tableName = $class->table['name'];
                }
...

This problems are topical for inheritance type: INHERITANCE_TYPE_NONE and INHERITANCE_TYPE_TABLE_PER_CLASS.

I don't know, may be my solutions are wrong. But some programmers want to correctly work with INHERITANCE_TYPE_TABLE_PER_CLASS.

Sorry for my english.

Originally created by @doctrinebot on GitHub (Nov 3, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user sergsw: I tried to create inheritance entities with save policy table per class. Simple fileds was created normally, but a field with ManyToOne type was lost. I had found a solution. In Doctrine\ORM\Tools\SchemaTool ... ``` private function _gatherRelationsSql($class, $table, $schema) { foreach ($class->associationMappings as $fieldName => $mapping) { // if (isset($mapping['inherited'])) { // - old version /**** * SSW * It's the solution */ if (isset($mapping['inherited']) && !$class->isInheritanceTypeNone() && !$class->isInheritanceTypeTablePerClass() ) { continue; } $foreignClass = $this->_em->getClassMetadata($mapping['targetEntity']); ... ``` But it was enough. In DQL query a simple query was made wrong. I had found a solution again. In Doctrine\ORM\Query\SqlWalker ... ``` public function walkSelectExpression($selectExpression) ... // original => if (isset($mapping['inherited'])){ // It's the solution if (isset($mapping['inherited']) && !$class->isInheritanceTypeNone() && !$class->isInheritanceTypeTablePerClass()) { $tableName = $this->_em->getClassMetadata($mapping['inherited'])->table['name']; } else { $tableName = $class->table['name']; } ... ``` This problems are topical for inheritance type: INHERITANCE_TYPE_NONE and INHERITANCE_TYPE_TABLE_PER_CLASS. I don't know, may be my solutions are wrong. But some programmers want to correctly work with INHERITANCE_TYPE_TABLE_PER_CLASS. Sorry for my english.
admin added the Bug label 2026-01-22 13:59:47 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 5, 2012):

Comment created by @FabioBatSilva:

Hi SergSW

Could you try to write a failing test case ?

Thanks

@doctrinebot commented on GitHub (Nov 5, 2012): Comment created by @FabioBatSilva: Hi SergSW Could you try to write a failing test case ? Thanks
Author
Owner

@doctrinebot commented on GitHub (Nov 6, 2012):

Comment created by sergsw:

SSW/TestBundle with the problem

@doctrinebot commented on GitHub (Nov 6, 2012): Comment created by sergsw: SSW/TestBundle with the problem
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2012):

Comment created by sergsw:

I install the Symfony v2.0.18. and made small TestBundle.
I made schema database, by CLI "console doctrine:schema:update --force"
Result: Database schema updated successfully!
But I saw that I lost a field 'user_id' in a table 'AttachTree' (see Attach)

@doctrinebot commented on GitHub (Nov 7, 2012): Comment created by sergsw: I install the Symfony v2.0.18. and made small TestBundle. I made schema database, by CLI "console doctrine:schema:update --force" Result: Database schema updated successfully! But I saw that I lost a field 'user_id' in a table 'AttachTree' (see Attach)
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2012):

Comment created by sergsw:

MySQL dump

@doctrinebot commented on GitHub (Nov 7, 2012): Comment created by sergsw: MySQL dump
Author
Owner

@doctrinebot commented on GitHub (Nov 12, 2012):

Comment created by @beberlei:

Adjusted example formatting, don't apologize for your English, thanks for the report!

@doctrinebot commented on GitHub (Nov 12, 2012): Comment created by @beberlei: Adjusted example formatting, don't apologize for your English, thanks for the report!
Author
Owner

@doctrinebot commented on GitHub (Dec 24, 2012):

Comment created by @beberlei:

What version of 2.1 are you using? We don't actually support 2.1 anymore. Inheritance has always worked as used in hundrets of unit-tests, this changes look quite major a bug to have been missed before. I can't really explain whats happening here.

@doctrinebot commented on GitHub (Dec 24, 2012): Comment created by @beberlei: What version of 2.1 are you using? We don't actually support 2.1 anymore. Inheritance has always worked as used in hundrets of unit-tests, this changes look quite major a bug to have been missed before. I can't really explain whats happening here.
Author
Owner

@doctrinebot commented on GitHub (Jan 23, 2013):

Comment created by @ocramius:

[~sergsw] news?

@doctrinebot commented on GitHub (Jan 23, 2013): Comment created by @ocramius: [~sergsw] news?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2670