mirror of
https://github.com/ent/ent.git
synced 2026-05-28 09:49:08 +03:00
entc/gen: change neighbors predicate to use sqlgraph
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/204 Reviewed By: alexsn Differential Revision: D18726911 fbshipit-source-id: 6fe850bb0c0613c3f1c94e8bbcf3f0684dded9a6
This commit is contained in:
committed by
Facebook Github Bot
parent
5fe9fcdc1b
commit
f7ce61fc3c
@@ -262,16 +262,12 @@ func NameContainsFold(v string) predicate.User {
|
||||
func HasSpouse() predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
t1 := s.Table()
|
||||
builder := sql.Dialect(s.Dialect())
|
||||
s.Where(
|
||||
sql.In(
|
||||
t1.C(FieldID),
|
||||
builder.Select(SpouseColumn).
|
||||
From(builder.Table(SpouseTable)).
|
||||
Where(sql.NotNull(SpouseColumn)),
|
||||
),
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(SpouseTable, FieldID),
|
||||
sql.Edge(sql.O2O, false, SpouseTable, SpouseColumn),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -295,15 +291,12 @@ func HasSpouseWith(preds ...predicate.User) predicate.User {
|
||||
func HasFollowers() predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
t1 := s.Table()
|
||||
builder := sql.Dialect(s.Dialect())
|
||||
s.Where(
|
||||
sql.In(
|
||||
t1.C(FieldID),
|
||||
builder.Select(FollowersPrimaryKey[1]).
|
||||
From(builder.Table(FollowersTable)),
|
||||
),
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(FollowersTable, FieldID),
|
||||
sql.Edge(sql.M2M, true, FollowersTable, FollowersPrimaryKey...),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -334,15 +327,12 @@ func HasFollowersWith(preds ...predicate.User) predicate.User {
|
||||
func HasFollowing() predicate.User {
|
||||
return predicate.User(
|
||||
func(s *sql.Selector) {
|
||||
t1 := s.Table()
|
||||
builder := sql.Dialect(s.Dialect())
|
||||
s.Where(
|
||||
sql.In(
|
||||
t1.C(FieldID),
|
||||
builder.Select(FollowingPrimaryKey[0]).
|
||||
From(builder.Table(FollowingTable)),
|
||||
),
|
||||
step := sql.NewStep(
|
||||
sql.From(Table, FieldID),
|
||||
sql.To(FollowingTable, FieldID),
|
||||
sql.Edge(sql.M2M, false, FollowingTable, FollowingPrimaryKey...),
|
||||
)
|
||||
sql.HasNeighbors(s, step)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user