Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ModelTableExpr to TruncateTableQuery #969

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion migrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right, because there is no Model call. Could you revert it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vmihailenco
Thanks for the reply.

Referring to other implementations, I decided that it would be better to call a Model method than to revert.
I would appreciate it if you could check the following commit again. 27193c3

return err
}

Expand Down
5 changes: 5 additions & 0 deletions query_table_truncate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading