codegen: make generated godoc more relevant for without-rowid tables
This commit is contained in:
@@ -22,8 +22,6 @@ TODO: codegen SaveXyz update path doesn't check foreign keys
|
|||||||
- Insert path has FK error handling, but the update path wraps everything in Must
|
- Insert path has FK error handling, but the update path wraps everything in Must
|
||||||
- An update that violates an FK constraint will panic instead of returning an error
|
- An update that violates an FK constraint will panic instead of returning an error
|
||||||
|
|
||||||
TODO: codegen `without rowid` tables properly
|
|
||||||
|
|
||||||
TODO: generated test file inclues global test DB setup, which is wrong
|
TODO: generated test file inclues global test DB setup, which is wrong
|
||||||
|
|
||||||
TODO: join-tables
|
TODO: join-tables
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
https://astexplorer.net/
|
https://astexplorer.net/
|
||||||
|
https://github.com/dave/dst
|
||||||
|
https://disaev.me/p/writing-useful-go-analysis-linter/
|
||||||
|
|||||||
@@ -515,11 +515,16 @@ func GenerateSaveItemFunc(tbl schema.Table) *ast.FuncDecl {
|
|||||||
}(),
|
}(),
|
||||||
}
|
}
|
||||||
|
|
||||||
funcDecl := &ast.FuncDecl{
|
docLines := []*ast.Comment{
|
||||||
Doc: &ast.CommentGroup{List: []*ast.Comment{
|
|
||||||
{Text: fmt.Sprintf("// Save%s creates or updates a %s in the database.", tbl.GoTypeName, tbl.GoTypeName)},
|
{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."},
|
}
|
||||||
}},
|
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: docLines},
|
||||||
Recv: dbRecv,
|
Recv: dbRecv,
|
||||||
Name: ast.NewIdent("Save" + tbl.GoTypeName),
|
Name: ast.NewIdent("Save" + tbl.GoTypeName),
|
||||||
Type: &ast.FuncType{
|
Type: &ast.FuncType{
|
||||||
|
|||||||
Reference in New Issue
Block a user