Skip to content

DBAL-88: MySqlPlatform not escaping table names #2119

Closed
doctrinebot opened this Issue Feb 10, 2011 · 6 comments

2 participants

@doctrinebot

Jira issue originally created by user jreed:

Methods in the MySql Platform that use the table name are not escaping the table name. This causes problems when your table name is the same as a reserved word in MySql. Example:

public function getListTableConstraintsSQL($table)
{
    return 'SHOW INDEX FROM ' . $table;
}

If my table name is User this method will fail and cause a SQL error because the word User is a reserved word in MySql. You need to escape the table name with backticks to prevent these errors. Example:

public function getListTableConstraintsSQL($table)
{
    return 'SHOW INDEX FROM `' . $table . '`';
}

I encountered this problem while reverse engineering my existing MySql database. I've attached a fixed version that solved my reverse engineering problems.

@doctrinebot

Comment created by @beberlei:

Duplicate of DDC-976

@doctrinebot

Comment created by @beberlei:

This issue is not a duplicate, only related to DBAL-91.

@doctrinebot

Comment created by @beberlei:

Fixed

@doctrinebot

Issue was closed with resolution "Fixed"

@doctrinebot doctrinebot added the Bug label Dec 7, 2015
@beberlei beberlei was assigned by doctrinebot Dec 7, 2015
@doctrinebot doctrinebot added this to the 2.0.2 milestone Dec 7, 2015
@doctrinebot doctrinebot closed this Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.