Skip to content

Commit 3cdd9ef

Browse files
authored
cmd/gf: fix command gf gen dao for fieldMapping feature (#3549)
1 parent 9aa426a commit 3cdd9ef

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func Test_Gen_Dao_FieldMapping(t *testing.T) {
241241
in = gendao.CGenDaoInput{
242242
Path: path,
243243
Link: link,
244-
Tables: "table_user",
244+
Tables: "",
245245
TablesEx: "",
246246
Group: group,
247247
Prefix: "",

cmd/gf/internal/cmd/gendao/gendao_structure.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func generateStructFieldDefinition(
133133
}
134134

135135
if in.FieldMapping != nil && len(in.FieldMapping) > 0 {
136-
if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.Tables, newFiledName)]; ok {
136+
if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.TableName, newFiledName)]; ok {
137137
localTypeNameStr = typeMapping.Type
138138
appendImport = typeMapping.Import
139139
}

os/gfile/gfile_replace.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func ReplaceFile(search, replace, path string) error {
1919
func ReplaceFileFunc(f func(path, content string) string, path string) error {
2020
data := GetContents(path)
2121
result := f(path, data)
22-
if len(data) != len(result) && data != result {
22+
if len(data) != len(result) || data != result {
2323
return PutContents(path, result)
2424
}
2525
return nil

0 commit comments

Comments
 (0)