]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Adjustments to the engine plugin hook, such that the
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 22 May 2015 17:51:00 +0000 (13:51 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 22 May 2015 17:51:00 +0000 (13:51 -0400)
: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

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/engine/strategies.py
lib/sqlalchemy/engine/url.py

index 291382ba13c5c9eaf9b2847c7c1c373c700d2275..917485582d484dc9571f98bbceb23789a116a35e 100644 (file)
 .. 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
index a802e5d90eafdf1b83fceb77894d2ff3abeaea72..e2a086de42cee556593f1bef61eece9588374063 100644 (file)
@@ -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):
index d045961dd63889044499ad0035a3ded2df6ac536..07f6a5730a708f7649de75a27372e3a781b0ca3d 100644 (file)
@@ -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.