MCPcopy Create free account
hub / github.com/AdRoll/baker / maybeTruncate

Method maybeTruncate

output/sqlite.go:288–302  ·  view source on GitHub ↗

maybeTruncate truncates the table (if configured to do so)

(tx *sql.Tx)

Source from the content-addressed store, hash-verified

286
287// maybeTruncate truncates the table (if configured to do so)
288func (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.

Callers 1

setupTableMethod · 0.95

Calls 2

sqliteQuoteFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected