]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Check for hybrid's attribute name and support no name
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Apr 2021 14:26:31 +0000 (10:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 7 Apr 2021 14:26:31 +0000 (10:26 -0400)
commit475a1ada5d3ac88f12080ef8672a8fda70c7e76e
tree9279db69a507c329530f0ba227a88a9c0308ff9c
parentd1847bbe268d48d34f4781b317ac8e6bf13d44bd
Check for hybrid's attribute name and support no name

Fixed regression where the ORM compilation scheme would assume the function
name of a hybrid property would be the same as the attribute name in such a
way that an ``AttributeError`` would be raised, when it would attempt to
determine the correct name for each element in a result tuple. A similar
issue exists in 1.3 but only impacts the names of tuple rows. The fix here
adds a check that the hybrid's function name is actually present in the
``__dict__`` of the class or its superclasses before assigning this name;
otherwise, the hybrid is considered to be "unnamed" and ORM result tuples
will use the naming scheme of the underlying expression.

Fixes: #6215
Change-Id: I584c0c05efec957f4dcaccf5df371399a57dffe9
doc/build/changelog/unreleased_14/6215.rst [new file with mode: 0644]
lib/sqlalchemy/ext/hybrid.py
lib/sqlalchemy/orm/attributes.py
test/ext/test_hybrid.py