RoleTest and RoleCheckoutTest fail with Uncaught PHP Exception Drupal\Core\Database\IntegrityConstraintViolationException: "SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "rpid" violates not-null constraint: INSERT INTO simpletest713714uc_roles_products (pfid, rpid, nid, model, rid, duration, granularity, by_quantity, shippable, end_override, end_time) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9, :db_insert_placeholder_10); Array
Comment | File | Size | Author |
---|---|---|---|
#9 | pgsql.patch | 2.88 KB | TR |
#6 | pgsql.patch | 1.53 KB | TR |
#5 | pgsql.patch | 1.35 KB | TR |
Comments
Comment #2
TR CreditAttribution: TR commentedComment #3
TR CreditAttribution: TR commentedThis appears to be a problem with db_merge() not working on PostgreSQL when the primary key is a serial field. We use essentially the same code for both roles and file downloads, since they are both file features, which is why these tests are the ones that fail in PostgreSQL.
This seems to be a problem in core - all the db_ functions EXCEPT db_merge are tested against tables with serial and non-serial primary keys, but db_merge() is only tested in the case of non-serial primary keys. db_merge() is the recommended replacement for drupal_write_record() which we used to use in D7 for roles and files, but drupal_write_record() has always had this known problem with PostgreSQL and serial primary keys. There have been many issues about this, but they have all been closed and "fixed" in core by not using db_merge() when core has a serial primary key, thereby avoiding the issue instead of addressing it.
Short of a core fix for db_merge(), we'll probably just have to test the key and do a conditional db_insert()/db_update(). Yuck, but it will work.
Comment #4
TR CreditAttribution: TR commentedLet's do this for beta.
Comment #5
TR CreditAttribution: TR commentedLet's test my theory ...
Comment #6
TR CreditAttribution: TR commentedAgain ...
Comment #7
TR CreditAttribution: TR commentedSee if I can debug the package test ...
Comment #8
TR CreditAttribution: TR commentedAnother debug attempt.
Comment #9
TR CreditAttribution: TR commentedAnother wild guess as to what may be going wrong ...
Comment #11
TR CreditAttribution: TR commentedSuccess! PostgreSQL tests are now passing for the first time!
Lessons learned:
Comment #12
longwaveNice work. The first one feels like a bug in the Postgres driver - maybe it should be reported against core? The second one isn't strictly a bug, more an assumption that succeeds in MySQL but is not guaranteed in other databases.
Comment #13
TR CreditAttribution: TR commentedYes it should, I just don't know if I have the energy to take on what is probably a multi-year task of trying to get that fixed in core.