-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Can't have nullable relationship #227
Comments
Are you sure this is the code you're running? I can't seem to reproduce this |
Yup, can still see it :/ Just recreated in a new python 3.10.6 venv to be doubly sure. Copied code above as app.py
pip freeze:
Full traceback if it's helpful:
For experiments sake if I changed the
then it works (I know it's not correct, I'm just not sure how to get the mapped type hint of elem) |
Any ideas on this? The workaround I suggested is obviously not the best! |
I had a similar discussion (actually referencing this issue) in discord. I could reproduce the same behaviour with SQLAlchemy itself, so I think it's specific to Litestar rather than advanced alchemy. Regardless, Cofin is aware of the issue: https://discord.com/channels/919193495116337154/1262488171023695919 |
Ah okay, thanks! I'll keep a look out 👀 I wasn't sure where the problem was but given I could change a file in here to fix it, I assumed this was the place 🤦 |
Setting |
Description
If I want a one to one relationship that is nullable I can create some tables like this:
However, if I try a get route in litestar to retrieve a row from the db where bar is not present in foo, I get:
I think this is because the function
detect_nullable_relationship
doesn't check if it itself is mapped as optional (if the relationship is a one to many)?URL to code causing the issue
No response
MCVE
Package Version
0.16.0
Platform
The text was updated successfully, but these errors were encountered: