codegen: make generated godoc more relevant for without-rowid tables
This commit is contained in:
@@ -515,11 +515,16 @@ func GenerateSaveItemFunc(tbl schema.Table) *ast.FuncDecl {
|
||||
}(),
|
||||
}
|
||||
|
||||
docLines := []*ast.Comment{
|
||||
{Text: fmt.Sprintf("// Save%s creates or updates a %s in the database.", tbl.GoTypeName, tbl.GoTypeName)},
|
||||
}
|
||||
if tbl.IsWithoutRowid {
|
||||
docLines = append(docLines, &ast.Comment{Text: "// If a row with the same key already exists, it will be updated; otherwise it will be created."})
|
||||
} else {
|
||||
docLines = append(docLines, &ast.Comment{Text: "// If the item doesn't exist (has no ID set), it will create it; otherwise it will do an update."})
|
||||
}
|
||||
funcDecl := &ast.FuncDecl{
|
||||
Doc: &ast.CommentGroup{List: []*ast.Comment{
|
||||
{Text: fmt.Sprintf("// Save%s creates or updates a %s in the database.", tbl.GoTypeName, tbl.GoTypeName)},
|
||||
{Text: "// If the item doesn't exist (has no ID set), it will create it; otherwise it will do an update."},
|
||||
}},
|
||||
Doc: &ast.CommentGroup{List: docLines},
|
||||
Recv: dbRecv,
|
||||
Name: ast.NewIdent("Save" + tbl.GoTypeName),
|
||||
Type: &ast.FuncType{
|
||||
|
||||
Reference in New Issue
Block a user