Obtaining TypeError: Cannot pickle 'module' object
on models with many-to-many relationships
#540
Open
8 tasks done
Labels
question
Further information is requested
First Check
Commit to Help
Example Code
Description
I upgraded a project to SQLModel version 0.0.8 and, after that, it started giving out
TypeError: cannot pickle 'module' object
on the models that had a many to many relationship through thelink_model
Relationship
attribute.I figured it was the many to many relationship since, after I deleted it from one of the models to test, that particular model stopped erroring out. However, there might be something else I'm missing that's causing the error. Either way, the error seems to happen only when there's a
Relationship
attribute with alink_model
for the many to many relation. I even tried to remove the__tablename__
attributes on the tables just in case that was messing something up, but I had no luck.I tried googling the issue and could not find any solution that would help on any front, so I'm currently at a loss. Closest match was a question where the OP was using SQLAlchemy directly, which I am NOT doing and so the solution proposed did not work for me. Any advice or guidance would be appreciated.
If it helps, I followed this example for the layout (though using PDM instead of Poetry): https://github.com/jonra1993/fastapi-alembic-sqlmodel-async.
Also, note that, before the upgrade to 0.0.8 (we were on 0.0.6 before), the
Relationship
attributes were completely non-functional, so they didn't error out (we did the joins manually to obtain the data).The full error dump looks as such:
The text was updated successfully, but these errors were encountered: