Skip to content

Commit

Permalink
fix: scan error uptrace#709
Browse files Browse the repository at this point in the history
  • Loading branch information
calorie committed May 27, 2023
1 parent dacffd2 commit ff2dcb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion internal/dbtest/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ func testBookRelations(t *testing.T, db *bun.DB) {
Relation("Author.Avatar").
Relation("Editor").
Relation("Editor.Avatar").
Relation("Genres").
Relation("Genres", func(q *bun.SelectQuery) *bun.SelectQuery {
return q.Column("id", "name", "genre__rating")
}).
Relation("Comments").
Relation("Translations", func(q *bun.SelectQuery) *bun.SelectQuery {
return q.Order("id")
Expand Down
7 changes: 6 additions & 1 deletion relation_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ func (j *relationJoin) m2mQuery(q *SelectQuery) *SelectQuery {
baseTable := j.BaseModel.Table()

if j.Relation.M2MTable != nil {
q = q.ColumnExpr(string(j.Relation.M2MTable.SQLAlias) + ".*")
for _, f := range j.Relation.M2MBaseFields {
q = q.ColumnExpr(string(j.Relation.M2MTable.SQLAlias) + "." + string(f.SQLName))
}
for _, f := range j.Relation.M2MJoinFields {
q = q.ColumnExpr(string(j.Relation.M2MTable.SQLAlias) + "." + string(f.SQLName))
}
}

//nolint
Expand Down

0 comments on commit ff2dcb7

Please sign in to comment.