Skip to content

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