Generated columns not implemented in JoinedSubclassPersister? #6977

Closed
opened 2026-01-22 15:42:30 +01:00 by admin · 1 comment
Owner

Originally created by @mrVrAlex on GitHub (May 12, 2022).

Bug Report

Q A
BC Break no
Version 1.12.0

Summary

Not possible use Generated columns feature with Class Table Inheritance because for example what JoinedSubclassPersister re-write getInsertColumnList method without checks:

if (isset($this->class->fieldMappings[$name]['notInsertable'])) {
    continue;
}

So this just forgot implement in this https://github.com/doctrine/orm/pull/9118 or for purpose? @mehldau @beberlei

Current behavior

Generated columns exists in insert/update SQL queries.

How to reproduce


#[ORM\Entity]
#[ORM\Table(name: 'auth_users')]
#[ORM\InheritanceType('JOINED')]
#[ORM\DiscriminatorColumn(name: 'kind', type: 'string')]
#[ORM\DiscriminatorMap([
    'admin'    => Admin::class,
    'customer' => Customer::class,
])]
abstract class AbstractUser {}

#[ORM\Table(name: 'crm_customer')]
#[ORM\Index(columns: ['full_name'], name: 'crm_customer_full_name_idx', flags: ['gin_trgm_ops'])]
#[ORM\Entity(repositoryClass: CustomerRepository::class)]
#[ORM\HasLifecycleCallbacks]
class Customer extends AbstractUser
{
    #[ORM\Column(name: 'first_name', length: 100, nullable: true)]
    private ?string $firstName = null;

    #[ORM\Column(name: 'last_name', length: 100, nullable: true)]
    private ?string $lastName = null;

    #[ORM\Column(
        name: 'full_name',
        insertable: false,
        updatable: false,
        options: ['length' => 201],
        columnDefinition: "varchar(201) NOT NULL GENERATED ALWAYS AS ((((lower(COALESCE(first_name, ''::character varying)::text) || ' '::text) || lower(COALESCE(last_name, ''::character varying)::text)))) STORED",
        generated: 'ALWAYS'
    )]
    public string $fullName = '';

}

Expected behavior

Generated columns do not exists in insert/update SQL queries.

Originally created by @mrVrAlex on GitHub (May 12, 2022). ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 1.12.0 #### Summary Not possible use Generated columns feature with Class Table Inheritance because for example what JoinedSubclassPersister re-write getInsertColumnList method without checks: ```php if (isset($this->class->fieldMappings[$name]['notInsertable'])) { continue; } ``` So this just forgot implement in this https://github.com/doctrine/orm/pull/9118 or for purpose? @mehldau @beberlei #### Current behavior Generated columns exists in insert/update SQL queries. #### How to reproduce ```php #[ORM\Entity] #[ORM\Table(name: 'auth_users')] #[ORM\InheritanceType('JOINED')] #[ORM\DiscriminatorColumn(name: 'kind', type: 'string')] #[ORM\DiscriminatorMap([ 'admin' => Admin::class, 'customer' => Customer::class, ])] abstract class AbstractUser {} #[ORM\Table(name: 'crm_customer')] #[ORM\Index(columns: ['full_name'], name: 'crm_customer_full_name_idx', flags: ['gin_trgm_ops'])] #[ORM\Entity(repositoryClass: CustomerRepository::class)] #[ORM\HasLifecycleCallbacks] class Customer extends AbstractUser { #[ORM\Column(name: 'first_name', length: 100, nullable: true)] private ?string $firstName = null; #[ORM\Column(name: 'last_name', length: 100, nullable: true)] private ?string $lastName = null; #[ORM\Column( name: 'full_name', insertable: false, updatable: false, options: ['length' => 201], columnDefinition: "varchar(201) NOT NULL GENERATED ALWAYS AS ((((lower(COALESCE(first_name, ''::character varying)::text) || ' '::text) || lower(COALESCE(last_name, ''::character varying)::text)))) STORED", generated: 'ALWAYS' )] public string $fullName = ''; } ``` #### Expected behavior Generated columns do not exists in insert/update SQL queries.
admin closed this issue 2026-01-22 15:42:31 +01:00
Author
Owner

@mrVrAlex commented on GitHub (May 12, 2022):

Duplicate https://github.com/doctrine/orm/issues/9467 Sorry.

@mrVrAlex commented on GitHub (May 12, 2022): Duplicate https://github.com/doctrine/orm/issues/9467 Sorry.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6977