]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
add __init__ to DeclarativeBase directly
authorMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Jan 2023 19:37:33 +0000 (14:37 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sat, 28 Jan 2023 19:47:32 +0000 (14:47 -0500)
commit960f6dcefe24c6894844366ef6fff60fbcf1ccd6
treee7e00e7745618e0abff900e8855dfb6203681f26
parent586df197615d91af56aefc0d5ff94ceac13154eb
add __init__ to DeclarativeBase directly

Fixed regression in :class:`.DeclarativeBase` class where the registry's
default constructor would not be applied to the base itself, which is
different from how the previous :func:`_orm.declarative_base` construct
works. This would prevent a mapped class with its own ``__init__()`` method
from calling ``super().__init__()`` in order to access the registry's
default constructor and automatically populate attributes, instead hitting
``object.__init__()`` which would raise a ``TypeError`` on any arguments.

This is a very simple change in code, however explaining it is
very complicated.

Fixes: #9171
Change-Id: I4baecdf671861a8198d835e286fe19a51ecda126
doc/build/changelog/unreleased_20/9171.rst [new file with mode: 0644]
lib/sqlalchemy/orm/decl_api.py
test/orm/declarative/test_basic.py