From: Mike Bayer Date: Tue, 17 Oct 2023 20:15:07 +0000 (-0400) Subject: remove compare_against_backend from tests and docs X-Git-Tag: rel_1_12_1~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b37d3d0ad7b0ed949fa895c5051e9d144f86698f;p=thirdparty%2Fsqlalchemy%2Falembic.git remove compare_against_backend from tests and docs Change-Id: I6f480711ec94cd4113d3f0ca114d143b49b8d869 Fixes: #1293 --- diff --git a/docs/build/autogenerate.rst b/docs/build/autogenerate.rst index 6a66c2e6..a6397177 100644 --- a/docs/build/autogenerate.rst +++ b/docs/build/autogenerate.rst @@ -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: diff --git a/docs/build/changelog.rst b/docs/build/changelog.rst index 4c8024c5..e0a7d753 100644 --- a/docs/build/changelog.rst +++ b/docs/build/changelog.rst @@ -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 diff --git a/tests/test_autogen_diffs.py b/tests/test_autogen_diffs.py index 8a2cf996..2a622aee 100644 --- a/tests/test_autogen_diffs.py +++ b/tests/test_autogen_diffs.py @@ -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,