Skip to content

Commit cfd1df2

Browse files
committed
internal/postgres: read and write deprecated comment
Insert the deprecated comment into the modules table, and read it back out. For golang/go#41321 Change-Id: Ib4f2c8ceb70e28940b18f52d25b2a0d05c57648d Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/290098 Trust: Jonathan Amsterdam <[email protected]> Run-TryBot: Jonathan Amsterdam <[email protected]> TryBot-Result: kokoro <[email protected]> Reviewed-by: Jamal Carvalho <[email protected]>
1 parent f88089b commit cfd1df2

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

internal/postgres/details.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func (db *DB) GetNestedModules(ctx context.Context, modulePath string) (_ []*int
3131
m.commit_time,
3232
m.redistributable,
3333
m.has_go_mod,
34+
m.deprecated_comment,
3435
m.source_info
3536
FROM
3637
modules m
@@ -146,6 +147,7 @@ func (db *DB) GetModuleInfo(ctx context.Context, modulePath, resolvedVersion str
146147
commit_time,
147148
redistributable,
148149
has_go_mod,
150+
deprecated_comment,
149151
source_info
150152
FROM
151153
modules
@@ -197,7 +199,7 @@ func (s jsonbScanner) Scan(value interface{}) (err error) {
197199
func scanModuleInfo(scan func(dest ...interface{}) error) (*internal.ModuleInfo, error) {
198200
var mi internal.ModuleInfo
199201
if err := scan(&mi.ModulePath, &mi.Version, &mi.CommitTime,
200-
&mi.IsRedistributable, &mi.HasGoMod, jsonbScanner{&mi.SourceInfo}); err != nil {
202+
&mi.IsRedistributable, &mi.HasGoMod, &mi.DeprecatedComment, jsonbScanner{&mi.SourceInfo}); err != nil {
201203
return nil, err
202204
}
203205
return &mi, nil

internal/postgres/insert_module.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,9 @@ func insertModule(ctx context.Context, db *database.DB, m *internal.Module) (_ i
176176
source_info,
177177
redistributable,
178178
has_go_mod,
179+
deprecated_comment,
179180
incompatible)
180-
VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
181+
VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)
181182
ON CONFLICT
182183
(module_path, version)
183184
DO UPDATE SET
@@ -193,6 +194,7 @@ func insertModule(ctx context.Context, db *database.DB, m *internal.Module) (_ i
193194
sourceInfoJSON,
194195
m.IsRedistributable,
195196
m.HasGoMod,
197+
m.DeprecatedComment,
196198
isIncompatible(m.Version),
197199
).Scan(&moduleID)
198200
if err != nil {

internal/postgres/insert_module_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ func TestInsertModule(t *testing.T) {
5757
name: "stdlib",
5858
module: sample.Module("std", "v1.12.5", "context"),
5959
},
60+
{
61+
name: "deprecated",
62+
module: func() *internal.Module {
63+
m := sample.DefaultModule()
64+
c := "use v2"
65+
m.DeprecatedComment = &c
66+
return m
67+
}(),
68+
},
6069
} {
6170
t.Run(test.name, func(t *testing.T) {
6271
defer ResetTestDB(testDB, t)

internal/postgres/path_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
func TestGetLatestMajorPathForV1Path(t *testing.T) {
17-
ctx, cancel := context.WithTimeout(context.Background(), testTimeout)
17+
ctx, cancel := context.WithTimeout(context.Background(), testTimeout*2)
1818
defer cancel()
1919

2020
checkLatest := func(t *testing.T, versions []string, v1path string, version, suffix string) {

internal/postgres/version.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func getPathVersions(ctx context.Context, db *DB, path string, versionTypes ...v
5050
m.commit_time,
5151
m.redistributable,
5252
m.has_go_mod,
53+
m.deprecated_comment,
5354
m.source_info
5455
FROM modules m
5556
INNER JOIN units u

0 commit comments

Comments
 (0)