Fix id flip

This commit is contained in:
2026-05-14 18:50:10 +02:00
parent 9384d905d1
commit 0e1001657a
2 changed files with 36 additions and 11 deletions
+3 -11
View File
@@ -311,7 +311,7 @@ func buildNativeUnchecked(p *project.Project, opts NativeBuildOptions, progress
if err != nil {
return BuildResult{}, err
}
lockAdded, lockPruned, err := saveNativeBaseLockfiles(collected)
lockAdded, lockPruned, err := saveNativeLockfiles(collected)
if err != nil {
return BuildResult{}, err
}
@@ -419,11 +419,11 @@ func nativeCompileGroup(datasetName string) string {
}
}
func saveNativeBaseLockfiles(collected []nativeCollectedDataset) (int, int, error) {
func saveNativeLockfiles(collected []nativeCollectedDataset) (int, int, error) {
added := 0
pruned := 0
for _, dataset := range collected {
if dataset.Dataset.Kind != nativeDatasetBase || dataset.Dataset.LockPath == "" {
if dataset.Dataset.LockPath == "" {
continue
}
current, err := loadLockfile(dataset.Dataset.LockPath)
@@ -2769,7 +2769,6 @@ func collectPlainDataset(dataset nativeDataset) (nativeCollectedDataset, error)
}
rows := make([]map[string]any, 0, len(rawRows))
lockModified := false
explicitID := make([]bool, 0, len(rawRows))
for index, raw := range rawRows {
rowObj, ok := raw.(map[string]any)
@@ -2804,7 +2803,6 @@ func collectPlainDataset(dataset nativeDataset) (nativeCollectedDataset, error)
usedIDs[nextID] = struct{}{}
nextID = nextAvailableID(usedIDs)
}
lockModified = true
continue
}
if !explicitID[index] {
@@ -2812,12 +2810,6 @@ func collectPlainDataset(dataset nativeDataset) (nativeCollectedDataset, error)
}
}
if lockModified {
if err := saveLockfile(dataset.LockPath, lockData); err != nil {
return nativeCollectedDataset{}, fmt.Errorf("dataset %s: %w", dataset.Name, err)
}
}
slices.SortFunc(rows, func(a, b map[string]any) int {
return a["id"].(int) - b["id"].(int)
})