Fix has_table method (#3741)

Dialect's has_table method requires connection as the first argument, not engine (https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/engine/interfaces.py#L454). Instead, we can use engine's has_table method that handles the connection for us (https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/engine/base.py#L2141). Alternatively, we could call engine.dialect.has_table(engine.connect(), ...).
This commit is contained in:
mxmzdlv 2017-10-31 17:04:23 +13:00 committed by Maxime Beauchemin
parent 814b70ffd8
commit 5bc734b2e5
1 changed files with 2 additions and 2 deletions

View File

@ -788,8 +788,8 @@ class Database(Model, AuditMixinNullable):
def has_table(self, table):
engine = self.get_sqla_engine()
return engine.dialect.has_table(
engine, table.table_name, table.schema or None)
return engine.has_table(
table.table_name, table.schema or None)
def get_dialect(self):
sqla_url = url.make_url(self.sqlalchemy_uri_decrypted)