"first_null_row" configuration option
This commit is contained in:
@@ -265,7 +265,7 @@ func ValidateProject(p *project.Project) ValidationReport {
|
||||
validateTopPackageAssets(sourceDir, dataDir, &report)
|
||||
validateNativeOutputCatalog(dataDir, &report)
|
||||
validateNativeEntryKeyUniqueness(dataDir, &report)
|
||||
validateNativeLockAllocation(dataDir, &report)
|
||||
validateNativeLockAllocation(dataDir, p.EffectiveConfig().TopData.RowGeneration, &report)
|
||||
validateGeneratedFeatFamilies(dataDir, &report)
|
||||
validateItempropsRegistryGraph(dataDir, &report)
|
||||
if _, err := os.Stat(statePath); err == nil {
|
||||
@@ -273,7 +273,7 @@ func ValidateProject(p *project.Project) ValidationReport {
|
||||
_ = validateJSONFile(statePath, "state", &report)
|
||||
}
|
||||
if !report.HasErrors() {
|
||||
validateNativeAuthoringWarnings(dataDir, &report)
|
||||
validateNativeAuthoringWarnings(dataDir, p.EffectiveConfig().TopData.RowGeneration, &report)
|
||||
validateNativeBuildability(p, &report)
|
||||
}
|
||||
|
||||
@@ -1089,7 +1089,7 @@ func validateNativeEntryKeyUniqueness(dataDir string, report *ValidationReport)
|
||||
}
|
||||
}
|
||||
|
||||
func validateNativeLockAllocation(dataDir string, report *ValidationReport) {
|
||||
func validateNativeLockAllocation(dataDir string, rowGeneration []project.TopDataRowGenerationConfig, report *ValidationReport) {
|
||||
datasets, err := discoverNativeDatasets(dataDir)
|
||||
if err != nil {
|
||||
report.Diagnostics = append(report.Diagnostics, Diagnostic{
|
||||
@@ -1099,6 +1099,7 @@ func validateNativeLockAllocation(dataDir string, report *ValidationReport) {
|
||||
})
|
||||
return
|
||||
}
|
||||
datasets = applyTopDataRowGeneration(datasets, rowGeneration)
|
||||
for _, dataset := range datasets {
|
||||
if dataset.Kind != nativeDatasetBase {
|
||||
continue
|
||||
@@ -1118,6 +1119,8 @@ func validateNativeLockAllocation(dataDir string, report *ValidationReport) {
|
||||
}
|
||||
baseBoundaryID := len(rawRows) - 1
|
||||
baseKeys := map[string]struct{}{}
|
||||
nullBaseIDs := map[int]struct{}{}
|
||||
columns, _ := parseColumns(baseObj, dataset.Name)
|
||||
for index, raw := range rawRows {
|
||||
row, ok := raw.(map[string]any)
|
||||
if !ok {
|
||||
@@ -1133,6 +1136,12 @@ func validateNativeLockAllocation(dataDir string, report *ValidationReport) {
|
||||
if key, ok := row["key"].(string); ok && key != "" {
|
||||
baseKeys[key] = struct{}{}
|
||||
}
|
||||
if len(columns) > 0 {
|
||||
canonical, err := canonicalizeBaseRow(dataset, columns, row, index)
|
||||
if err == nil && isNativeAllocationNullRow(canonical, columns) {
|
||||
nullBaseIDs[rowID] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
explicitModuleIDs := map[string]int{}
|
||||
for _, dir := range []string{dataset.ModulesDir, dataset.GeneratedDir} {
|
||||
@@ -1208,6 +1217,11 @@ func validateNativeLockAllocation(dataDir string, report *ValidationReport) {
|
||||
if rowID > baseBoundaryID {
|
||||
continue
|
||||
}
|
||||
if dataset.RowGeneration == "first_null_row" {
|
||||
if _, ok := nullBaseIDs[rowID]; ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if _, ok := baseKeys[key]; ok {
|
||||
continue
|
||||
}
|
||||
@@ -1226,11 +1240,12 @@ func validateNativeLockAllocation(dataDir string, report *ValidationReport) {
|
||||
}
|
||||
}
|
||||
|
||||
func validateNativeAuthoringWarnings(dataDir string, report *ValidationReport) {
|
||||
func validateNativeAuthoringWarnings(dataDir string, rowGeneration []project.TopDataRowGenerationConfig, report *ValidationReport) {
|
||||
datasets, err := discoverNativeDatasets(dataDir)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
datasets = applyTopDataRowGeneration(datasets, rowGeneration)
|
||||
for _, dataset := range datasets {
|
||||
if dataset.Kind != nativeDatasetBase {
|
||||
continue
|
||||
@@ -1256,6 +1271,7 @@ func validateDatasetOverrideTargetWarnings(dataset nativeDataset, report *Valida
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
columns, _ := parseColumns(baseObj, dataset.Name)
|
||||
rowIDToKey := map[int]string{}
|
||||
keyToID := map[string]int{}
|
||||
usedIDs := map[int]struct{}{}
|
||||
@@ -1270,6 +1286,12 @@ func validateDatasetOverrideTargetWarnings(dataset nativeDataset, report *Valida
|
||||
rowID = parsed
|
||||
}
|
||||
}
|
||||
if dataset.RowGeneration == "first_null_row" && len(columns) > 0 {
|
||||
canonical, err := canonicalizeBaseRow(dataset, columns, row, index)
|
||||
if err == nil && isNativeAllocationNullRow(canonical, columns) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
usedIDs[rowID] = struct{}{}
|
||||
if key, ok := row["key"].(string); ok && key != "" {
|
||||
rowIDToKey[rowID] = key
|
||||
|
||||
Reference in New Issue
Block a user