I use go-pg, and I can not figure out how to solve the problem when the number of fields in the model does not match the number of fields in the database

type UnitModel struct { Id int Name string TableName struct{} `sql:"unit"` } var unit UnitModel err := db.Model(&unit).Where("id = ?", id).Select() 

pg: can't find column alter_name in model

  • I looked at the sources and came to the conclusion that without fixing the library, nothing could be done about it. I did not rule, because My task is short-term and writing a patch would not be justified in time. - rekby

1 answer 1

In version 4.8.10 go-pg this behavior is changed. Now if the table has fields that are not in the structure, the error will not fall.