fix column_diff_table for modifed json columns (#7145)

* fix modifying json columns in diff tables

* [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh

---------

Co-authored-by: James Cor <james@dolthub.com>
Co-authored-by: JCOR11599 <JCOR11599@users.noreply.github.com>
This commit is contained in:
James Cor
2023-12-11 21:11:40 -08:00
committed by GitHub
parent c596e164bc
commit 81a6e152c1
2 changed files with 29 additions and 1 deletions

View File

@@ -553,7 +553,12 @@ func calculateColDelta(ctx *sql.Context, ddb *doltdb.DoltDB, delta *diff.TableDe
toIdx := diffTableCols.TagToIdx[toColTag]
fromIdx := diffTableCols.TagToIdx[fromColTag]
if r[toIdx] != r[fromIdx] {
toCol := delta.ToSch.GetAllCols().GetByIndex(toIdx)
cmp, err := toCol.TypeInfo.ToSqlType().Compare(r[toIdx], r[fromIdx])
if err != nil {
return nil, nil, err
}
if cmp != 0 {
colNamesSet[col] = struct{}{}
}
}

View File

@@ -4623,6 +4623,29 @@ var ColumnDiffSystemTableScriptTests = []queries.ScriptTest{
},
},
},
{
Name: "json column change",
SetUpScript: []string{
"create table t (pk int primary key, j json);",
`insert into t values (1, '{"test": 123}');`,
"call dolt_add('.')",
"call dolt_commit('-m', 'commit1');",
`update t set j = '{"nottest": 321}'`,
"call dolt_add('.')",
"call dolt_commit('-m', 'commit2');",
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "select column_name, diff_type from dolt_column_diff;",
Expected: []sql.Row{
{"j", "modified"},
{"pk", "added"},
{"j", "added"},
},
},
},
},
}
var CommitDiffSystemTableScriptTests = []queries.ScriptTest{