MCPcopy Index your code
hub / github.com/ent/ent / SetNeighbors

Function SetNeighbors

dialect/sql/sqlgraph/graph.go:201–237  ·  view source on GitHub ↗

SetNeighbors returns a Selector for evaluating the path-step and getting the neighbors of set of vertices.

(dialect string, s *Step)

Source from the content-addressed store, hash-verified

199// SetNeighbors returns a Selector for evaluating the path-step
200// and getting the neighbors of set of vertices.
201func SetNeighbors(dialect string, s *Step) (q *sql.Selector) {
202 set := s.From.V.(*sql.Selector)
203 builder := sql.Dialect(dialect)
204 switch {
205 case s.ThroughEdgeTable():
206 pk1, pk2 := s.Edge.Columns[1], s.Edge.Columns[0]
207 if s.Edge.Inverse {
208 pk1, pk2 = pk2, pk1
209 }
210 to := builder.Table(s.To.Table).Schema(s.To.Schema)
211 set.Select(set.C(s.From.Column))
212 join := builder.Table(s.Edge.Table).Schema(s.Edge.Schema)
213 match := builder.Select(join.C(pk1)).
214 From(join).
215 Join(set).
216 On(join.C(pk2), set.C(s.From.Column))
217 q = builder.Select().
218 From(to).
219 Join(match).
220 On(to.C(s.To.Column), match.C(pk1))
221 case s.FromEdgeOwner():
222 t1 := builder.Table(s.To.Table).Schema(s.To.Schema)
223 set.Select(set.C(s.Edge.Columns[0]))
224 q = builder.Select().
225 From(t1).
226 Join(set).
227 On(t1.C(s.To.Column), set.C(s.Edge.Columns[0]))
228 case s.ToEdgeOwner():
229 t1 := builder.Table(s.To.Table).Schema(s.To.Schema)
230 set.Select(set.C(s.From.Column))
231 q = builder.Select().
232 From(t1).
233 Join(set).
234 On(t1.C(s.Edge.Columns[0]), set.C(s.From.Column))
235 }
236 return q
237}
238
239// HasNeighbors applies on the given Selector a neighbors check.
240func HasNeighbors(q *sql.Selector, s *Step) {

Callers 15

QueryOwnerMethod · 0.92
QueryAdminsMethod · 0.92
QueryCarMethod · 0.92
QueryPetsMethod · 0.92
QueryFriendsMethod · 0.92
QueryOwnerMethod · 0.92
QueryParentMethod · 0.92
QueryChildrenMethod · 0.92
QuerySpouseMethod · 0.92
QueryCarMethod · 0.92
QueryOwnerMethod · 0.92
QueryFilesMethod · 0.92

Calls 11

DialectFunction · 0.92
ThroughEdgeTableMethod · 0.80
OnMethod · 0.80
FromEdgeOwnerMethod · 0.80
ToEdgeOwnerMethod · 0.80
CMethod · 0.65
SchemaMethod · 0.45
TableMethod · 0.45
SelectMethod · 0.45
JoinMethod · 0.45
FromMethod · 0.45

Tested by 1

TestSetNeighborsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…