-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Bug Report
Q | A |
---|---|
Version | 4.* |
Previous Version if the bug is a regression | 3.* |
Summary
In versions 3 and earlier method Connection::lastInsertId()
accepted an optional sequence name. Version 3 made this deprecated and later it was removed. The rationale is described in #4687.
Current behaviour
However, there are scenarios when the sequence name is necessary, at least in PostgreSQL:
- There is an insert trigger on table A, and the trigger inserts a new row into table B.
- Both table A and B have an identity column.
- I insert a new row into table A with
Connection::insert()
method or with pure SQL. Connection::lastInsertId()
returns value of identity column from table B (because of the trigger) but I want the value from table A and there's no way to do it with this method any longer. I need to use workarounds like manually construct anINSERT ... RETURNING id
query or run a query likeSELECT currval('table_id_seq')
.
Expected behaviour
I should be able to specify the name of the sequence like in the old versions for cases with triggers like described above.
Metadata
Metadata
Assignees
Labels
No labels