- attached testcase.py
Quote table names by default in MySQL
Table names are quoted by default in MySQL when they are checked for existing; see MySQLDialect.has_table() in lib/sqlalchemy/databases/mysql.py. However, when issuing CREATE TABLE statements, there is no such quoting by default, unless it is in databases.mysql.RESERVED_WORDS. "fields" is not included among these reserved words, but it is a reserved word in MySQL 4.1 and earlier; see http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html.
This causes the attached test case to fail on MySQL 4.1 / Debian Sarge, and should affect all 4.1 or earlier MySQL versions.
It is corrected by adding "fields" to the reserved words; this is included in sqla_mysql_resword.patch. Alternately, adding a format_table function to MySQLIdentifierPreparer that automatically quotes all table names in CREATE TABLE statements will more closely mirror how has_table() works. This is included in sqla_quote_mysql_tables.patch. The second patch should also preempt additional problems with as-yet missing reserved words (like "fields").
Comments (5)
-
Account Deleted -
Account Deleted - attached sqla_mysql_resword.patch
Patch to add "fields" to MySQL reserved words
-
Account Deleted - attached sqla_quote_mysql_tables.patch
Patch to quote MySQL tables by default in MySQLIdentifierPreparer
-
repo owner - changed component to mysql
we can add "fields" to MySQL reserved words. if you want quoting turned on unconditionally for a certain table, specify "quote=True" to the
Table
function call. its there for exactly this situation. quoting on by default for everyone would create problems particularly for MySQL where "case sensitivity" of identifiers is such a subjective (platform-dependent) thing. -
repo owner - changed status to resolved
implemented 'fields' in changeset:2702 changeset:2703
- Log in to comment
Test case that fails on MySQL 4.1