Hi,
I was trying to do the following:
type A struct {
Foo string
Bar int
Bs []B `gorm:"many2many:a_b`
}
type B struct {
Field string
As A[] `gorm:"many2many:a_b`
}
...
db.Preload("As", func(db *gorm.DB) *gorm.DB {
return db.Select("foo").Order("bar ASC")
}).First(&B{})
But the query that is executed is
SELECT * FROM "as" .... ORDER BY bar ASC
Obviously custom preloading doesn't handle Select()
when retrieving a many2many
association.
Is it wanted?
This should been fixed, thank you for your report.
i have same problem, is that fixed ?
@jinzhu Faced with same problem, Select()
is not working properly for m2m associations.
I am using m2m and 1toM connections at the same time
Most helpful comment
This should been fixed, thank you for your report.