Closed
Description
i can fix this but I have to make declarative meta look at cls.__dict__
, and that's confusing me. What's "dict_" then ? shrugs. lets just run through CI
class Base:
def __init_subclass__(cls) -> None:
cls.id = Column(Integer, primary_key=True)
Base = registry.generate_base(cls=Base)
class Foo(Base):
__tablename__ = 'foo'
name = Column(String)
self.assert_compile(select(Foo), "SELECT foo.name, foo.id FROM foo")
1.4 tentative
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
sqla-tester commentedon Apr 4, 2022
Mike Bayer has proposed a fix for this issue in the main branch:
read from cls.dict so init_subclass works https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3769
sqla-tester commentedon Apr 4, 2022
Mike Bayer has proposed a fix for this issue in the rel_1_4 branch:
read from cls.dict so init_subclass works https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3770
read from cls.__dict__ so init_subclass works
subhashb commentedon May 8, 2022
@zzzeek Does this change alter our discussion in #6791?
As per that discussion:
I had changed my code to populate the dictionary passed into
__init__
instead ofcls.__dict__
. Now, 1.4.36 breaks my code, while 1.4.35 works.What do you suggest?
zzzeek commentedon May 8, 2022
yes.
populate both
class.__dict__
anddict_
.zzzeek commentedon May 8, 2022
or, block SQLAlchemy versions from 1.4.10 -> 1.4.35 and revert your code to what you had previously in #6791
subhashb commentedon May 10, 2022
I will go the route of populating both
dict_
andclass.__dict__
as I need to accommodate both pre and post 1.4.36 changes.