Skip to content

Commit

Permalink
bulker: respect type of existing "_unmapped_data" column
Browse files Browse the repository at this point in the history
  • Loading branch information
absorbb committed Nov 19, 2024
1 parent 3204466 commit a772fe2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bulkerlib/implementations/sql/abstract.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,19 @@ func (ps *AbstractSQLStream) adjustTableColumnTypes(currentTable, existingTable,
}
}
if len(unmappedObj) > 0 {
var existingCol types.SQLColumn
ok := false
if existingTable.Exists() {
_, ok = existingTable.Columns.Get(ps.unmappedDataColumn)
existingCol, ok = existingTable.Columns.Get(ps.unmappedDataColumn)
}
if !ok {
jsonSQLType, _ := ps.sqlAdapter.GetSQLType(types.JSON)
added := current.SetIfAbsent(ps.unmappedDataColumn, types.SQLColumn{DataType: types.JSON, Type: jsonSQLType})
if added {
columnsAdded++
}
} else {
current.Set(ps.unmappedDataColumn, existingCol)
}
if ps.sqlAdapter.StringifyObjects() {
b, _ := jsoniter.Marshal(unmappedObj)
Expand Down

0 comments on commit a772fe2

Please sign in to comment.