internal/postgres: delete LegacyGetimports
For golang/go#39629
Change-Id: Ie22dd9759a0d37cbb64c68ed578ba4bb852237e0
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/258281
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
diff --git a/internal/postgres/details.go b/internal/postgres/details.go
index 6d03ab3..a3f9cb6 100644
--- a/internal/postgres/details.go
+++ b/internal/postgres/details.go
@@ -124,44 +124,6 @@
return packages, nil
}
-// LegacyGetImports fetches and returns all of the imports for the package with
-// pkgPath, modulePath and version.
-//
-// The returned error may be checked with derrors.IsInvalidArgument to
-// determine if it resulted from an invalid package path or version.
-func (db *DB) LegacyGetImports(ctx context.Context, pkgPath, modulePath, resolvedVersion string) (paths []string, err error) {
- defer derrors.Wrap(&err, "DB.LegacyGetImports(ctx, %q, %q, %q)", pkgPath, modulePath, resolvedVersion)
-
- if pkgPath == "" || resolvedVersion == "" || modulePath == "" {
- return nil, fmt.Errorf("pkgPath, modulePath and version must all be non-empty: %w", derrors.InvalidArgument)
- }
-
- query := `
- SELECT to_path
- FROM imports
- WHERE
- from_path = $1
- AND from_version = $2
- AND from_module_path = $3
- ORDER BY
- to_path;`
- var (
- toPath string
- imports []string
- )
- collect := func(rows *sql.Rows) error {
- if err := rows.Scan(&toPath); err != nil {
- return fmt.Errorf("row.Scan(): %v", err)
- }
- imports = append(imports, toPath)
- return nil
- }
- if err := db.db.RunQuery(ctx, query, collect, pkgPath, resolvedVersion, modulePath); err != nil {
- return nil, err
- }
- return imports, nil
-}
-
// GetImportedBy fetches and returns all of the packages that import the
// package with path.
// The returned error may be checked with derrors.IsInvalidArgument to
diff --git a/internal/postgres/details_test.go b/internal/postgres/details_test.go
index 04c4c2b..03087cd 100644
--- a/internal/postgres/details_test.go
+++ b/internal/postgres/details_test.go
@@ -8,7 +8,6 @@
"context"
"encoding/json"
"errors"
- "sort"
"testing"
"github.com/google/go-cmp/cmp"
@@ -271,7 +270,7 @@
}
}
-func TestPostgres_GetImportsAndImportedBy(t *testing.T) {
+func TestGetImportedBy(t *testing.T) {
var (
m1 = sample.Module("path.to/foo", "v1.1.0", "bar")
m2 = sample.Module("path2.to/foo", "v1.2.0", "bar2")
@@ -339,15 +338,6 @@
t.Error(err)
}
}
- got, err := testDB.LegacyGetImports(ctx, tc.path, tc.modulePath, tc.version)
- if err != nil {
- t.Fatal(err)
- }
-
- sort.Strings(tc.wantImports)
- if diff := cmp.Diff(tc.wantImports, got); diff != "" {
- t.Errorf("testDB.GetImports(%q, %q) mismatch (-want +got):\n%s", tc.path, tc.version, diff)
- }
gotImportedBy, err := testDB.GetImportedBy(ctx, tc.path, tc.modulePath, 100)
if err != nil {