Skip to content

Commit

Permalink
V1.0.64 (#82)
Browse files Browse the repository at this point in the history
* update dbio

* improve replications

* improve store

* improve settings

* improve ErrorHelper
  • Loading branch information
flarco authored Dec 11, 2023
1 parent 27fc1f3 commit a0f2ddc
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/sling/sling_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func runReplication(cfgPath string, selectStreams ...string) (err error) {

// clean up selectStreams
selectStreams = lo.Filter(selectStreams, func(v string, i int) bool {
return strings.TrimSpace(v) != ""
return replication.HasStream(v)
})

streamCnt := lo.Ternary(len(selectStreams) > 0, len(selectStreams), len(replication.Streams))
Expand Down
4 changes: 2 additions & 2 deletions core/sling/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ type ConfigOptions struct {

// Source is a source of data
type Source struct {
Conn string `json:"conn" yaml:"conn"`
Conn string `json:"conn,omitempty" yaml:"conn,omitempty"`
Stream string `json:"stream,omitempty" yaml:"stream,omitempty"`
Select []string `json:"select,omitempty" yaml:"select,omitempty"` // Select columns
PrimaryKeyI any `json:"primary_key,omitempty" yaml:"primary_key,omitempty"`
Expand Down Expand Up @@ -708,7 +708,7 @@ func (s *Source) PrimaryKey() []string {

// Target is a target of data
type Target struct {
Conn string `json:"conn" yaml:"conn"`
Conn string `json:"conn,omitempty" yaml:"conn,omitempty"`
Object string `json:"object,omitempty" yaml:"object,omitempty"`
Options *TargetOptions `json:"options,omitempty" yaml:"options,omitempty"`
Data map[string]interface{} `json:"data,omitempty" yaml:"data,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions core/sling/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ func UnmarshalReplication(replicYAML string) (config ReplicationConfig, err erro
err = g.Error(err, "could not parse 'env'")
return
}
} else {
config.Env = map[string]any{}
}

// parse streams
Expand Down Expand Up @@ -335,6 +337,7 @@ func LoadReplicationConfig(cfgPath string) (config ReplicationConfig, err error)
config, err = UnmarshalReplication(string(cfgBytes))
if err != nil {
err = g.Error(err, "Error parsing replication config")
return
}

config.originalCfg = g.Marshal(config)
Expand Down
4 changes: 3 additions & 1 deletion core/sling/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ func ErrorHelper(err error) (helpString string) {
helpString = "Perhaps specifying `encrypt=true` and `TrustServerCertificate=true` properties could help? See https://docs.slingdata.io/connections/database-connections/sqlserver"
case strings.Contains(errString, "ssl is not enabled on the server"):
helpString = "Perhaps setting the 'sslmode' option could help? See https://docs.slingdata.io/connections/database-connections/postgres"
case strings.Contains(errString, "invalid input syntax for type") || (strings.Contains(errString, " value ") && strings.Contains(errString, "is not recognized")):
case strings.Contains(errString, "invalid input syntax for type") || (strings.Contains(errString, " value ") && strings.Contains(errString, "is not recognized")) || strings.Contains(errString, "invalid character value"):
helpString = "Perhaps setting a higher 'SAMPLE_SIZE' environment variable could help? This represents the number of records to process in order to infer column types (especially for file sources). The default is 900. Try 2000 or even higher.\nYou can also manually specify the column types with the `columns` source option. See https://docs.slingdata.io/sling-cli/run/configuration#source"
case strings.Contains(errString, "bcp import"):
helpString = "If facing issues with Microsoft's BCP, try disabling Bulk Loading with `use_bulk=false`. See https://docs.slingdata.io/sling-cli/run/configuration#target"
}
}
return
Expand Down
5 changes: 4 additions & 1 deletion core/store/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/jmoiron/sqlx"
"github.com/slingdata-io/sling-cli/core/env"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)

var (
Expand All @@ -31,7 +32,9 @@ func InitDB() {

g.LogError(err, "Could not initialize sqlite connection: %s", dbURL)

Db, err = Conn.GetGormConn(&gorm.Config{})
Db, err = Conn.GetGormConn(&gorm.Config{
Logger: logger.Default.LogMode(logger.Silent),
})
g.LogError(err, "Could not connect to sqlite database: %s", dbURL)

allTables := []interface{}{
Expand Down
3 changes: 3 additions & 0 deletions core/store/store.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package store

import (
"os"
"strings"
"time"

Expand Down Expand Up @@ -36,6 +37,7 @@ type Execution struct {
ExitCode int `json:"exit_code"`
Output string `json:"output" sql:"default ''"`
Rows uint64 `json:"rows"`
Pid int `json:"pid"`

// ProjectID represents the project or the repository.
// If .git exists, grab first commit with `git rev-list --max-parents=0 HEAD`.
Expand Down Expand Up @@ -91,6 +93,7 @@ func ToExecutionObject(t *sling.TaskExecution) *Execution {
Rows: t.GetCount(),
ProjectID: g.String(t.Config.Env["SLING_PROJECT_ID"]),
FilePath: g.String(t.Config.Env["SLING_CONFIG_PATH"]),
Pid: os.Getpid(),
}

if t.Err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/denisbrodbeck/machineid v1.0.1
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.13.0
github.com/flarco/dbio v0.4.38
github.com/flarco/dbio v0.4.40
github.com/flarco/g v0.1.66
github.com/getsentry/sentry-go v0.11.0
github.com/google/uuid v1.3.0
Expand Down

0 comments on commit a0f2ddc

Please sign in to comment.