Skip to content

Commit

Permalink
table/table: set default value when write only column is null (pingca…
Browse files Browse the repository at this point in the history
…p#1357)

The test cover this issue need some work, will be added in next PR.
  • Loading branch information
coocood authored Jun 29, 2016
1 parent 83a6c94 commit 9bf6e03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion table/tables/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,14 @@ func (t *Table) UpdateRecord(ctx context.Context, h int64, oldData []types.Datum
// Compose new row
t.composeNewData(touched, currentData, oldData)
colIDs := make([]int64, 0, len(t.writableCols()))
for _, col := range t.writableCols() {
for i, col := range t.writableCols() {
if col.State != model.StatePublic && currentData[i].IsNull() {
defaultVal, _, err := table.GetColDefaultValue(ctx, &col.ColumnInfo)
if err != nil {
return errors.Trace(err)
}
currentData[i] = defaultVal
}
colIDs = append(colIDs, col.ID)
}
// Set new row data into KV.
Expand Down

0 comments on commit 9bf6e03

Please sign in to comment.