SelectQuery has ScanAndCount, but UpdateQuery, InsertQuery, DeleteQuery do not
As described by the title, SelectQuery has ScanAndCount, a convenience method for processing rows and counting them at the same time.
Normally, inserts/updates/deletes don't return rows and are invoked with Exec, which returns a row count, and therefore it's not necessary to do anything special to count the number of rows they operate on. But they can return rows if the RETURNING clause is used, in which case they need to be processed with Scan instead. However, they lack a corresponding ScanAndCount method, which limits the practical usefulness of this (it becomes difficult to e.g. check whether a given operation did anything significant, or operated on 0 rows because of the query's filter).
Can the ScanAndCount and any similar functions be be implemented for all query types which have the ability to produce rows?
You can use res.RowsAffected as the count. We probably can support ScanAndCount as well...
Scan() doesn't return an sql.Result, only an error. If I use Exec() will it actually capture the result rows? My impression was that it wouldn't but the docs aren't clear and I didn't try it.