]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Added a placeholder method :meth:`.TypeEngine.compare_against_backend`
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Apr 2015 15:38:24 +0000 (11:38 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 30 Apr 2015 15:38:24 +0000 (11:38 -0400)
which is now consumed by Alembic migrations as of 0.7.6.  User-defined
types can implement this method to assist in the comparison of
a type against one reflected from the database.

doc/build/changelog/changelog_10.rst
lib/sqlalchemy/sql/type_api.py

index 1e67221f52068dfb983e16c52c0413ebf51ed339..5e32c667fb3ba753af5a11fd994a07460812fb8d 100644 (file)
 .. changelog::
     :version: 1.0.3
 
+    .. change::
+        :tags: feature, sql
+
+        Added a placeholder method :meth:`.TypeEngine.compare_against_backend`
+        which is now consumed by Alembic migrations as of 0.7.6.  User-defined
+        types can implement this method to assist in the comparison of
+        a type against one reflected from the database.
+
     .. change::
         :tags: bug, orm
         :tickets: 3402
index 4660850bde90e3c14d04594b24e57b0ac33df2f5..a55eed98114663b79889992f70c24751d34d8a43 100644 (file)
@@ -128,6 +128,33 @@ class TypeEngine(Visitable):
 
     """
 
+    def compare_against_backend(self, dialect, conn_type):
+        """Compare this type against the given backend type.
+
+        This function is currently not implemented for SQLAlchemy
+        types, and for all built in types will return ``None``.  However,
+        it can be implemented by a user-defined type
+        where it can be consumed by schema comparison tools such as
+        Alembic autogenerate.
+
+        A future release of SQLAlchemy will potentially impement this method
+        for builtin types as well.
+
+        The function should return True if this type is equivalent to the
+        given type; the type is typically reflected from the database
+        so should be database specific.  The dialect in use is also
+        passed.   It can also return False to assert that the type is
+        not equivalent.
+
+        :param dialect: a :class:`.Dialect` that is involved in the comparison.
+
+        :param conn_type: the type object reflected from the backend.
+
+        .. versionadded:: 1.0.3
+
+        """
+        return None
+
     def copy_value(self, value):
         return value