Problem to update DiscriminatorColumn name #5259

Open
opened 2026-01-22 15:02:48 +01:00 by admin · 1 comment
Owner

Originally created by @Gowsan10 on GitHub (Sep 15, 2016).

Hello,
I have a problem on update DiscriminatorColumn name

Entities:

/**
 *@ORM\Entity
 *@ORM\Table(name="item")
 *@ORM\InheritanceType("JOINED")
 *@ORM\DiscriminatorColumn(name="item_type", type="string")
 */
abstract class Item
{

}


/**
 *@ORM\Entity
 *@ORM\Table(name="product")
 *@ORM\InheritanceType("JOINED")
 */
abstract class Product extends Item
{

}

/**
 *@ORM\Entity
 *@ORM\Table(name="vehicle")
 *@ORM\InheritanceType("JOINED")
 */
abstract class Vehicle extends ItemBundle\Product
{

}


/**
 *@ORM\Entity(repositoryClass="Aussiito\Bundles\VehicleBundle\Entity\Repository\CarRepository")
 *@ORM\Table(name="car")
 */
class Car extends Vehicle
{
}


class CarRepository extends EntityRepository
{

    public function getListCars(){
        return $this->findAll();

    }
}**

Before I didn't add the annotation: @ORM\DiscriminatorColumn(name="item_type", type="string") on "Item", So by default I had the column dType. I wanted to rename the fields by " item_type " so I added the annotation And I execute the following command:

php bin/console doctrine:schema:update

The modifcation on the database was executed successfully but When I call the function getListCars(), I have the following error:

An exception occurred while executing 'SELECT t3.id AS id_4, t3.created_at AS created_at_5, t3.updated_at AS updated_at_6, t2.id AS id_7, t1.id AS id_8, t0.id AS id_9, t3.dtype FROM car t0 INNER JOIN vehicle t1 ON t0.id = t1.id INNER JOIN product t2 ON t0.id = t2.id INNER JOIN item t3 ON t0.id = t3.id':

SQLSTATE[42S22]: Column not found: 1054 Unknown column 't3.dtype' in 'field list'

So I thought it was the cache and I executed the following commands:

php bin/console cache:clear --env=prod
php bin/console cache:clear --env=dev
php bin/console doctrine:cache:clear-query  
php bin/console doctrine:cache:clear-result  
php bin/console doctrine:cache:clear-metadata 

But I have the same error.

Anyone have the solution ?

Originally created by @Gowsan10 on GitHub (Sep 15, 2016). Hello, I have a problem on update DiscriminatorColumn name Entities: ``` php /** *@ORM\Entity *@ORM\Table(name="item") *@ORM\InheritanceType("JOINED") *@ORM\DiscriminatorColumn(name="item_type", type="string") */ abstract class Item { } /** *@ORM\Entity *@ORM\Table(name="product") *@ORM\InheritanceType("JOINED") */ abstract class Product extends Item { } /** *@ORM\Entity *@ORM\Table(name="vehicle") *@ORM\InheritanceType("JOINED") */ abstract class Vehicle extends ItemBundle\Product { } /** *@ORM\Entity(repositoryClass="Aussiito\Bundles\VehicleBundle\Entity\Repository\CarRepository") *@ORM\Table(name="car") */ class Car extends Vehicle { } class CarRepository extends EntityRepository { public function getListCars(){ return $this->findAll(); } }** ``` Before I didn't add the annotation: @ORM\DiscriminatorColumn(name="item_type", type="string") on "Item", So by default I had the column dType. I wanted to rename the fields by " item_type " so I added the annotation And I execute the following command: ``` bash php bin/console doctrine:schema:update ``` The modifcation on the database was executed successfully but When I call the function getListCars(), I have the following error: **An exception occurred while executing 'SELECT t3.id AS id_4, t3.created_at AS created_at_5, t3.updated_at AS updated_at_6, t2.id AS id_7, t1.id AS id_8, t0.id AS id_9, t3.dtype FROM car t0 INNER JOIN vehicle t1 ON t0.id = t1.id INNER JOIN product t2 ON t0.id = t2.id INNER JOIN item t3 ON t0.id = t3.id':** **SQLSTATE[42S22]: Column not found: 1054 Unknown column 't3.dtype' in 'field list'** So I thought it was the cache and I executed the following commands: ``` bash php bin/console cache:clear --env=prod php bin/console cache:clear --env=dev php bin/console doctrine:cache:clear-query php bin/console doctrine:cache:clear-result php bin/console doctrine:cache:clear-metadata ``` But I have the same error. Anyone have the solution ?
Author
Owner

@chishiuanlu commented on GitHub (Apr 19, 2018):

I am having very similar issue with this.
After updating the column name in the code and the db, now the column can't be found error pops up with the persist call.
Has this been answered or resolved in any place?
I have tried using clear cache and schema-tool to update the schema. validate-schema returns OK for everything but the error still not going away.
Any help would be appreciated.

@chishiuanlu commented on GitHub (Apr 19, 2018): I am having very similar issue with this. After updating the column name in the code and the db, now the column can't be found error pops up with the persist call. Has this been answered or resolved in any place? I have tried using clear cache and schema-tool to update the schema. validate-schema returns OK for everything but the error still not going away. Any help would be appreciated.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5259