refactor: use TRUNCATE to reset the tables for postgres/ mysql (#74)

MySQL docs: https://dev.mysql.com/doc/refman/8.0/en/truncate-table.html
Postgres docs: https://www.postgresql.org/docs/current/sql-truncate.html
This commit is contained in:
Roman
2021-03-31 14:11:33 +02:00
committed by GitHub
parent f69705a65d
commit 8a84698537
2 changed files with 2 additions and 2 deletions

View File

@@ -99,7 +99,7 @@ func New(config ...Config) *Storage {
sqlSelect: fmt.Sprintf(`SELECT v, e FROM %s WHERE k=$1;`, cfg.Table),
sqlInsert: fmt.Sprintf("INSERT INTO %s (k, v, e) VALUES ($1, $2, $3) ON CONFLICT (k) DO UPDATE SET v = $4, e = $5", cfg.Table),
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE k=$1", cfg.Table),
sqlReset: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
sqlReset: fmt.Sprintf("TRUNCATE TABLE %s;", cfg.Table),
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE e <= $1 AND e != 0", cfg.Table),
}