Problem/Motivation
If you do something like:
$database->insert('table_with_serial_id')->from(
$database->select('table_with_serial_id_backup')->fields('table_with_serial_id_backup')
)->execute();
$database->insert('table_with_serial_id')->fields([
'value' => 'Foob bar,
])->execute()
Where table_with_serial_id_backup contains a couple of rows - PostgreSQL will error on the second insert because \Drupal\pgsql\Driver\Database\pgsql\Insert::execute() has not update the sequence like it would for an insert not using a fromQuery.
See https://git.drupalcode.org/issue/drupal-3561800/-/jobs/7571540#L2892 for the failing test case.
Proposed resolution
Always update sequences if the fromQuery includes the serial field.
Remaining tasks
User interface changes
None
Introduced terminology
N/a
API changes
None
Data model changes
None
Release notes snippet
N/a
Issue fork drupal-3561800
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
alexpottComment #4
alexpottComment #5
smustgrave commentedSo test-only is passing should it be failing?
Comment #6
alexpott@smustgrave it is not passing on PostgreSQL. - sure it passes on MySQL and SQLite. But they don't have the bug :)
Comment #9
smustgrave commentedSorry for the noise, I opened an MR with just the tests and ran postgreSql with 8.5, I did get a test failure in https://git.drupalcode.org/issue/drupal-3561800/-/jobs/7648408
So fix addresses the problem.
Comment #10
longwavePatch applies to 10.6.x so let's backport it there as well.
Committed and pushed a0acc2c1005 to main and cbb23a2aebd to 11.x and 9ebef38a847 to 11.3.x and 96912dd3a82 to 10.6.x. Thanks!