mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sqlgraph: fix neighbors check with predicates
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/206 Reviewed By: alexsn Differential Revision: D18729641 fbshipit-source-id: a5d333132ae276691ac8c1b084bc5d2037112529
This commit is contained in:
committed by
Facebook Github Bot
parent
29c7b0a0d8
commit
5610d0ade9
@@ -237,13 +237,15 @@ func HasNeighborsWith(q *Selector, s *Step, pred func(*Selector)) {
|
||||
}
|
||||
from := q.Table()
|
||||
to := builder.Table(s.To.Table)
|
||||
join := builder.Table(s.Edge.Table)
|
||||
matches := builder.Select(join.C(pk2)).
|
||||
From(join).
|
||||
edge := builder.Table(s.Edge.Table)
|
||||
join := builder.Select(edge.C(pk2)).
|
||||
From(edge).
|
||||
Join(to).
|
||||
On(join.C(pk1), to.C(s.To.Column))
|
||||
On(edge.C(pk1), to.C(s.To.Column))
|
||||
matches := builder.Select().From(to)
|
||||
pred(matches)
|
||||
q.Where(In(from.C(s.From.Column), matches))
|
||||
join.FromSelect(matches)
|
||||
q.Where(In(from.C(s.From.Column), join))
|
||||
case r == M2O || (r == O2O && s.Edge.Inverse):
|
||||
from := q.Table()
|
||||
to := builder.Table(s.To.Table)
|
||||
|
||||
Reference in New Issue
Block a user