maybeTruncate truncates the table (if configured to do so)
(tx *sql.Tx)
| 286 | |
| 287 | // maybeTruncate truncates the table (if configured to do so) |
| 288 | func (c *SQLite) maybeTruncate(tx *sql.Tx) error { |
| 289 | if c.cfg.Clear { |
| 290 | stmt, err := tx.Prepare("DELETE FROM " + sqliteQuote(c.cfg.TableName)) |
| 291 | if err != nil { |
| 292 | return fmt.Errorf("prepare truncate statement: %s", err) |
| 293 | } |
| 294 | if _, err = stmt.Exec(); err != nil { |
| 295 | stmt.Close() |
| 296 | return fmt.Errorf("truncate table: %s", err) |
| 297 | } |
| 298 | stmt.Close() |
| 299 | } |
| 300 | |
| 301 | return nil |
| 302 | } |
| 303 | |
| 304 | // setupTable either creates the table or, in case it already exists and the |
| 305 | // config has Clear=true, we truncate the table. |
no test coverage detected