entc/load: add schema-type field for schema (#459)

This commit is contained in:
Ariel Mashraki
2020-05-04 19:35:40 +03:00
committed by GitHub
parent cef1058af0
commit 6fbb5b6b4a
3 changed files with 35 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@@ -35,22 +35,23 @@ type Position struct {
// Field represents an ent.Field that was loaded from a complied user package.
type Field struct {
Name string `json:"name,omitempty"`
Info *field.TypeInfo `json:"type,omitempty"`
Tag string `json:"tag,omitempty"`
Size *int64 `json:"size,omitempty"`
Enums []string `json:"enums,omitempty"`
Unique bool `json:"unique,omitempty"`
Nillable bool `json:"nillable,omitempty"`
Optional bool `json:"optional,omitempty"`
Default bool `json:"default,omitempty"`
DefaultValue interface{} `json:"default_value,omitempty"`
UpdateDefault bool `json:"update_default,omitempty"`
Immutable bool `json:"immutable,omitempty"`
Validators int `json:"validators,omitempty"`
StorageKey string `json:"storage_key,omitempty"`
Position *Position `json:"position,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
Name string `json:"name,omitempty"`
Info *field.TypeInfo `json:"type,omitempty"`
Tag string `json:"tag,omitempty"`
Size *int64 `json:"size,omitempty"`
Enums []string `json:"enums,omitempty"`
Unique bool `json:"unique,omitempty"`
Nillable bool `json:"nillable,omitempty"`
Optional bool `json:"optional,omitempty"`
Default bool `json:"default,omitempty"`
DefaultValue interface{} `json:"default_value,omitempty"`
UpdateDefault bool `json:"update_default,omitempty"`
Immutable bool `json:"immutable,omitempty"`
Validators int `json:"validators,omitempty"`
StorageKey string `json:"storage_key,omitempty"`
Position *Position `json:"position,omitempty"`
Sensitive bool `json:"sensitive,omitempty"`
SchemaType map[string]string `json:"schema_type,omitempty"`
}
// Edge represents an ent.Edge that was loaded from a complied user package.
@@ -106,6 +107,7 @@ func NewField(fd *field.Descriptor) (*Field, error) {
StorageKey: fd.StorageKey,
Validators: len(fd.Validators),
Sensitive: fd.Sensitive,
SchemaType: fd.SchemaType,
}
if sf.Info == nil {
return nil, fmt.Errorf("missing type info for field %q", sf.Name)