Skip to content

Commit 03520e6

Browse files
committed
refactor: replace ToMapString with CastToMapString for consistency in data conversion
1 parent 13e84fe commit 03520e6

8 files changed

Lines changed: 9 additions & 11 deletions

File tree

core/dbio/api/api.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type APIConnection struct {
2020
State *APIState
2121
Context *g.Context
2222
evaluator *iop.Evaluator `json:"-" yaml:"-"`
23-
sp *iop.StreamProcessor
2423
}
2524

2625
// NewAPIConnection creates an
@@ -36,7 +35,6 @@ func NewAPIConnection(ctx context.Context, spec Spec, data map[string]any) (ac *
3635
},
3736
Spec: spec,
3837
evaluator: iop.NewEvaluator(g.ArrStr("env", "state", "secrets", "auth", "response", "request", "sync", "context")),
39-
sp: iop.NewStreamProcessor(),
4038
}
4139

4240
// Merge spec defaults state into ac.State.State first

core/dbio/iop/datastream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ func (ds *Datastream) GetConfig() (configMap map[string]string) {
302302
// lower the keys
303303
configMapI := g.M()
304304
g.JSONConvert(ds.Sp.Config, &configMapI)
305-
return g.ToMapString(configMapI)
305+
return g.CastToMapString(configMapI)
306306
}
307307

308308
// CastRowToString returns the row as string casted

core/dbio/iop/stream_processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type StreamConfig struct {
8181
func (sc *StreamConfig) ToMap() map[string]string {
8282
m := g.M()
8383
g.Unmarshal(g.Marshal(sc), &m)
84-
return g.ToMapString(m)
84+
return g.CastToMapString(m)
8585
}
8686

8787
type Transformers struct {

core/dbio/iop/transforms.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,9 @@ func (e *Evaluator) FillMissingKeys(stateMap map[string]any, varsToCheck []strin
831831
stateMap[section] = g.M()
832832
}
833833

834-
nested, err := cast.ToStringMapE(stateMap[section])
834+
nested, err := g.CastToMapAnyE(stateMap[section])
835835
if err != nil {
836-
g.Warn("could not convert to map to fill missing key for %s: %#v", section, stateMap[section])
836+
g.Warn(`could not convert to map to fill missing key for "%s": %#v`, section, stateMap[section])
837837
nested = g.M()
838838
} else if nested == nil {
839839
nested = g.M()

core/sling/replication.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,7 @@ func (rd *ReplicationConfig) Compile(cfgOverwrite *Config, selectStreams ...stri
10571057
}
10581058

10591059
// config overwrite
1060-
taskEnv := g.ToMapString(rd.Env)
1060+
taskEnv := g.CastToMapString(rd.Env)
10611061
var incrementalValStr string
10621062

10631063
if cfgOverwrite != nil {

core/sling/task_run_read.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (t *TaskExecution) ReadFromFile(cfg *Config) (df *iop.Dataflow, err error)
273273
// construct props by merging with options
274274
props := append(
275275
g.MapToKVArr(cfg.SrcConn.DataS()),
276-
g.MapToKVArr(g.ToMapString(options))...,
276+
g.MapToKVArr(g.CastToMapString(options))...,
277277
)
278278

279279
fs, err := filesys.NewFileSysClientFromURLContext(t.Context.Ctx, uri, props...)
@@ -354,7 +354,7 @@ func (t *TaskExecution) ReadFromFile(cfg *Config) (df *iop.Dataflow, err error)
354354
return t.df, err
355355
}
356356
} else {
357-
stream, err = filesys.MakeDatastream(bufio.NewReader(os.Stdin), g.ToMapString(options))
357+
stream, err = filesys.MakeDatastream(bufio.NewReader(os.Stdin), g.CastToMapString(options))
358358
if err != nil {
359359
err = g.Error(err, "Could not MakeDatastream")
360360
return t.df, err

core/sling/task_run_write.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (t *TaskExecution) WriteToFile(cfg *Config, df *iop.Dataflow) (cnt uint64,
3939
options := t.getTargetOptionsMap()
4040
props := append(
4141
g.MapToKVArr(cfg.TgtConn.DataS()),
42-
g.MapToKVArr(g.ToMapString(options))...,
42+
g.MapToKVArr(g.CastToMapString(options))...,
4343
)
4444

4545
fs, err := filesys.NewFileSysClientFromURLContext(t.Context.Ctx, uri, props...)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require (
3737
github.com/exasol/exasol-driver-go v1.0.14
3838
github.com/fatih/color v1.18.0
3939
github.com/flarco/bigquery v0.0.9
40-
github.com/flarco/g v0.1.168
40+
github.com/flarco/g v0.1.169
4141
github.com/getsentry/sentry-go v0.27.0
4242
github.com/go-sql-driver/mysql v1.9.3
4343
github.com/gobwas/glob v0.2.3

0 commit comments

Comments
 (0)