From d997c65011be2c6a6151fcb8235d707924f5b11d Mon Sep 17 00:00:00 2001 From: Jun Nishimura Date: Tue, 2 Apr 2024 00:19:49 +0900 Subject: [PATCH] add ModelTableExpr to TruncateTableQuery --- migrate/migrator.go | 4 +++- query_table_truncate.go | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/migrate/migrator.go b/migrate/migrator.go index 52290b370..2e20cbf11 100644 --- a/migrate/migrator.go +++ b/migrate/migrator.go @@ -362,7 +362,9 @@ func (m *Migrator) MarkUnapplied(ctx context.Context, migration *Migration) erro } func (m *Migrator) TruncateTable(ctx context.Context) error { - _, err := m.db.NewTruncateTable().TableExpr(m.table).Exec(ctx) + _, err := m.db.NewTruncateTable(). + ModelTableExpr(m.table). + Exec(ctx) return err } diff --git a/query_table_truncate.go b/query_table_truncate.go index a704b7b10..9ac5599d9 100644 --- a/query_table_truncate.go +++ b/query_table_truncate.go @@ -57,6 +57,11 @@ func (q *TruncateTableQuery) TableExpr(query string, args ...interface{}) *Trunc return q } +func (q *TruncateTableQuery) ModelTableExpr(query string, args ...interface{}) *TruncateTableQuery { + q.modelTableName = schema.SafeQuery(query, args) + return q +} + //------------------------------------------------------------------------------ func (q *TruncateTableQuery) ContinueIdentity() *TruncateTableQuery {