ent/gen: set currect storage-key for indexes

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

Reviewed By: alexsn

Differential Revision: D17779042

fbshipit-source-id: 12be885b20f91eb611a41e361650f7a66747fab0
This commit is contained in:
Ariel Mashraki
2019-10-05 11:01:36 -07:00
committed by Facebook Github Bot
parent b64330e475
commit 766940563f
8 changed files with 14 additions and 10 deletions

View File

@@ -68,7 +68,7 @@ func (f *File) FromResponse(res *gremlin.Response) error {
}
var vf struct {
ID string `json:"id,omitempty"`
Size int `json:"size,omitempty"`
Size int `json:"fsize,omitempty"`
Name string `json:"name,omitempty"`
User *string `json:"user,omitempty"`
Group string `json:"group,omitempty"`
@@ -156,7 +156,7 @@ func (f *Files) FromResponse(res *gremlin.Response) error {
}
var vf []struct {
ID string `json:"id,omitempty"`
Size int `json:"size,omitempty"`
Size int `json:"fsize,omitempty"`
Name string `json:"name,omitempty"`
User *string `json:"user,omitempty"`
Group string `json:"group,omitempty"`

View File

@@ -16,7 +16,7 @@ const (
// FieldID holds the string denoting the id field in the database.
FieldID = "id"
// FieldSize holds the string denoting the size vertex property in the database.
FieldSize = "size"
FieldSize = "fsize"
// FieldName holds the string denoting the name vertex property in the database.
FieldName = "name"
// FieldUser holds the string denoting the user vertex property in the database.

View File

@@ -85,7 +85,7 @@ var (
// FilesColumns holds the columns for the "files" table.
FilesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "size", Type: field.TypeInt, Default: file.DefaultSize},
{Name: "fsize", Type: field.TypeInt, Default: file.DefaultSize},
{Name: "name", Type: field.TypeString},
{Name: "user", Type: field.TypeString, Nullable: true},
{Name: "group", Type: field.TypeString, Nullable: true},
@@ -123,7 +123,7 @@ var (
},
Indexes: []*schema.Index{
{
Name: "name_size",
Name: "name_fsize",
Unique: false,
Columns: []*schema.Column{FilesColumns[2], FilesColumns[1]},
},

View File

@@ -22,6 +22,7 @@ type File struct {
func (File) Fields() []ent.Field {
return []ent.Field{
field.Int("size").
StorageKey("fsize").
Default(math.MaxInt32).
Positive(),
field.String("name"),