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

Object names are always introspected as unquoted #5776

Open
morozov opened this issue Oct 18, 2022 · 1 comment
Open

Object names are always introspected as unquoted #5776

morozov opened this issue Oct 18, 2022 · 1 comment

Comments

@morozov
Copy link
Member

morozov commented Oct 18, 2022

Q A
Version 3.4.5

Consider the following code snippet:

$platform = $connection->getDatabasePlatform();
$sm       = $connection->createSchemaManager();

$table = new Table('"foo-bar"');
$table->addColumn('id', 'integer');
$sm->createTable($table);

foreach ($sm->listTables() as $table) {
    try {
        $sm->dropTable($table->getQuotedName($platform));
    } catch (Exception $e) {
        echo $e->getMessage() . PHP_EOL;
        exit(1);
    }
}

// An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1 near "-": syntax error

The original table definition wraps the table name in quotes which suggests the DBAL that the name should be quoted in SQL. When the table is introspected, the $quoted property of the table is not initialized, so all subsequent operations on the table name will result in invalid SQL.

@morozov
Copy link
Member Author

morozov commented Oct 19, 2022

It would be correct to mark all introspected object names as quoted on all platforms. Whether the name is quoted or not doesn't make a difference on most of the platforms. On Oracle and IBM DB2, the quoted name will naturally preserve the actual upper/lower case of the object as it exists in the actual database.

But the side effects of that on existing code are unknown.

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

1 participant