Wrong sequence name generator #5255

Closed
opened 2026-01-22 15:02:44 +01:00 by admin · 6 comments
Owner

Originally created by @andreas4all on GitHub (Sep 14, 2016).

Hi,

I created entity like this:

/**
 * @ORM\Entity
 */
class WirelessStatisticsServiceShortTerm
{
    /**
     * @var int
     *
     * @ORM\Column(name="wireless_statistic_id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    protected $id;

... shortened ...
}

Doctrine use this sequence:

wireless_statistics_service_short_term_wireless_statistic_id_se

and PostgreSQL generate this:

wireless_statistics_service_short_ter_wireless_statistic_id_seq
Originally created by @andreas4all on GitHub (Sep 14, 2016). Hi, I created entity like this: ``` /** * @ORM\Entity */ class WirelessStatisticsServiceShortTerm { /** * @var int * * @ORM\Column(name="wireless_statistic_id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") */ protected $id; ... shortened ... } ``` Doctrine use this sequence: ``` wireless_statistics_service_short_term_wireless_statistic_id_se ``` and PostgreSQL generate this: ``` wireless_statistics_service_short_ter_wireless_statistic_id_seq ```
admin closed this issue 2026-01-22 15:02:45 +01:00
Author
Owner

@lcobucci commented on GitHub (Sep 14, 2016):

Are you sure that "IDENTITY" is the strategy you want?

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#identifier-generation-strategies

@lcobucci commented on GitHub (Sep 14, 2016): Are you sure that "IDENTITY" is the strategy you want? http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/basic-mapping.html#identifier-generation-strategies
Author
Owner

@andreas4all commented on GitHub (Sep 14, 2016):

Yes. I want to use IDENTITY, because I want to use SERIAL in PostgreSQL.

@andreas4all commented on GitHub (Sep 14, 2016): Yes. I want to use `IDENTITY`, because I want to use `SERIAL` in PostgreSQL.
Author
Owner

@lcobucci commented on GitHub (Sep 14, 2016):

If you take a look on PostgreSqlPlatform you'll see that it's correct: https://github.com/doctrine/dbal/blob/9f8c05cd5225a320d56d4bfdb4772f10d045a0c9/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L196

However wireless_statistics_service_short_term_wireless_statistic_id_se contains exactly 63 chars which is the value that AbstractPlatform#getMaxIdentifierLength() returns and DBAL\Schema\Table uses it to trim the identifier names.

I don't know exactly where's the problem (and if it's a problem) but it's definitely related to DBAL and not the ORM.

Can you reopen this on DBAL (maybe with some test cases)?

@lcobucci commented on GitHub (Sep 14, 2016): If you take a look on `PostgreSqlPlatform` you'll see that it's correct: https://github.com/doctrine/dbal/blob/9f8c05cd5225a320d56d4bfdb4772f10d045a0c9/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php#L196 However `wireless_statistics_service_short_term_wireless_statistic_id_se` contains exactly 63 chars which is the value that `AbstractPlatform#getMaxIdentifierLength()` returns and `DBAL\Schema\Table` uses it to trim the identifier names. I don't know exactly where's the problem (and if it's a problem) but it's definitely related to `DBAL` and not the `ORM`. Can you reopen this on `DBAL` (maybe with some test cases)?
Author
Owner

@lcobucci commented on GitHub (Sep 14, 2016):

BTW 63 is the max identifier length for PostgreSQL too: https://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html (so it's not a bug)

@lcobucci commented on GitHub (Sep 14, 2016): BTW 63 is the max identifier length for PostgreSQL too: https://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html (so it's not a bug)
Author
Owner

@andreas4all commented on GitHub (Sep 14, 2016):

yes, thats right. but doctrine strip last character of sequence name to limit. Postgresql generate it from table name and column name, but PG strip characters from table name not column name (or last character from generated sequence name). You can see it there is _ter_ in Postgresql name, not _term_.

@andreas4all commented on GitHub (Sep 14, 2016): yes, thats right. but doctrine strip last character of sequence name to limit. Postgresql generate it from table name and column name, but PG strip characters from table name not column name (or last character from generated sequence name). You can see it there is `_ter_` in Postgresql name, not `_term_`.
Author
Owner

@lcobucci commented on GitHub (Sep 14, 2016):

Indeed, but it's still related to the DBAL and not the ORM, open that bug there to help us to organize things plz https://github.com/doctrine/dbal

@lcobucci commented on GitHub (Sep 14, 2016): Indeed, but it's still related to the `DBAL` and not the `ORM`, open that bug there to help us to organize things plz https://github.com/doctrine/dbal
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5255