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

DryRun for migrator #5689

Merged
merged 3 commits into from Dec 24, 2022
Merged

DryRun for migrator #5689

merged 3 commits into from Dec 24, 2022

Conversation

defool
Copy link
Contributor

@defool defool commented Sep 12, 2022

What did this pull request do?

Print SQL in AutoMigrate with DryRun option.

User Case Description

As mentioned in #3545.

execTx := queryTx
if m.DB.DryRun {
queryTx.DryRun = false
execTx = m.DB.Session(&gorm.Session{Logger: &printSQLLogger{}})
Copy link
Member

Choose a reason for hiding this comment

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

the printSQLLogger should reuse the current logger to print the running SQL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The existing logger print some tracing text, so we can not copy the output to execute it.
I think a new logger printSQLLogger is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any other suggestion on this PR? @jinzhu

@jinzhu jinzhu mentioned this pull request Oct 20, 2022
3 tasks
@defool defool requested a review from jinzhu October 22, 2022 15:40
@zchenyu
Copy link

zchenyu commented Dec 1, 2022

Any progress on this PR? This would be a great feature!

@jinzhu jinzhu merged commit 775fa70 into go-gorm:master Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants