refactor/organize-conversion-pipeline #4

Merged
agent merged 3 commits from refactor/organize-conversion-pipeline into main 2026-07-19 10:09:07 +09:00
2 changed files with 24 additions and 7 deletions
Showing only changes of commit 3edb93fcf7 - Show all commits

View File

@@ -138,12 +138,24 @@ func TestParseCellConservativeInference(t *testing.T) {
} }
func TestSetPathDoesNotOverwriteConflictingShape(t *testing.T) { func TestSetPathDoesNotOverwriteConflictingShape(t *testing.T) {
record := map[string]any{} t.Run("parent scalar before child", func(t *testing.T) {
setPath(record, "user", "Alice") record := map[string]any{}
setPath(record, "user.name", "Bob") setPath(record, "user", "Alice")
if got := record["user"]; got != "Alice" { setPath(record, "user.name", "Bob")
t.Fatalf("user = %#v, want original scalar", got) if got := record["user"]; got != "Alice" {
} t.Fatalf("user = %#v, want original scalar", got)
}
})
t.Run("child before parent scalar", func(t *testing.T) {
record := map[string]any{}
setPath(record, "user.name", "Bob")
setPath(record, "user", "Alice")
want := map[string]any{"name": "Bob"}
if got := record["user"]; !reflect.DeepEqual(got, want) {
t.Fatalf("user = %#v, want original nested value %#v", got, want)
}
})
} }
func TestSetPathRestoresNestedArrays(t *testing.T) { func TestSetPathRestoresNestedArrays(t *testing.T) {

View File

@@ -93,7 +93,12 @@ func setPath(root map[string]any, path string, value any) {
return return
} }
if last { if last {
m[token.key] = value // Preserve the value established by an earlier column. This also
// protects a nested map/slice when a later parent scalar conflicts
// with it (for example, user.name followed by user).
if _, exists := m[token.key]; !exists {
m[token.key] = value
}
return return
} }
if _, exists := m[token.key]; !exists { if _, exists := m[token.key]; !exists {