AutoIncrement pgSQL without identity strategy #7182

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

Originally created by @vencakrecl on GitHub (Jul 12, 2023).

Bug Report

The AUTO and SEQUENCE strategy does not support autoincrement, only 'IDENTITY' works.

Q A
BC Break no
Version 2.15.3

Summary

Current behavior

IDENTITY

        $this->addSql('CREATE SEQUENCE billing_plan_id_seq');
        $this->addSql('SELECT setval(\'billing_plan_id_seq\', (SELECT MAX(id) FROM billing_plan))');
        $this->addSql('ALTER TABLE billing_plan ALTER id SET DEFAULT nextval(\'billing_plan_id_seq\')');

AUTO, SEQUENCE

        $this->addSql('CREATE SEQUENCE billing_plan_id_seq');

How to reproduce

    #[ORM\Id]
    #[ORM\Column(type: Types::INTEGER, unique: true, nullable: false)]
    #[ORM\GeneratedValue(strategy: 'IDENTITY')]
    private ?int $id = null;
    #[ORM\Id]
    #[ORM\Column(type: Types::INTEGER, unique: true, nullable: false)]
    #[ORM\GeneratedValue(strategy: 'AUTO')] // #[ORM\GeneratedValue(strategy: 'SEQUENCE')
    private ?int $id = null;

Expected behavior

IDENTITY, AUTO, SEQUENCE

        $this->addSql('CREATE SEQUENCE billing_plan_id_seq');
        $this->addSql('SELECT setval(\'billing_plan_id_seq\', (SELECT MAX(id) FROM billing_plan))');
        $this->addSql('ALTER TABLE billing_plan ALTER id SET DEFAULT nextval(\'billing_plan_id_seq\')');
Originally created by @vencakrecl on GitHub (Jul 12, 2023). ### Bug Report The `AUTO` and `SEQUENCE` strategy does not support autoincrement, only 'IDENTITY' works. | Q | A |------------ | ------ | BC Break | no | Version | 2.15.3 #### Summary #### Current behavior IDENTITY ``` $this->addSql('CREATE SEQUENCE billing_plan_id_seq'); $this->addSql('SELECT setval(\'billing_plan_id_seq\', (SELECT MAX(id) FROM billing_plan))'); $this->addSql('ALTER TABLE billing_plan ALTER id SET DEFAULT nextval(\'billing_plan_id_seq\')'); ``` AUTO, SEQUENCE ``` $this->addSql('CREATE SEQUENCE billing_plan_id_seq'); ``` #### How to reproduce ``` #[ORM\Id] #[ORM\Column(type: Types::INTEGER, unique: true, nullable: false)] #[ORM\GeneratedValue(strategy: 'IDENTITY')] private ?int $id = null; ``` ``` #[ORM\Id] #[ORM\Column(type: Types::INTEGER, unique: true, nullable: false)] #[ORM\GeneratedValue(strategy: 'AUTO')] // #[ORM\GeneratedValue(strategy: 'SEQUENCE') private ?int $id = null; ``` #### Expected behavior IDENTITY, AUTO, SEQUENCE ``` $this->addSql('CREATE SEQUENCE billing_plan_id_seq'); $this->addSql('SELECT setval(\'billing_plan_id_seq\', (SELECT MAX(id) FROM billing_plan))'); $this->addSql('ALTER TABLE billing_plan ALTER id SET DEFAULT nextval(\'billing_plan_id_seq\')'); ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7182