incorrect case checking in MySQLDialect.reflecttable()

Issue #316 resolved
Former user created an issue

I have some tables in my database which names start with capital letter, e.g. 'User'. I try to autoload metadata for it:

engine = create_engine("mysql://root:123@localhost/test", echo='debug')
meta = BoundMetaData(engine)
user = Table('User', meta, autoload=True)

But exception is occurring: sqlalchemy.exceptions.SQLError: (ProgrammingError) (1146, "Table 'test.user' doesn't exist") 'describe user' {} I have case-sensitive platform and there's a difference between 'user' and 'User'.

I noticed that SQLAlchemy do some magic in reflecttable() to check whether my platform is case sensitive or not:

connection.execute("show variables like 'lower_case_table_names'").fetchone()[1](1) == 0
if not case_sensitive:
    table.name = table.name.lower()
    table.metadata.tables[table.name](table.name)= table

But this check is not correct, it should be "0", not 0, because ''fetchone()1'' is a string.

Comments (1)

  1. Log in to comment