8000 Fix introspection of table options in non-default schemas by morozov · Pull Request #6753 · doctrine/dbal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix introspection of table options in non-default schemas #6753

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

Conversation

morozov
Copy link
Member
@morozov morozov commented Feb 1, 2025

When introspecting table options, the PostgreSQL and SQL Server schema managers do not take the schema name into account, so all selected options are mistakenly attributed to the table with the same unqualified name in the default schema.

Additionally, the SQL Server platform cannot create tables with comments in the non-default schema.

if (str_contains($tableName, '.')) {
[$schemaName, $tableName] = explode('.', $tableName);
} else {
$schemaName = 'dbo';
Copy link
Member Author
@morozov morozov Feb 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have to default to the dbo schema here because the platform doesn't know of the current schema, which is scoped to a connection.

UPD: technically, we can use CURRENT_SCHEMA(), but I'll leave dbo for now for consistency with the rest of the code.

@@ -227,9 +227,15 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys)
$name = $tableForeignKey['ForeignKey'];

if (! isset($foreignKeys[$name])) {
$referencedTableName = $tableForeignKey['ReferenceTableName']; 8000

if ($tableForeignKey['ReferenceSchemaName'] !== 'dbo') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have to default to the dbo schema here because the schema manager is unaware of the current schema in 3.x (see #6677).

@morozov morozov marked this pull request as ready for review February 1, 2025 22:22
@morozov morozov requested a review from greg0ire February 1, 2025 22:23
@morozov morozov added this to the 3.9.5 milestone Feb 2, 2025
@morozov morozov merged commit a1932ce into doctrine:3.9.x Feb 2, 2025
68 checks passed
@morozov morozov deleted the non-default-schema-table-comment-introspection branch February 2, 2025 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0