Skip to content

Commit

Permalink
check before casting to string
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Nov 14, 2023
1 parent 13e0e0f commit 6ff107f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions flow/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,19 @@ func (r *RecordItems) toMap() (map[string]interface{}, error) {
var err error
switch v.Kind {
case qvalue.QValueKindString, qvalue.QValueKindJSON:
if len(v.Value.(string)) > 15*1024*1024 {
jsonStruct[col] = ""
if v.Value == nil {
jsonStruct[col] = nil
} else {
jsonStruct[col] = v.Value
strVal, ok := v.Value.(string)
if !ok {
return nil, fmt.Errorf("expected string value for column %s for %T", col, v.Value)
}

if len(strVal) > 15*1024*1024 {
jsonStruct[col] = ""
} else {
jsonStruct[col] = strVal
}
}
case qvalue.QValueKindTimestamp, qvalue.QValueKindTimestampTZ, qvalue.QValueKindDate,
qvalue.QValueKindTime, qvalue.QValueKindTimeTZ:
Expand Down

0 comments on commit 6ff107f

Please sign in to comment.