diff options
| author | Jonathan Amsterdam <jba@google.com> | 2020-09-03 17:59:03 -0400 |
|---|---|---|
| committer | Jonathan Amsterdam <jba@google.com> | 2020-09-09 15:03:16 +0000 |
| commit | 958591c5a38d9791928b7dc6dcb9076c86275553 (patch) | |
| tree | 5a9a2b4efc1fdd74be52ac4fc23d77b6adf88387 /internal/postgres/versionstate.go | |
| parent | 9d1142edd71c8519c1512a0c6a3a58a958849921 (diff) | |
| download | go-x-pkgsite-958591c5a38d9791928b7dc6dcb9076c86275553.tar.xz | |
internal/database: change Exec to return rows affected
Change Exec so it return the number of rows affected by
the statement, rather than a sql.Result.
- We never use the other methods of sql.Result.
- It's annoying to get the number of affected rows from a sql.Result
because of the error return value.
- Examination of github.com/lib/pq shows that there is no extra cost
to calling sql.Result.RowsAffected after an Exec.
Change-Id: If16a15cbabf38755518732c4489109e0b01f2cd1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/253079
Reviewed-by: Julie Qiu <julie@golang.org>
Diffstat (limited to 'internal/postgres/versionstate.go')
| -rw-r--r-- | internal/postgres/versionstate.go | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/internal/postgres/versionstate.go b/internal/postgres/versionstate.go index c7dcbfc0..69178f7f 100644 --- a/internal/postgres/versionstate.go +++ b/internal/postgres/versionstate.go @@ -79,7 +79,7 @@ func upsertModuleVersionState(ctx context.Context, db *database.DB, modulePath, sqlErrorMsg = fetchErr.Error() } - result, err := db.Exec(ctx, ` + affected, err := db.Exec(ctx, ` INSERT INTO module_version_states AS mvs ( module_path, version, @@ -116,10 +116,6 @@ func upsertModuleVersionState(ctx context.Context, db *database.DB, modulePath, if err != nil { return err } - affected, err := result.RowsAffected() - if err != nil { - return fmt.Errorf("result.RowsAffected(): %v", err) - } if affected != 1 { return fmt.Errorf("module version state update affected %d rows, expected exactly 1", affected) } |
