diff options
Diffstat (limited to 'internal/postgres')
| -rw-r--r-- | internal/postgres/unit.go | 11 | ||||
| -rw-r--r-- | internal/postgres/unit_test.go | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/internal/postgres/unit.go b/internal/postgres/unit.go index 7c7e9c66..b2528f48 100644 --- a/internal/postgres/unit.go +++ b/internal/postgres/unit.go @@ -316,10 +316,17 @@ func (db *DB) getUnitID(ctx context.Context, fullPath, modulePath, resolvedVersi func (db *DB) getImports(ctx context.Context, unitID int) (_ []string, err error) { defer derrors.WrapStack(&err, "getImports(ctx, %d)", unitID) defer middleware.ElapsedStat(ctx, "getImports")() - return collectStrings(ctx, db.db, ` + query := ` SELECT to_path FROM package_imports - WHERE unit_id = $1`, unitID) + WHERE unit_id = $1` + if experiment.IsActive(ctx, internal.ExperimentReadImports) { + query = ` + SELECT p.path + FROM paths p INNER JOIN imports i ON p.id = i.to_path_id + WHERE i.unit_id = $1` + } + return collectStrings(ctx, db.db, query, unitID) } // getPackagesInUnit returns all of the packages in a unit from a diff --git a/internal/postgres/unit_test.go b/internal/postgres/unit_test.go index 64e0b57f..c60941b7 100644 --- a/internal/postgres/unit_test.go +++ b/internal/postgres/unit_test.go @@ -743,7 +743,12 @@ func TestGetUnit(t *testing.T) { test.want.IsRedistributable, ) test.want.CommitTime = um.CommitTime - checkUnit(ctx, t, testDB, um, test.want) + t.Run("none", func(t *testing.T) { + checkUnit(ctx, t, testDB, um, test.want) + }) + t.Run(internal.ExperimentReadImports, func(t *testing.T) { + checkUnit(ctx, t, testDB, um, test.want, internal.ExperimentReadImports) + }) }) } } |
