summaryrefslogtreecommitdiff
path: root/test/engine
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-04-14 12:12:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-04-14 12:14:12 -0400
commitb26cf96462b195a4c12ccdf8283ef028f91eb872 (patch)
treeffaceb138fd0039863ea1110fd33d295aa66c003 /test/engine
parentd3c3982100a617623c92b41799b19f27448a1574 (diff)
downloadsqlalchemy-b26cf96462b195a4c12ccdf8283ef028f91eb872.tar.gz
Explicitly test for Connection in dialect.has_table()
The :meth:`_engine.Dialect.has_table` method now raises an informative exception if a non-Connection is passed to it, as this incorrect behavior seems to be common. This method is not intended for external use outside of a dialect. Please use the :meth:`.Inspector.has_table` method or for cross-compatibility with older SQLAlchemy versions, the :meth:`_engine.Engine.has_table` method. Fixes: #5780 Fixes: #6062 Fixes: #6260 Change-Id: I9b2439675167019b68d682edee3dcdcfce836987
Diffstat (limited to 'test/engine')
-rw-r--r--test/engine/test_execute.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py
index 0de5ed124..0b65b3055 100644
--- a/test/engine/test_execute.py
+++ b/test/engine/test_execute.py
@@ -261,6 +261,13 @@ class ExecuteTest(fixtures.TablesTest):
(4, "sally"),
]
+ def test_dialect_has_table_assertion(self):
+ with expect_raises_message(
+ tsa.exc.ArgumentError,
+ r"The argument passed to Dialect.has_table\(\) should be a",
+ ):
+ testing.db.dialect.has_table(testing.db, "some_table")
+
def test_exception_wrapping_dbapi(self):
with testing.db.connect() as conn:
# engine does not have exec_driver_sql