mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
entc/gen: atlas:pos directive to views (#4400)
This commit is contained in:
@@ -793,7 +793,8 @@ func (g *Graph) Views() (views []*schema.Table, err error) {
|
||||
continue
|
||||
}
|
||||
view := schema.NewView(n.Table()).
|
||||
SetComment(n.sqlComment())
|
||||
SetComment(n.sqlComment()).
|
||||
SetPos(n.Pos())
|
||||
switch ant := n.EntSQL(); {
|
||||
case ant == nil:
|
||||
case ant.Skip:
|
||||
|
||||
@@ -401,6 +401,12 @@ func TestPosition(t *testing.T) {
|
||||
},
|
||||
Annotations: antFn("two"),
|
||||
}
|
||||
petView = &load.Schema{
|
||||
View: true,
|
||||
Name: "PetView",
|
||||
Pos: "pet_view.go:10",
|
||||
Annotations: antFn("two"),
|
||||
}
|
||||
car = &load.Schema{
|
||||
Name: "Car",
|
||||
Pos: "car.go:100",
|
||||
@@ -423,7 +429,7 @@ func TestPosition(t *testing.T) {
|
||||
Annotations: antFn("two"),
|
||||
}
|
||||
)
|
||||
g, err := NewGraph(&Config{Package: "entc/gen", Storage: drivers[0]}, user, pet, car, carOwner)
|
||||
g, err := NewGraph(&Config{Package: "entc/gen", Storage: drivers[0]}, user, pet, petView, car, carOwner)
|
||||
require.NoError(t, err)
|
||||
ts, err := g.Tables()
|
||||
require.NoError(t, err)
|
||||
@@ -433,6 +439,10 @@ func TestPosition(t *testing.T) {
|
||||
require.Equal(t, ts[2].Pos, "car.go:100")
|
||||
require.Equal(t, ts[3].Pos, "car_owner.go:1000") // edge schema has its own position
|
||||
require.Equal(t, ts[4].Pos, "user.go:1") // user owns the pet edge -> user position
|
||||
vs, err := g.Views()
|
||||
require.NoError(t, err)
|
||||
require.Len(t, vs, 1)
|
||||
require.Equal(t, vs[0].Pos, "pet_view.go:10")
|
||||
}
|
||||
|
||||
func TestMultiSchemaAnnotation(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user