mysql.py fails to escape certain identifiers
When reflecting tables, mysql.py fails to escape the table name if necessary, sometimes resulting in invalid queries.
Here is a diff against mysql.py as of SQLAlchemy 0.3.4.
346c346
< c = connection.execute("describe " + table.fullname, {})
---
> c = connection.execute("describe " + self.identifier_preparer.format_table(table), {})
407c407
< c = connection.execute("SHOW CREATE TABLE " + table.fullname, {})
---
> c = connection.execute("SHOW CREATE TABLE " + self.identifier_preparer.format_table(table), {})
Comments (7)
-
Account Deleted -
repo owner passing the full table in to has_table() still does not eliminate the complexity that some dialects need to query the schema name and tablename as separate columns, so the format_table() method is not flexible enough. a new method "foramt_schema_and_tablename" or similar should be added to ANSIIdentifierPreparer which returns the two names separately, and is called by the generic create/drop methods in ansisql.py to get the quoted names, which then get passed to has_table (also has_table has a "schema" kw arg in the trunk, though only supported on postgres).
-
repo owner - changed milestone to 0.3.6
-
repo owner - changed milestone to 0.4.0
blocked by
#233 -
This is addressed in 81f42181f431eb8ea96c94ee8a2d798f11a296e7 for the 0.3 series through a workaround (no format_... methods added to preparer.) MySQL reflection is one that needs seperate schema and table names, fwiw.
The additional format_ method would be for 0.4, also keeping in mind
#594. -
- changed status to resolved
breaking out the implementation enhancement part of this to
#666 -
repo owner - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
By the way, this also affects has_table. This is harder to fix because it is only passed the table's name, without the schema (if any). A simple fix would be to change has_table so it takes a Table object instead of a string; it would still only have the task of checking for the existence of a table with that name, but it could access other information (table.schema, etc.) when necessary.