Skip to content

Commit

Permalink
cmd/gf: fix command gf gen dao for fieldMapping feature (#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyjaysong authored Apr 29, 2024
1 parent 9aa426a commit 3cdd9ef
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func Test_Gen_Dao_FieldMapping(t *testing.T) {
in = gendao.CGenDaoInput{
Path: path,
Link: link,
Tables: "table_user",
Tables: "",
TablesEx: "",
Group: group,
Prefix: "",
Expand Down
2 changes: 1 addition & 1 deletion cmd/gf/internal/cmd/gendao/gendao_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func generateStructFieldDefinition(
}

if in.FieldMapping != nil && len(in.FieldMapping) > 0 {
if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.Tables, newFiledName)]; ok {
if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.TableName, newFiledName)]; ok {
localTypeNameStr = typeMapping.Type
appendImport = typeMapping.Import
}
Expand Down
2 changes: 1 addition & 1 deletion os/gfile/gfile_replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func ReplaceFile(search, replace, path string) error {
func ReplaceFileFunc(f func(path, content string) string, path string) error {
data := GetContents(path)
result := f(path, data)
if len(data) != len(result) && data != result {
if len(data) != len(result) || data != result {
return PutContents(path, result)
}
return nil
Expand Down

0 comments on commit 3cdd9ef

Please sign in to comment.