summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-04-30 11:38:24 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-04-30 11:38:24 -0400
commit606a9b02e5c6081878aa331d1d2c3a678a671904 (patch)
treec185c641f737947deb9a3af6b6151f6212b3e63f
parentb0be9211c9a2d9032b659b63888ffc76f64d4247 (diff)
downloadsqlalchemy-606a9b02e5c6081878aa331d1d2c3a678a671904.tar.gz
- 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.
-rw-r--r--doc/build/changelog/changelog_10.rst8
-rw-r--r--lib/sqlalchemy/sql/type_api.py27
2 files changed, 35 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_10.rst b/doc/build/changelog/changelog_10.rst
index 1e67221f5..5e32c667f 100644
--- a/doc/build/changelog/changelog_10.rst
+++ b/doc/build/changelog/changelog_10.rst
@@ -19,6 +19,14 @@
: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
diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py
index 4660850bd..a55eed981 100644
--- a/lib/sqlalchemy/sql/type_api.py
+++ b/lib/sqlalchemy/sql/type_api.py
@@ -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