mirror of
https://github.com/sqlalchemy/sqlalchemy.git
synced 2026-05-19 15:12:04 -04:00
Merge "Don't emit pyodbc "no driver" warning for empty URL" into rel_1_3
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
.. change::
|
||||
:tags: bug, mssql, pyodbc
|
||||
:tickets: 5346
|
||||
|
||||
Fixed an issue in the pyodbc connector such that a warning about pyodbc
|
||||
"drivername" would be emitted when using a totally empty URL. Empty URLs
|
||||
are normal when producing a non-connected dialect object or when using the
|
||||
"creator" argument to create_engine(). The warning now only emits if the
|
||||
driver name is missing but other parameters are still present.
|
||||
@@ -75,7 +75,8 @@ class PyODBCConnector(Connector):
|
||||
|
||||
connectors = []
|
||||
driver = keys.pop("driver", self.pyodbc_driver_name)
|
||||
if driver is None:
|
||||
if driver is None and keys:
|
||||
# note if keys is empty, this is a totally blank URL
|
||||
util.warn(
|
||||
"No driver name specified; "
|
||||
"this is expected by PyODBC when using "
|
||||
|
||||
@@ -67,6 +67,13 @@ class ParseConnectTest(fixtures.TestBase):
|
||||
connection,
|
||||
)
|
||||
|
||||
def test_pyodbc_empty_url_no_warning(self):
|
||||
dialect = pyodbc.dialect()
|
||||
u = url.make_url("mssql+pyodbc://")
|
||||
|
||||
# no warning is emitted
|
||||
dialect.create_connect_args(u)
|
||||
|
||||
def test_pyodbc_host_no_driver(self):
|
||||
dialect = pyodbc.dialect()
|
||||
u = url.make_url("mssql://username:password@hostspec/database")
|
||||
|
||||
Reference in New Issue
Block a user