You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the id value is provided as part of the data, it will not be generated by calling nextval on the sequence tied to the column if on a PostgreSQL
platform. This will make calling lastval (on which \Doctrine\DBAL\Connection::lastInsertId() relies) meaningless and an exception will occur:
[Doctrine\DBAL\Exception\DriverException (7)]
An exception occurred in the driver: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: lastval is not yet defined in this session
previous:
[Doctrine\DBAL\Driver\PDO\Exception (7)]
SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: lastval is not yet defined in this session
previous:
[PDOException (55000)]
SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: lastval is not yet defined in this session
Expected behavior
I believe it is possible to extend the abstraction layer to detect whether the primary key has had an explicit value passed and memorize it for use instead of automatically proxying to the pdo_pgsql method for retrieving the last insert id. This will make the DBAL more platform-independent.
In this case the sequence will also need to be reset properly to the new value using:
SELECT
setval(
pg_get_serial_sequence('$table', '$primaryKeyName'),
(SELECT MAX($primaryKeyName) FROM $table)
)
How to reproduce
To be provided...
The text was updated successfully, but these errors were encountered:
Bug Report
Summary
Originally discovered while creating a data migration on the PostgreSQL platform.
Current behavior
If the id value is provided as part of the data, it will not be generated by calling
nextval
on the sequence tied to the column if on a PostgreSQLplatform. This will make calling
lastval
(on which\Doctrine\DBAL\Connection::lastInsertId()
relies) meaningless and an exception will occur:previous:
previous:
Expected behavior
I believe it is possible to extend the abstraction layer to detect whether the primary key has had an explicit value passed and memorize it for use instead of automatically proxying to the pdo_pgsql method for retrieving the last insert id. This will make the DBAL more platform-independent.
In this case the sequence will also need to be reset properly to the new value using:
How to reproduce
To be provided...
The text was updated successfully, but these errors were encountered: