]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add additional test cases re: #11371
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Jun 2024 16:13:28 +0000 (12:13 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 26 Jun 2024 16:15:03 +0000 (12:15 -0400)
Just want to make sure aliased() and with_polymorphic() still
work in the of_type() context here, since that's likely why we
had Any for this parameter in the first place

Change-Id: I0a2c4445bc3b91039b3446d31b4a02db28feaee7

test/typing/plain_files/orm/relationship.py

index 683e347f19f153436759140dae4254e2179fa33e..44090ad53b4ea5d7a6fba4a5be41a8751c9ee64a 100644 (file)
@@ -16,6 +16,7 @@ from sqlalchemy import ForeignKey
 from sqlalchemy import Integer
 from sqlalchemy import select
 from sqlalchemy import Table
+from sqlalchemy.orm import aliased
 from sqlalchemy.orm import DeclarativeBase
 from sqlalchemy.orm import joinedload
 from sqlalchemy.orm import Mapped
@@ -24,6 +25,7 @@ from sqlalchemy.orm import registry
 from sqlalchemy.orm import Relationship
 from sqlalchemy.orm import relationship
 from sqlalchemy.orm import Session
+from sqlalchemy.orm import with_polymorphic
 
 
 class Base(DeclarativeBase):
@@ -164,6 +166,15 @@ if typing.TYPE_CHECKING:
     # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Engineer\]
     reveal_type(Team.employees.of_type(Engineer))
 
+    # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Employee\]
+    reveal_type(Team.employees.of_type(aliased(Employee)))
+
+    # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Engineer\]
+    reveal_type(Team.employees.of_type(aliased(Engineer)))
+
+    # EXPECTED_RE_TYPE: sqlalchemy.*.QueryableAttribute\[relationship.Employee\]
+    reveal_type(Team.employees.of_type(with_polymorphic(Employee, [Engineer])))
+
 
 mapper_registry: registry = registry()