Running tests for postgresql brings exceptions
FileFieldValidateTestCase->testRequired()
SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation "simpletest239413field_data_field_s239413c9d2bf6f_etid_idx" already exists
ListFieldTestCase->testUpdateAllowedValues()
SQLSTATE[42P07]: Duplicate table: 7 ERROR: relation "simpletest727934field_data_field_test_etid_idx" already exists
This caused by renaming tables but not renaming there indexes
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | 718016-rename-table-with-indexes_d7.patch | 1.49 KB | andypost |
| #11 | 718016-rename-table-with-indexes_d7.patch | 1.39 KB | andypost |
| #2 | 718016-rename-table-rename-index.patch | 1.66 KB | damien tournoud |
| #1 | 718016_schema.patch | 1.74 KB | andypost |
Comments
Comment #1
andypostThis patch adds field[id] to index-name so all index names for fields are unique and does not need rename on delete
Comment #2
damien tournoud commentedActually, this is the responsibility of the PostgreSQL driver. We need to rename indexes to match the new table name.
Comment #3
andypostI still think that we should change index-names inside field_sql_storage_field_storage_delete_field()
Because after renaming table schema is changed and index-names returned by _field_sql_storage_schema() are different from actually stored in DB for all DB-engines
Comment #4
damien tournoud commented@andypost, no that's not the case. The name of the indexes in hook_schema() are *relative to the table*. We only have to do that in PostgreSQL because the index names are global, not table-specific.
Comment #5
andypostSo +1 to commit your patch, I dont know is it a good idea to query pg_indexes... waiting for Josh review
Anyway confirm this fix both tests for fields.
Comment #6
damien tournoud commentedRelated: #718846: DatabaseSchema_pgsql should not prefix the constraints names. @andypost, care to fix that other issue?
Comment #7
andypostThere's a a test
testFieldUpdateIndexesWithDatawhich works only for mysql nowSuppose this onу could be extended
field_sql_storage.module
Comment #8
andypostTest for renaming indexes #720620: indexExists() for pgsql and sqlite does not prefix tablename
Comment #9
andypostBecause PK and UK are indexes this patch works fine.
I think tests from #8 cover index rename
Comment #10
webchickIf we're going to change the name of the first argument here, we should do it in the other back-ends too, for consistency.
Additionally, it sounds like we need expanded test coverage for this?
Comment #11
andypostSuppose Damien does not mean to change the api
Extended tests goes in #718254: Fieldname in tests are too long and #720620: indexExists() for pgsql and sqlite does not prefix tablename
Because this is a different trouble
Comment #12
andypostSequence of patches:
1) This because other issues with tests depends on it
2) #720620: indexExists() for pgsql and sqlite does not prefix tablename - to repair schema (here first part of tests)
3) #718254: Fieldname in tests are too long - Tests for fields storage now could be expanded on posgresql and sqlite
Comment #13
dries commentedCan we add a one sentence explanation in the code explaining _why_ we are doing this? Thanks!
Comment #14
damien tournoud commentedAs a side note: I was under the impression for a while that we also needed to rename the named constraints associated to the table (as described in #718846: DatabaseSchema_pgsql should not prefix the constraints names). But we only actually use named constraints for the unique keys, and it seems that renaming the index that PostgreSQL automatically creates when you add a UNIQUE constraints is enough to rename the constraint itself.
All good.
Comment #15
andypostNew patch with improved comment
Comment #16
andypostAs #720620: indexExists() for pgsql and sqlite does not prefix tablename commited so tests already in.
Comment #17
damien tournoud commentedLet's get this sucker in.
Comment #18
webchickCool, I think that makes sense. I made a minor English correction and committed to HEAD. Thanks!