Skip to content

Commit

Permalink
improve GetColumn error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
flarco committed Aug 27, 2024
1 parent 8dd5881 commit f3fa3b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion core/dbio/iop/datastream.go
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,9 @@ func (it *Iterator) BelowEqualIncrementalVal() bool {
// no incremental val or col
return false
} else if it.incrementalColI == -1 {
it.incrementalColI = it.ds.Columns.GetColumn(it.incrementalCol).Position - 1
if col := it.ds.Columns.GetColumn(it.incrementalCol); col != nil {
it.incrementalColI = col.Position - 1
}
}

if it.incrementalColI == -1 || it.incrementalColI > len(it.ds.Columns) {
Expand Down
2 changes: 1 addition & 1 deletion core/sling/task_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func getIncrementalValue(cfg *Config, tgtConn database.Connection, srcConnVarMap
// get target columns to match update-key
// in case column casing needs adjustment
targetCols, _ := pullTargetTableColumns(cfg, tgtConn, false)
if updateCol := targetCols.GetColumn(tgtUpdateKey); updateCol.Name != "" {
if updateCol := targetCols.GetColumn(tgtUpdateKey); updateCol != nil && updateCol.Name != "" {
tgtUpdateKey = updateCol.Name // overwrite with correct casing
} else if len(targetCols) == 0 {
return // target table does not exist
Expand Down
2 changes: 1 addition & 1 deletion core/sling/task_run_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (t *TaskExecution) ReadFromDB(cfg *Config, srcConn database.Connection) (df
// get source columns to match update-key
// in case column casing needs adjustment
updateCol := sTable.Columns.GetColumn(cfg.Source.UpdateKey)
if updateCol.Name != "" {
if updateCol != nil && updateCol.Name != "" {
cfg.Source.UpdateKey = updateCol.Name // overwrite with correct casing
}

Expand Down

0 comments on commit f3fa3b9

Please sign in to comment.