From: Mike Bayer Date: Fri, 22 May 2015 17:51:00 +0000 (-0400) Subject: - Adjustments to the engine plugin hook, such that the X-Git-Tag: rel_1_0_5~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04c625467e65ec4189d4fd73e0e10c727f04dce6;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Adjustments to the engine plugin hook, such that the :meth:`.URL.get_dialect` method will continue to return the ultimate :class:`.Dialect` object when a dialect plugin is used, without the need for the caller to be aware of the :meth:`.Dialect.get_dialect_cls` method. reference #3379 --- diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst index 291382ba13..917485582d 100644 --- a/doc/build/changelog/changelog_10.rst +++ b/doc/build/changelog/changelog_10.rst @@ -18,6 +18,17 @@ .. changelog:: :version: 1.0.5 + .. change:: + :tags: feature, engine + :tickets: 3379 + + Adjustments to the engine plugin hook, such that the + :meth:`.URL.get_dialect` method will continue to return the + ultimate :class:`.Dialect` object when a dialect plugin is used, + without the need for the caller to be aware of the + :meth:`.Dialect.get_dialect_cls` method. + + .. change:: :tags: bug, ext :tickets: 3427 diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py index a802e5d90e..e2a086de42 100644 --- a/lib/sqlalchemy/engine/strategies.py +++ b/lib/sqlalchemy/engine/strategies.py @@ -48,8 +48,7 @@ class DefaultEngineStrategy(EngineStrategy): # create url.URL object u = url.make_url(name_or_url) - entrypoint = u.get_dialect() - dialect_cls = entrypoint.get_dialect_cls(u) + entrypoint, dialect_cls = u._get_dialect_plus_entrypoint() if kwargs.pop('_coerce_config', False): def pop_kwarg(key, default=None): diff --git a/lib/sqlalchemy/engine/url.py b/lib/sqlalchemy/engine/url.py index d045961dd6..07f6a5730a 100644 --- a/lib/sqlalchemy/engine/url.py +++ b/lib/sqlalchemy/engine/url.py @@ -117,11 +117,7 @@ class URL(object): else: return self.drivername.split('+')[1] - def get_dialect(self): - """Return the SQLAlchemy database dialect class corresponding - to this URL's driver name. - """ - + def _get_dialect_plus_entrypoint(self): if '+' not in self.drivername: name = self.drivername else: @@ -133,9 +129,17 @@ class URL(object): if hasattr(cls, 'dialect') and \ isinstance(cls.dialect, type) and \ issubclass(cls.dialect, Dialect): - return cls.dialect + return cls.dialect, cls.dialect else: - return cls + dialect_cls = cls.get_dialect_cls(self) + return cls, dialect_cls + + def get_dialect(self): + """Return the SQLAlchemy database dialect class corresponding + to this URL's driver name. + """ + entrypoint, dialect_cls = self._get_dialect_plus_entrypoint() + return dialect_cls def translate_connect_args(self, names=[], **kw): """Translate url attributes into a dictionary of connection arguments.