dialect/sqlgraph: fix M2O relation in neighbors-with check

Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/198

Reviewed By: alexsn

Differential Revision: D18707741

fbshipit-source-id: 69dd010e27ee07ffe44acc12003b9772220aaa2a
This commit is contained in:
Ariel Mashraki
2019-11-26 12:22:08 -08:00
committed by Facebook Github Bot
parent 56335d6e12
commit 413bbad8d8
2 changed files with 87 additions and 1 deletions

View File

@@ -202,7 +202,7 @@ func HasNeighborsWith(q *Selector, s *Step, pred func(*Selector)) {
matches := builder.Select(to.C(s.To.Column)).
From(to)
pred(matches)
q.Where(In(from.C(s.From.Column), matches))
q.Where(In(from.C(s.Edge.Columns[0]), matches))
case r == O2M || (r == O2O && !s.Edge.Inverse):
from := q.Table()
to := builder.Table(s.Edge.Table)