db icon indicating copy to clipboard operation
db copied to clipboard

`getForeignKeys()` - inconsistency of array keys

Open arogachev opened this issue 1 year ago • 4 comments

SQLite:

[['auth_item', 'child' => 'name'], ['auth_item', 'parent' => 'name']];

MySQL:

['auth_item_child_ibfk_1' => ['auth_item', 'child' => 'name'], 'auth_item_child_ibfk_2' => ['auth_item', 'parent' => 'name']];

arogachev avatar Apr 13 '23 06:04 arogachev

Do you mean that SQLite does not return FK names?

samdark avatar Apr 15 '23 09:04 samdark

I mean integer and string keys difference. Maybe add docs for now.

arogachev avatar Apr 15 '23 16:04 arogachev

Foreign key in MySQL supports index name, and in SQLite don't supports, so in SQLite used integer ID (seems, it's just number in order) as name.

I think improve phpdoc and make more specified psalm type for TableSchemaInterface::getForeignKeys() result will be enough.

vjik avatar Aug 08 '23 13:08 vjik

Decided to use ForeignKeyConstraint[] instead of arrays. Related with #734

Tigrov avatar Aug 28 '23 02:08 Tigrov