uselist not inferred correctly for relationship when a non-string type annotation is used in Mapped #10815
Labels
bug
Something isn't working
near-term release
addition to the milestone which indicates this should be in a near-term release
orm - annotated declarative
issues with the new annotations-based declarative ORM approach
orm
Milestone
Describe the bug
It seems that the one-to-one example for a relationship does not infer correctly the
uselist
value if the mapped argument is not a string annotation.The difference is in the value inferred for uselist in the
Parent.child
relationship, that is correctly inferred toFalse
in the example, while it is inferred toTrue
if the type annotation forchild
is changed toMapped[Child]
.In the docs of the uselist parameter (https://docs.sqlalchemy.org/en/20/orm/relationship_api.html#sqlalchemy.orm.relationship.params.uselist) it is stated that uselist may be derived from whether the mapped argument is a collection or not, but in this case
Mapped[Child]
is not a collection, so I would expect uselist set toFalse
.Optional link from https://docs.sqlalchemy.org which documents the behavior that is expected
https://docs.sqlalchemy.org/en/20/orm/relationship_api.html#sqlalchemy.orm.relationship.params.uselist
SQLAlchemy Version in Use
2.0.24
DBAPI (i.e. the database driver)
psycopg2
Database Vendor and Major Version
PostgreSQL 13
Python Version
3.10
Operating system
Windows
To Reproduce
Error
Additional context
No response
The text was updated successfully, but these errors were encountered: