aboutsummaryrefslogtreecommitdiff
path: root/pgruntime/connector.go
diff options
context:
space:
mode:
Diffstat (limited to 'pgruntime/connector.go')
-rw-r--r--pgruntime/connector.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/pgruntime/connector.go b/pgruntime/connector.go
index 92780f6..5276a26 100644
--- a/pgruntime/connector.go
+++ b/pgruntime/connector.go
@@ -164,10 +164,12 @@ func resetTestDatabase(ctx context.Context, db gsql.Handle, params testSetupPara
}
// truncate all tables at once
- query = fmt.Sprintf(`TRUNCATE %s RESTART IDENTITY CASCADE`, strings.Join(quotedTableNames, ", "))
- _, err = execQuery(ctx, db, query, nil)
- if err != nil {
- return fmt.Errorf("during %s: %w", query, err)
+ if len(quotedTableNames) > 0 {
+ query = fmt.Sprintf(`TRUNCATE %s RESTART IDENTITY CASCADE`, strings.Join(quotedTableNames, ", "))
+ _, err = execQuery(ctx, db, query, nil)
+ if err != nil {
+ return fmt.Errorf("during %s: %w", query, err)
+ }
}
return nil