-
-
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
Enhancement: make .get_one
respect None filters
#187
Comments
Does this work? from sqlalchemy import null
obj = await repo.get_one(id='id', deleted_at=null()) |
You can also do something like this: from sqlalchemy import null
obj = await repo.get_one(MyModel.deleted_at.is_(None), id='id') Depending on the data type used, the |
No, under the hood
Looks like SA tries to convert this explicilty into DATETIME:
|
Yes, this is exactly my current workaround. But it would be nice to have it in kwargs either with |
Summary
I use soft delete for my models, and i try to get instance with repo like this:
because i dont want instance to be selected if it is deleted.
The problem is that with these kwargs i dont get any object at all, because the filter doesn't get converted to
deleted_at is null
for the db query but todeleted_at = 'None'
Is it as intended? For now the workaround to this is to pass custom statement to get_one, but its not very convenient.
Thank you.
Basic Example
No response
Drawbacks and Impact
No response
Unresolved questions
No response
The text was updated successfully, but these errors were encountered: