]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
remove compare_against_backend from tests and docs
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Oct 2023 20:15:07 +0000 (16:15 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 17 Oct 2023 20:15:07 +0000 (16:15 -0400)
Change-Id: I6f480711ec94cd4113d3f0ca114d143b49b8d869
Fixes: #1293
docs/build/autogenerate.rst
docs/build/changelog.rst
tests/test_autogen_diffs.py

index 6a66c2e698eed3bcb04b3a3948049a710fa3694f..a63971771c6f9a06014005d9d0872edd339db591 100644 (file)
@@ -647,47 +647,6 @@ returned by
 local model environment.  A return value of ``None`` indicates that default
 type comparison to proceed.
 
-Additionally, custom types that are part of imported or third party
-packages which have special behaviors such as per-dialect behavior
-should implement a method called ``compare_against_backend()``
-on their SQLAlchemy type.   If this method is present, it will be called
-where it can also return True or False to specify the types compare as
-equivalent or not; if it returns None, default type comparison logic
-will proceed::
-
-    class MySpecialType(TypeDecorator):
-
-        # ...
-
-        def compare_against_backend(self, dialect, conn_type):
-            # return True if this type is the same as the given database type,
-            # or None to allow the default implementation to compare these
-            # types. a return value of False means the given type does not
-            # match this type.
-
-            if dialect.name == 'postgresql':
-                return isinstance(conn_type, postgresql.UUID)
-            else:
-                return isinstance(conn_type, String)
-
-.. warning::
-
-    The boolean return values for the above
-    ``compare_against_backend`` method, which is part of SQLAlchemy and not
-    Alembic, are **the opposite** of that of the
-    :paramref:`.EnvironmentContext.configure.compare_type` callable, returning
-    ``True`` for types that are the same vs. ``False`` for types that are
-    different. The :paramref:`.EnvironmentContext.configure.compare_type`
-    callable on the other hand should return ``True`` for types that are
-    **different**.
-
-The order of precedence regarding the
-:paramref:`.EnvironmentContext.configure.compare_type` callable vs. the
-type itself implementing ``compare_against_backend`` is that the
-:paramref:`.EnvironmentContext.configure.compare_type` callable is favored
-first; if it returns ``None``, then the ``compare_against_backend`` method
-will be used, if present on the metadata type.  If that returns ``None``,
-then the default check for type equivalence is run.
 
 .. _post_write_hooks:
 
index 4c8024c55a3a8bec5c30a6069f33b84724364a5c..e0a7d753b008ebd7491de3962feb742e52e50b05 100644 (file)
@@ -1722,6 +1722,9 @@ Changelog
         also be resolved.   Thanks very much to Paul Becotte  for lots of hard work
         and patience on this one.
 
+        .. note:: *updated* - this change also removes support for the
+           ``compare_against_backend`` SQLAlchemy type hook.
+
         .. seealso::
 
             :ref:`autogenerate_detects` - updated comments on type comparison
@@ -3509,6 +3512,7 @@ Changelog
       Added a new documentation section :ref:`compare_types` describing
       type comparison fully.
 
+
     .. change::
       :tags: feature, operations
       :tickets: 255
index 8a2cf9969283d85388a3650cb8368ba76bc1d38d..2a622aeed614677cf212d0f17c1239eeafd1836c 100644 (file)
@@ -627,9 +627,6 @@ class AutogenerateDiffTest(ModelOne, AutogenTest, TestBase):
         class MyType(TypeDecorator):
             impl = Integer
 
-            def compare_against_backend(self, dialect, conn_type):
-                return isinstance(conn_type, Integer)
-
         ac = ops.AlterColumnOp("sometable", "somecol")
         autogenerate.compare._compare_type(
             self.autogen_context,