"Persist" error with Embedded and IDENTITY strategy #6841

Open
opened 2026-01-22 15:39:52 +01:00 by admin · 0 comments
Owner

Originally created by @maxm86545 on GitHub (Oct 4, 2021).

Bug Report

Q A
BC Break yes/no
Version orm 2.9.5
PostgreSQL 13.4

Summary

Current behavior

PostgreSQL create SEQUENCE with user_id_seq name. Doctrine use user_id_id_seq name.
#[ORM\SequenceGenerator(sequenceName: 'user_id_seq')] don't work!

How to reproduce

Entity:

<?php

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class User
{
    #[ORM\Embedded(class: UserId::class, columnPrefix: false)]
    private UserId $id;
}

#[ORM\Embeddable]
class UserId
{
    #[ORM\Id]
    #[ORM\Column(type: 'integer')]
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
    private int $id;
}

Auto-generated migration:

<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20210913000000 extends AbstractMigration
{

    public function up(Schema $schema): void
    {
        $this->addSql('CREATE TABLE user (id SERIAL NOT NULL, PRIMARY KEY(id))');
    }

    public function down(Schema $schema): void
    {
        $this->addSql('DROP TABLE user');
    }
}

Expected behavior

PostgreSQL create SEQUENCE with user_id_seq name. Doctrine use user_id_seq name.

Originally created by @maxm86545 on GitHub (Oct 4, 2021). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes/no | Version orm | 2.9.5 | PostgreSQL | 13.4 #### Summary #### Current behavior PostgreSQL create SEQUENCE with `user_id_seq` name. Doctrine use `user_id_id_seq` name. `#[ORM\SequenceGenerator(sequenceName: 'user_id_seq')]` don't work! #### How to reproduce Entity: ```php <?php use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] class User { #[ORM\Embedded(class: UserId::class, columnPrefix: false)] private UserId $id; } #[ORM\Embeddable] class UserId { #[ORM\Id] #[ORM\Column(type: 'integer')] #[ORM\GeneratedValue(strategy: 'IDENTITY')] private int $id; } ``` Auto-generated migration: ```php <?php declare(strict_types=1); namespace DoctrineMigrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; final class Version20210913000000 extends AbstractMigration { public function up(Schema $schema): void { $this->addSql('CREATE TABLE user (id SERIAL NOT NULL, PRIMARY KEY(id))'); } public function down(Schema $schema): void { $this->addSql('DROP TABLE user'); } } ``` #### Expected behavior PostgreSQL create SEQUENCE with `user_id_seq` name. Doctrine use `user_id_seq` name.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6841