Closed jfly closed 2 years ago
I will let @josephmancuso answer this one.
In the meantime, could you move this issue to Masonite ORM repository ? This question belongs there. In the future it will help people with the same questions finding the answer there. 🙏
Oops, sorry! Reading through https://docs.github.com/en/issues/tracking-your-work-with-issues/transferring-an-issue-to-another-repository, I don't think I have the power to transfer this issue. I can close this and open a new issue of you like. Or perhaps you or another admin could transfer the issue?
Theres currently no way to do this now but it COULD be possible by getting the values from the databases cursor object
I would assume this would be a breaking change though if we changed the delete method to return the number of rows affected
Yes, for a pymysql connection you could use something like: connection.get_cursor().rowcount
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
Is 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 whatdelete
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 returnsself
, when it actually returns the result ofself.new_connection().query
...Describe alternatives you've considered
No response
Would this be a breaking change ?
Anything else ?
No response