Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't set sequenceGenerator when generator strategy set to IDENTITY

I am trying to set the allocation size and initial value of a sequence using the IDENTITY strategy for PostgreSQL. This doesn't produce the SQL I expected, changing the strategy to SEQUENCE works however. Is this intended?

id:
    id:
        type: integer
        id: true
        generator:
            strategy: IDENTITY
        sequenceGenerator:
            sequenceName: table_id_seq
            allocationSize: 10
            initialValue: 100000
like image 323
shapeshifter Avatar asked Feb 22 '15 23:02

shapeshifter


1 Answers

Doctrine initializes the ID generator strategy in Doctrine\ORM\Mapping\ClassMetadataFactory. There is a big switch statement in the factory, switching the <STRATEGY_NAME> you provide in your YAML configuration:

generator:
    strategy: <STRATEGY_NAME>

The selected strategy then fetches further optional parameters from your configuration.

All available strategies are listed in the Doctrine Manual. The options for the Sequence Generator strategy are detailed in the following subsection.

Judging from your configuration, you are currently setting the parameters for the Sequence Generator strategy, while telling Doctrine to use the Identifier strategy. Maybe this is the unexpected behavior you are experiencing?

You may read the source code of the respective factory lines to clarify your expectations.

like image 197
Fabian Keller Avatar answered Sep 30 '22 06:09

Fabian Keller