Hi, I want to check does the delete action is success, the filter().delete() response NoneType. Thanks.
Hi, you want to find out if .delete() returns any data?
No, it does not.
Is there some data you would need?
No, I mean if we use .delete(), if the .delete() is success, it will return something like id of the deleted item or success message
It is a good suggestion. Right now it only ever returns None, but returning a success/count would be better.
It doesn't make sense to return the deleted objects, as they now longer exist.
Well, the fact that there is no exception raised is success message by itself.
Regarding returning something useful:
Problem is - standard SQL doesn't provide anything to get meaningful messages from deleting query.
So if we would want to implement such thing we would have to implement custom solution for each of backends (RETURNING for postgres, for sqlite we could try fetching something from changes() and we would have to do SELECT ROW_COUNT() for MySQL)
For now I am not sure it's really needed, and I am quite sure that it's shouldn't be default behavior because it adds overhead that is not required for most of users.
If we would add it I think interface should be something like this:
Event.filter(...).delete(return_details=True)
Hi, I released v0.15.7, please test if this issue is resolved :-)
Most helpful comment
Well, the fact that there is no exception raised is success message by itself.
Regarding returning something useful:
Problem is - standard SQL doesn't provide anything to get meaningful messages from deleting query.
So if we would want to implement such thing we would have to implement custom solution for each of backends (
RETURNINGfor postgres, for sqlite we could try fetching something fromchanges()and we would have to doSELECT ROW_COUNT()for MySQL)For now I am not sure it's really needed, and I am quite sure that it's shouldn't be default behavior because it adds overhead that is not required for most of users.
If we would add it I think interface should be something like this:
Event.filter(...).delete(return_details=True)