mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: correctly handle custom storage-key for id fields (#643)
Fixed #621
This commit is contained in:
@@ -107,6 +107,8 @@ func CustomID(t *testing.T, client *ent.Client) {
|
||||
require.Equal(t, pedro.ID, a8m.QueryPets().OnlyIDX(ctx))
|
||||
xabi := client.Pet.Create().SetID("xabi").AddFriends(pedro).SetBestFriend(pedro).SaveX(ctx)
|
||||
require.Equal(t, "xabi", xabi.ID)
|
||||
pedro = client.Pet.Query().Where(pet.HasOwnerWith(user.ID(a8m.ID))).OnlyX(ctx)
|
||||
require.Equal(t, "pedro", pedro.ID)
|
||||
|
||||
pets := client.Pet.Query().WithFriends().WithBestFriend().Order(ent.Asc(pet.FieldID)).AllX(ctx)
|
||||
require.Len(t, pets, 2)
|
||||
|
||||
@@ -15,6 +15,8 @@ const (
|
||||
// EdgeUsers holds the string denoting the users edge name in mutations.
|
||||
EdgeUsers = "users"
|
||||
|
||||
// UserFieldID holds the string denoting the id field of the User.
|
||||
UserFieldID = "oid"
|
||||
// Table holds the table name of the group in the database.
|
||||
Table = "groups"
|
||||
// UsersTable is the table the holds the users relation/edge. The primary key declared below.
|
||||
|
||||
@@ -100,7 +100,7 @@ func HasUsers() predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UsersTable, FieldID),
|
||||
sqlgraph.To(UsersTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, UsersTable, UsersPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -112,7 +112,7 @@ func HasUsersWith(preds ...predicate.User) predicate.Group {
|
||||
return predicate.Group(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(UsersInverseTable, FieldID),
|
||||
sqlgraph.To(UsersInverseTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, UsersTable, UsersPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -21,6 +21,8 @@ const (
|
||||
// EdgeBestFriend holds the string denoting the best_friend edge name in mutations.
|
||||
EdgeBestFriend = "best_friend"
|
||||
|
||||
// UserFieldID holds the string denoting the id field of the User.
|
||||
UserFieldID = "oid"
|
||||
// Table holds the table name of the pet in the database.
|
||||
Table = "pets"
|
||||
// OwnerTable is the table the holds the owner relation/edge.
|
||||
|
||||
@@ -100,7 +100,7 @@ func HasOwner() predicate.Pet {
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerTable, FieldID),
|
||||
sqlgraph.To(OwnerTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Pet {
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -21,6 +21,10 @@ const (
|
||||
// EdgePets holds the string denoting the pets edge name in mutations.
|
||||
EdgePets = "pets"
|
||||
|
||||
// GroupFieldID holds the string denoting the id field of the Group.
|
||||
GroupFieldID = "id"
|
||||
// PetFieldID holds the string denoting the id field of the Pet.
|
||||
PetFieldID = "id"
|
||||
// Table holds the table name of the user in the database.
|
||||
Table = "users"
|
||||
// GroupsTable is the table the holds the groups relation/edge. The primary key declared below.
|
||||
|
||||
@@ -100,7 +100,7 @@ func HasGroups() predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(GroupsTable, FieldID),
|
||||
sqlgraph.To(GroupsTable, GroupFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, GroupsTable, GroupsPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -112,7 +112,7 @@ func HasGroupsWith(preds ...predicate.Group) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(GroupsInverseTable, FieldID),
|
||||
sqlgraph.To(GroupsInverseTable, GroupFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, GroupsTable, GroupsPrimaryKey...),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
@@ -184,7 +184,7 @@ func HasPets() predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(PetsTable, FieldID),
|
||||
sqlgraph.To(PetsTable, PetFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -196,7 +196,7 @@ func HasPetsWith(preds ...predicate.Pet) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(PetsInverseTable, FieldID),
|
||||
sqlgraph.To(PetsInverseTable, PetFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -15,6 +15,8 @@ const (
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
|
||||
// UserFieldID holds the string denoting the id field of the User.
|
||||
UserFieldID = "oid"
|
||||
// Table holds the table name of the car in the database.
|
||||
Table = "cars"
|
||||
// OwnerTable is the table the holds the owner relation/edge.
|
||||
|
||||
@@ -100,7 +100,7 @@ func HasOwner() predicate.Car {
|
||||
return predicate.Car(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerTable, FieldID),
|
||||
sqlgraph.To(OwnerTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Car {
|
||||
return predicate.Car(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -41,6 +41,8 @@ const (
|
||||
// EdgeCar holds the string denoting the car edge name in mutations.
|
||||
EdgeCar = "car"
|
||||
|
||||
// CarFieldID holds the string denoting the id field of the Car.
|
||||
CarFieldID = "id"
|
||||
// Table holds the table name of the user in the database.
|
||||
Table = "users"
|
||||
// ParentTable is the table the holds the parent relation/edge.
|
||||
|
||||
@@ -1058,7 +1058,7 @@ func HasCar() predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CarTable, FieldID),
|
||||
sqlgraph.To(CarTable, CarFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, CarTable, CarColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -1070,7 +1070,7 @@ func HasCarWith(preds ...predicate.Car) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CarInverseTable, FieldID),
|
||||
sqlgraph.To(CarInverseTable, CarFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, CarTable, CarColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -15,6 +15,8 @@ const (
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
|
||||
// UserFieldID holds the string denoting the id field of the User.
|
||||
UserFieldID = "oid"
|
||||
// Table holds the table name of the car in the database.
|
||||
Table = "cars"
|
||||
// OwnerTable is the table the holds the owner relation/edge.
|
||||
|
||||
@@ -100,7 +100,7 @@ func HasOwner() predicate.Car {
|
||||
return predicate.Car(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerTable, FieldID),
|
||||
sqlgraph.To(OwnerTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Car {
|
||||
return predicate.Car(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -15,6 +15,8 @@ const (
|
||||
// EdgeOwner holds the string denoting the owner edge name in mutations.
|
||||
EdgeOwner = "owner"
|
||||
|
||||
// UserFieldID holds the string denoting the id field of the User.
|
||||
UserFieldID = "oid"
|
||||
// Table holds the table name of the pet in the database.
|
||||
Table = "pets"
|
||||
// OwnerTable is the table the holds the owner relation/edge.
|
||||
|
||||
@@ -100,7 +100,7 @@ func HasOwner() predicate.Pet {
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerTable, FieldID),
|
||||
sqlgraph.To(OwnerTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -112,7 +112,7 @@ func HasOwnerWith(preds ...predicate.User) predicate.Pet {
|
||||
return predicate.Pet(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, FieldID),
|
||||
sqlgraph.To(OwnerInverseTable, UserFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, true, OwnerTable, OwnerColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
@@ -43,6 +43,10 @@ const (
|
||||
// EdgeFriends holds the string denoting the friends edge name in mutations.
|
||||
EdgeFriends = "friends"
|
||||
|
||||
// CarFieldID holds the string denoting the id field of the Car.
|
||||
CarFieldID = "id"
|
||||
// PetFieldID holds the string denoting the id field of the Pet.
|
||||
PetFieldID = "id"
|
||||
// Table holds the table name of the user in the database.
|
||||
Table = "users"
|
||||
// CarTable is the table the holds the car relation/edge.
|
||||
|
||||
@@ -1105,7 +1105,7 @@ func HasCar() predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CarTable, FieldID),
|
||||
sqlgraph.To(CarTable, CarFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CarTable, CarColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -1117,7 +1117,7 @@ func HasCarWith(preds ...predicate.Car) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(CarInverseTable, FieldID),
|
||||
sqlgraph.To(CarInverseTable, CarFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, CarTable, CarColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
@@ -1133,7 +1133,7 @@ func HasPets() predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(PetsTable, FieldID),
|
||||
sqlgraph.To(PetsTable, PetFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighbors(s, step)
|
||||
@@ -1145,7 +1145,7 @@ func HasPetsWith(preds ...predicate.Pet) predicate.User {
|
||||
return predicate.User(func(s *sql.Selector) {
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(Table, FieldID),
|
||||
sqlgraph.To(PetsInverseTable, FieldID),
|
||||
sqlgraph.To(PetsInverseTable, PetFieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2O, false, PetsTable, PetsColumn),
|
||||
)
|
||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||
|
||||
Reference in New Issue
Block a user