summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorKai Mueller <15907922+kasium@users.noreply.github.com>2021-12-01 10:58:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-12-01 13:22:46 -0500
commit20fe2a3dc2597b04338e8907883c6f4ea72518c8 (patch)
tree3c0069d12a995684481bdcca3d604f851ca7c9bc /lib/sqlalchemy
parent55e0497b080bf7f5159faa5abcb341269ebfdc7f (diff)
downloadsqlalchemy-20fe2a3dc2597b04338e8907883c6f4ea72518c8.tar.gz
Add __class_getitem__ to the declarative Base class
Fixed issue where the :func:`_orm.as_declarative` decorator and similar functions used to generate the declarative base class would not copy the ``__class_getitem__()`` method from a given superclass, which prevented the use of pep-484 generics in conjunction with the ``Base`` class. Pull request courtesy Kai Mueller. Fixes: #7368 Closes: #7381 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7381 Pull-request-sha: 7db7fd869a6bb617f767fad5b71ddf7cb5f14ff5 Change-Id: I495718c3082ad6dd2c83fdbf6feba7c529e351cb
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/orm/decl_api.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py
index 6bc857094..6951b3546 100644
--- a/lib/sqlalchemy/orm/decl_api.py
+++ b/lib/sqlalchemy/orm/decl_api.py
@@ -807,6 +807,8 @@ class registry:
class_dict["__abstract__"] = True
if mapper:
class_dict["__mapper_cls__"] = mapper
+ if hasattr(cls, "__class_getitem__"):
+ class_dict["__class_getitem__"] = cls.__class_getitem__
return metaclass(name, bases, class_dict)