Is there some way to get the number of rows deleted by a query builder's `delete` method?
See original GitHub issueIs your feature request related to a problem?
The query builder docs mention a delete method: https://orm.masoniteproject.com/query-builder#deletes, but I don’t see any way of figuring out how many rows were affected by that delete.
What do we currently have to do now?
Right now, I’m turning around and immediately doing a SELECT ROW_COUNT() query, which may be a MySQL specific solution.
Describe the solution you’d like
It would be nice to have a standard way of fetching the number of rows affected by the delete. Perhaps delete() could return the count of deleted rows? I’m not sure if that would count as a breaking change or not. The docs don’t seem to mention what delete returns, but the implementation clearly does return… something: https://github.com/MasoniteFramework/orm/blob/685a30409cd4b971c24c932d78b684a2be085f58/src/masoniteorm/query/QueryBuilder.py#L530-L565, although the docstring disagrees with the implementation: the docstring says it returns self, when it actually returns the result of self.new_connection().query…
Describe alternatives you’ve considered
No response
Would this be a breaking change ?
- Yes
Anything else ?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)

Top Related StackOverflow Question
I will work on this one but it won’t be available until Masonite ORM 3 around September since this is changing existing functionality in a way that could not be backwards compatable
This wil also be a bit tricky because the SoftDeleteMixin changes the DELETE to an UPDATE. so will need to figure out how to get the results for an update clause as well