Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table foreign keys load two times as arrays and as objects #734

Open
Tigrov opened this issue Aug 2, 2023 · 5 comments
Open

Table foreign keys load two times as arrays and as objects #734

Tigrov opened this issue Aug 2, 2023 · 5 comments

Comments

@Tigrov
Copy link
Member

Tigrov commented Aug 2, 2023

Current implementation loads table foreign keys two times as arrays and as objects.

PostgreSQL
https://github.com/yiisoft/db-pgsql/tree/535975396d865da6cb15ed7bee5648c27a9b7360/src/Schema.php#L499 as arrays
https://github.com/yiisoft/db-pgsql/tree/535975396d865da6cb15ed7bee5648c27a9b7360/src/Schema.php#L894 as objects

MySQL
https://github.com/yiisoft/db-mysql/blob/4dd4e13502a0f047627c398854fc733a41054370/src/Schema.php#L265 as arrays
https://github.com/yiisoft/db-mysql/blob/4dd4e13502a0f047627c398854fc733a41054370/src/Schema.php#L618 as objects

SQLite
https://github.com/yiisoft/db-sqlite/blob/b172ec9c11f31a5618a80e8cc6e3b298f423eb26/src/Schema.php#L381 as arrays
https://github.com/yiisoft/db-sqlite/blob/b172ec9c11f31a5618a80e8cc6e3b298f423eb26/src/Schema.php#L201 as objects

Should they be loaded once?

Q A
Version 1.1.0
PHP version any
Operating system any
@vjik
Copy link
Member

vjik commented Aug 6, 2023

Perhaps the solution could be use AbstractSchema::getTableMetadata() into Schema::findConstraints() of each DB specific package?

@Tigrov
Copy link
Member Author

Tigrov commented Aug 6, 2023

Yes, it looks like this. And use ForeignKeyConstraint[] instead of associative arrays.

@vjik
Copy link
Member

vjik commented Aug 6, 2023

@darkdef @terabytesoftw What do you think?

@Tigrov
Copy link
Member Author

Tigrov commented Aug 6, 2023

Perhaps the solution could be use AbstractSchema::getTableMetadata() into Schema::findConstraints() of each DB specific package?

Or AbstractSchema::getTableForeignKeys()

@Tigrov
Copy link
Member Author

Tigrov commented Aug 15, 2023

Suggestion to use one way to get foreign keys Schema::getTableForeignKeys() and do not store them in TableSchemaInterface as for indexes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants