Skip to content

Object names are always introspected as unquoted #5776

Open
@morozov

Description

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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions