mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-26 18:29:03 -06:00
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:
@@ -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{}{}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user