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
:exec only checks the error :execresult returns the full sql.Result :execrows returns the sql.Result.RowsAffected() (int64, error)
We just need one more return type to support the full interface:
:execlastinsertid would just be a matter of calling .LastInsertId() rather than .RowsAffected() on the sql.Result.
This will avoid sql.Result database information leaking across the boundary of the pkg.Querier interface. It's not good for the service code to be handling DB specific method calls. This is a MySQL/SQLite issue as Postgres uses RETURNING so you can use :one instead.
Unfortunately, there are a lot of companies still running older MySQL installs. In addition, using sqlc with products like TiDB or https://vitess.io/ would also require this.
:exec
only checks the error:execresult
returns the full sql.Result:execrows
returns the sql.Result.RowsAffected() (int64, error)
We just need one more return type to support the full interface:
:execlastinsertid
would just be a matter of calling.LastInsertId()
rather than.RowsAffected()
on the sql.Result.This will avoid
sql.Result
database information leaking across the boundary of thepkg.Querier
interface. It's not good for the service code to be handling DB specific method calls. This is a MySQL/SQLite issue as Postgres usesRETURNING
so you can use:one
instead.Solution: duplicate the template code used for :execrows
The text was updated successfully, but these errors were encountered: