codegen: make generated godoc more relevant for without-rowid tables

This commit is contained in:
2026-02-14 18:33:41 -08:00
parent 4f3865deaa
commit ba89f0b818
3 changed files with 11 additions and 6 deletions

View File

@@ -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{