sqlserver icon indicating copy to clipboard operation
sqlserver copied to clipboard

fix: failed to modify field comment when empty due to incorrect conditions

Open iTanken opened this issue 8 months ago • 0 comments

  • [x] Do only one thing
  • [x] Non breaking API changes
    • GetColumnComment(*gorm.Statement, string) string => GetColumnComment(*gorm.Statement, string) sql.NullString
  • [x] Tested

What did this pull request do?

@jinzhu Fix issue where modifying field comments failed when the field comment was an empty string due to incorrect judgment conditions.

User Case Description

type TestTableFieldComment struct {
	ID       string     `gorm:"column:id;primaryKey;comment:"`  // field comment is an empty string
	// ...
}

func (*TestTableFieldComment) TableName() string { return "test_table_field_comment" }

// =>

type TestTableFieldCommentUpdate struct {
	ID       string     `gorm:"column:id;primaryKey;comment:ID"`
	// ...
}

func (*TestTableFieldCommentUpdate) TableName() string { return "test_table_field_comment" }

iTanken avatar Mar 18 '25 07:03 iTanken