Skip to content

Commit dd8c4fc

Browse files
WangXiangUSTCsiddontang
authored andcommitted
add function of get term field's value by field name (go-mysql-org#124)
1 parent d6523c9 commit dd8c4fc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

canal/rows.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ func GetPKValues(table *schema.Table, row []interface{}) ([]interface{}, error)
5353
return values, nil
5454
}
5555

56+
// Get term column's value
57+
func GetColumnValue(table *schema.Table, column string, row []interface{}) (interface{}, error) {
58+
index := table.FindColumn(column)
59+
if index == -1 {
60+
return nil, errors.Errorf("table %s has no column name %s", table, column)
61+
}
62+
63+
return row[index], nil
64+
}
65+
5666
// String implements fmt.Stringer interface.
5767
func (r *RowsEvent) String() string {
5868
return fmt.Sprintf("%s %s %v", r.Action, r.Table, r.Rows)

0 commit comments

Comments
 (0)