Skip to content

Commit

Permalink
Parse nil value
Browse files Browse the repository at this point in the history
  • Loading branch information
ihippik committed Jan 8, 2021
1 parent 5a92614 commit 0d34ba6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions listener/wal_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ type Column struct {
// on the type of this data in the database table.
func (c *Column) AssertValue(src []byte) {
var val interface{}
if src == nil {
c.value = nil
return
}
strSrc := string(src)
switch c.valueType {
case pgtype.BoolOID:
val, _ = strconv.ParseBool(strSrc)
case pgtype.Int4OID:
val, _ = strconv.Atoi(strSrc)
case pgtype.TextOID:
case pgtype.TextOID, pgtype.VarcharOID:
val = strSrc
case pgtype.TimestampOID, pgtype.TimestamptzOID:
val = strSrc
Expand Down Expand Up @@ -116,7 +120,6 @@ func (w WalTransaction) CreateActionData(
isKey: rel.Columns[num].isKey,
}
column.AssertValue(row.Value)

columns = append(columns, column)
}
a.Columns = columns
Expand Down

0 comments on commit 0d34ba6

Please sign in to comment.