python
module_error
ai_generated
true
sqlalchemy.exc.InvalidRequestError: When initializing mapper Mapper[User(users)], expression 'addresses' failed to locate a name
ID: python/sqlalchemy-exc-invalid-request-relationship-not-loaded
80%Fix Rate
84%Confidence
0Evidence
2024-12-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
A relationship attribute in the ORM model references another class or attribute that is not defined or imported correctly.
generic中文
ORM 模型中的关系属性引用了另一个未正确定义或导入的类或属性。
Workarounds
-
95% success Import target class before usage
Ensure the referenced class is imported and defined before the model using it, e.g., from models import Address.
-
90% success Use string reference for relationship
Use string-based relationship targets like 'Address' if the class is defined later in the same module.
Dead Ends
Common approaches that don't work:
- Renaming the attribute only 60% fail
- Deleting the relationship 50% fail