dialect/sqlgraph: test and fix M2M neighbors check

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

Reviewed By: alexsn

Differential Revision: D18680440

fbshipit-source-id: b2dce0ee3e0a898fab901c4287c6c1c1844e51d6
This commit is contained in:
Ariel Mashraki
2019-11-24 22:09:28 -08:00
committed by Facebook Github Bot
parent 0344904a4e
commit 038dc2899a
2 changed files with 68 additions and 2 deletions

View File

@@ -148,9 +148,9 @@ func HasNeighbors(q *Selector, s *Step) {
builder := Dialect(q.dialect)
switch r := s.Edge.Rel; {
case r == M2M:
pk1 := s.Edge.Columns[1]
pk1 := s.Edge.Columns[0]
if s.Edge.Inverse {
pk1 = s.Edge.Columns[0]
pk1 = s.Edge.Columns[1]
}
from := q.Table()
join := builder.Table(s.Edge.Table)