Hello, I have some code to create a todo. but it doesnt work.
type Todo struct {
ID uintgorm:"primary key;autoIncrement" json:"id"Title stringjson:"title"Done intjson:"done"Body stringjson:"body"`
}
app.Post("/api/todos", func(c *fiber.Ctx) error { todo := &Todo{}
if err := c.BodyParser(todo); err != nil { return err }
err := db.Create(&todo).Error // does not work
if err != nil { c.Status(http.StatusBadRequest).JSON( &fiber.Map{"message": "could not create book"}) return err }
var todos []Todo db.Find(&todos)
return c.JSON(todos) })`
i get the following error:
2022/10/16 22:12:37 C:/Users/xxx/go/src/go-todo-app/server/main.go:38 Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'RETURNING id' at line 1
[0.550ms] [rows:0] INSERT INTO todos (title,done,body) VALUES ('Testing',0,'Finish Tutorial') RETURNING id
Comment From: github-actions[bot]
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
Comment From: a631807682
duplicated of https://github.com/go-gorm/mysql/issues/93