Bug: delete_where fail sanity check when a service is initialized with statment
#286
Open
1 of 4 tasks
Labels
bug
Something isn't working
lambda-stmt
Related to `lambda_stmt` in SQLAlchemy. Not necessarily an `advanced-alchemy` bug.
Description
This is somewhat unexpected behavior,
Since delete is not using the base statement from the service, sanity checks may fail.
For example,
I have a service which limit the access by my tenant_id:
Now let's say I try to delete a resource which is not in my tenant, I expect to get NotFoundError, but in this case I'll get Sanity Check Failed exception.
Unless I'll provide the same filters I provided with the statement.
A possible solution, which I'm thinking to do and create a PR (if I'll have time)
Is have the
new
method getfilters
and build the statement internally, this way these "global" filters can be applied to thedelete_where
and the behavior will be more predictable.URL to code causing the issue
No response
MCVE
No response
Steps to reproduce
No response
Screenshots
Logs
No response
Package Version
v0.23.1
Platform
The text was updated successfully, but these errors were encountered: