Skip to content

Commit

Permalink
fix: apply join condition to select with count
Browse files Browse the repository at this point in the history
Close #597
  • Loading branch information
j2gg0s committed Jan 6, 2025
1 parent ec5d81e commit e77b9e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions query_select.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ func (q *SelectQuery) appendQuery(
return nil, err
}

if err := q.forEachInlineRelJoin(func(j *relationJoin) error {
j.applyTo(q)
return nil
}); err != nil {
return nil, err
}

b = append(b, "SELECT "...)

if len(q.distinctOn) > 0 {
Expand Down Expand Up @@ -730,8 +737,6 @@ func (q *SelectQuery) appendColumns(fmter schema.Formatter, b []byte) (_ []byte,
func (q *SelectQuery) appendInlineRelColumns(
fmter schema.Formatter, b []byte, join *relationJoin,
) (_ []byte, err error) {
join.applyTo(q)

if join.columns != nil {
table := join.JoinModel.Table()
for i, col := range join.columns {
Expand Down

0 comments on commit e77b9e7

Please sign in to comment.