Open hookover opened 4 years ago
Hello, I think mine is related too because I have the same error when trying to create (not eager create) a user that contains "has_many" association.
So every time I want to create something I have to allocate the associated as empty like:
user := &models.User{}
if err := c.Bind(user); err != nil {
return c.Render(http.StatusBadRequest, r.HTML("auth/signup.html"))
}
user.Portals = &models.UserCompanies{} "<--- Without this I get the error @hookover shows"
if err := tx.Create(user); err != nil {
return err
}
Is that the correct behavior?, I thought that when we want to create something with associations we should use "eager().Create(&model)"
The ID field of this framework must be completely uppercase, otherwise problems will occur, including when querying a single record, the value of the ID field will be 0. like this:
type User struct {
Id int `db:"id"` //auto_increment
Name string `db:"name"`
}
u := &User{Name:"test"}
err :=pop.Create(u);
err == nil
//fmt.print(u.Id, u.Name) // 0, test ,the id in database is a 1 or more
debug
incompatible/associations/has_many_association.go:133 +0x16c
model
run