Skip to content

Commit

Permalink
Merge pull request #9 from knocknote/feature/fix-importer
Browse files Browse the repository at this point in the history
Fix importer
  • Loading branch information
goccy authored Dec 12, 2018
2 parents 84d3156 + 865dedd commit d4fdcaf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cmd/octillery/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ func (cmd *ImportCommand) values(record []string, types []GoType, columns []stri
}
values = append(values, value)
case GoString:
values = append(values, v)
if unquotedString, err := strconv.Unquote(fmt.Sprintf("\"%s\"", v)); err == nil {
values = append(values, unquotedString)
} else {
values = append(values, v)
}
case GoBytes:
values = append(values, []byte(v))
case GoDateFormat:
Expand Down Expand Up @@ -371,11 +375,12 @@ func (cmd *ImportCommand) Execute(args []string) error {
if _, exists := cfg.Tables[tableName]; !exists {
return errors.Errorf("invalid table name %s", tableName)
}
seeds, err := ioutil.ReadFile(path)
seeds, err := os.Open(path)
if err != nil {
return errors.WithStack(err)
}
reader := csv.NewReader(strings.NewReader(string(seeds)))
reader := csv.NewReader(seeds)
reader.LazyQuotes = true
records, err := reader.ReadAll()
if err != nil {
return errors.WithStack(err)
Expand Down
2 changes: 1 addition & 1 deletion octillery.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

// Version is the variable for versioning Octillery
const Version = "v1.1.0"
const Version = "v1.1.1"

// LoadConfig load your database configuration file.
//
Expand Down

0 comments on commit d4fdcaf

Please sign in to comment.