You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well this is a issue outside of sqlc, but that can be addressed trough code generation.
The Exec() method of the sql.DB type, from the database/sql package, returns two values: an sql.Result interface and an error.
The sql.Result interface has two methods: LastInsertId(), that is self-explanatory, and RowsAffected(), that returns the amount of rows that were inserted, updated, or deleted, and this is what you want.
My proposed solution is to have all generated methods that were marked with an exec tag in the generating sql script to also return a sql.Result in addition to the error.
If you can't wait for a change in the library like this, you can go use this Stack Overflow answer to solve your problem.
If I issue a DELETE it would be nice to know whether 0, 1, or more rows were deleted, in an easy way.
I tried doing this, FYI
And got this at runtime (not compile time)
pq: aggregate functions are not allowed in RETURNING
The text was updated successfully, but these errors were encountered: