]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
collect annotation earlier for mapped_column present
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 20 Oct 2022 16:05:33 +0000 (12:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 20 Oct 2022 16:09:32 +0000 (12:09 -0400)
commitfa6ce947a2804b71880d4fc768df01768f13543d
treeba488c4534364c13ffc31d93fea8cfccfec3bb74
parent7945ce44317869630f210c9afbbc2f44dfc4b821
collect annotation earlier for mapped_column present

Fixed issue with new dataclass mapping feature where arguments passed to
the dataclasses API could sometimes be mis-ordered when dealing with mixins
that override :func:`_orm.mapped_column` declarations, leading to
initializer problems.

the change made here is specific to the test case given which regards
mapped_column() most specifically.   cases that involve relationship()
etc. are not tested here, however mapped_column() is the only attribute
that's implicit without an instance given on the right side, and is also
most common for mixins.   not clear if there are more issues in this
area, however it appears that we need only adjust the order in which we
accommodate grabbing the annotations in order to affect how dataclasses
sees the class; that is, we have control over ``__annotations__`` here
so dont have to worry about ``cls.__dict__``.

Fixes: #8688
Change-Id: I808c86f23d73aa47cd910ae01c3e07093d469fdc
doc/build/changelog/unreleased_20/8688.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_base.py
test/orm/declarative/test_dc_transforms.py