go-fast-sql icon indicating copy to clipboard operation
go-fast-sql copied to clipboard

Fix db close causes sql syntax error when flushing empty batched inserts

Open chiahan1123 opened this issue 7 years ago • 0 comments

When the database close, FlushAll will be called, causing the following to be ran:

for _, in := range d.batchInserts {
  if err := d.flushInsert(in); err != nil {
    return err
  }
}

If the in does not contain any pending inserts, the following error will be thrown:

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Due to the way query is constructed. Therefore, we can simply just ignore in with no more pending inserts.

chiahan1123 avatar Feb 12 '18 10:02 chiahan1123