From f2b36ede482403a1d7631dca4cf7151898472598 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 18 Dec 2022 15:35:39 -0500 Subject: remove __allow_unmapped__ requirement from dataclasses Removed the requirement that the ``__allow_unmapped__`` attribute be used on Declarative Dataclass Mapped class when non-``Mapped[]`` annotations are detected; previously, an error message that was intended to support legacy ORM typed mappings would be raised, which additionally did not mention correct patterns to use with Dataclasses specifically. This error message is now no longer raised if :meth:`_orm.registry.mapped_as_dataclass` or :class:`_orm.MappedAsDataclass` is used. Fixes: #8973 Change-Id: I887afcc2da83dd904444bcb97f31e695b9f8b443 --- lib/sqlalchemy/orm/decl_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/sqlalchemy/orm/decl_base.py b/lib/sqlalchemy/orm/decl_base.py index 797828377..db1fafa4c 100644 --- a/lib/sqlalchemy/orm/decl_base.py +++ b/lib/sqlalchemy/orm/decl_base.py @@ -516,7 +516,7 @@ class _ClassScanMapperConfig(_MapperConfig): self.allow_unmapped_annotations = getattr( self.cls, "__allow_unmapped__", False - ) + ) or bool(self.dataclass_setup_arguments) self.is_dataclass_prior_to_mapping = cld = dataclasses.is_dataclass( cls_ -- cgit v1.2.1