Need to get sql.Result from genericDestroy()
Description
While trying to delete a record by ID, via Destroy(), it will be great help for us to know the affected rows information instead of just success or not by error as the return value.
After digging into the code, I found that in dialect.go calls genericExec() to execute SQL command, it can obtain sql.Result which contains the information regarding to affected rows but it drops it.
...
_, err := s.Exec(stmt)
...
It's better to keep the information and return to caller to make decision.
Steps to Reproduce the Problem
- Create a record by ValidateAndCreate()
- Delete the record by Destroy()
- Verify the return value from Destroy(), I can only know if error occurs or not but not affected rows.
Expected Behavior
I can get both result and error information from Destroy()
I dug into this a little, if I am not mistaken, there are two ways you can use .Destroy, you could pass in a single record or you could pass in a slice. In either scenario, as long as no errors occur, would you not know the number of records affected? It would be the number of records you passed in to .Destroy.
I think it would be better if the function would return affected no. of rows as a return value along with the error. Let me know if it is fine. I would like to give a shot.
It will be great to get the no. of rows along with error!
@sivagollapalli If you can make it without breaking changes, go ahead. :) Otherwise, you'll have to introduce a variant for the impacted function(s).