Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Bug: deleteRecords method does not remove all records
Browse files Browse the repository at this point in the history
  • Loading branch information
ryo-kadoya committed Aug 12, 2014
1 parent 276656b commit 8fcd2c5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions import.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ func upsert(app *kintone.App, recs []*kintone.Record, updating bool) error {
}

func deleteRecords(app *kintone.App) error {
offset := int64(0)
for ;;offset += ROW_LIMIT {
var lastId uint64 = 0
for {
ids := make([]uint64, 0, ROW_LIMIT)
records, err := getRecords(app, []string{"$id"}, offset)
records, err := getRecords(app, []string{"$id"}, 0)
if err != nil {
return err
}
Expand All @@ -133,6 +133,11 @@ func deleteRecords(app *kintone.App) error {
if len(records) < ROW_LIMIT {
break
}
if lastId == ids[0] {
// prevent an inifinite loop
return fmt.Errorf("Unexpected error occured during deleting")
}
lastId = ids[0]
}

return nil
Expand Down Expand Up @@ -182,6 +187,10 @@ func getField(fieldType string, value string, updating bool) interface{} {
if err == nil {
return kintone.DateField{dt, true}
}
dt, err = time.Parse("2006/1/2", value)
if err == nil {
return kintone.DateField{dt, true}
}
}
case kintone.FT_TIME:
if value == "" {
Expand Down

0 comments on commit 8fcd2c5

Please sign in to comment.