Skip to content

fix:default value is '' or 0 #1309

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

daijiezou
Copy link

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

When the default value of the database field is 0 or "", the default tag will still be generated.

User Case Description

  1. Problem background

In the database model definition, the default tag of gorm is used to specify the default value of the field. The current method does not generate the default tag when dealing with the empty string "" and the value of 0, resulting in the generated structure not meeting expectations.

  1. Modify the content

New logic: When value == "", return "" "(i.e., the SQL empty string literal), remove the detection of 0 values, and ensure that the value of the default tag of the generated struct is correct.

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.

1 participant