-
Notifications
You must be signed in to change notification settings - Fork 48
PostgreSQL - sequence must work on concurent mixed (/w/wo ID) inserts #714
Copy link
Copy link
Closed
Labels
Description
I think, when ID is not set, we can insert like INSERT INTO t (id, c, ...) VALUES (xx, c_val, ...)
where xx can be something like select max(id, seq.nextval) instead
Lines 939 to 945 in 8f03b55
| // PostgreSQL sequence must be manually synchronized if a row with explicit ID was inserted | |
| if ($this->connection instanceof \Atk4\Data\Persistence\Sql\Postgresql\Connection) { | |
| $this->connection->expr( | |
| 'select setval([], coalesce(max({}), 0) + 1, false) from {}', | |
| [$this->getIdSequenceName($model), $model->id_field, $model->table] | |
| )->execute(); | |
| } |
note: As PK is unique, this should throw an duplicate PK now, thus not corrupt data.
Reactions are currently unavailable