mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/field: add default value for time
Reviewed By: alexsn Differential Revision: D16890453 fbshipit-source-id: 362ae9e9666c523bdcce16503441565b6279ff08
This commit is contained in:
committed by
Facebook Github Bot
parent
51a4dd4412
commit
079ba191e3
File diff suppressed because one or more lines are too long
@@ -19,17 +19,16 @@ type Schema struct {
|
||||
|
||||
// Field represents an ent.Field that was loaded from a complied user package.
|
||||
type Field struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Type field.Type `json:"type,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Size *int `json:"size,omitempty"`
|
||||
Charset *string `json:"charset,omitempty"`
|
||||
Unique bool `json:"unique,omitempty"`
|
||||
Nillable bool `json:"nillable,omitempty"`
|
||||
Optional bool `json:"optional,omitempty"`
|
||||
Default bool `json:"default,omitempty"`
|
||||
Value interface{} `json:"value,omitempty"`
|
||||
Validators int `json:"validators,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Type field.Type `json:"type,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Size *int `json:"size,omitempty"`
|
||||
Charset *string `json:"charset,omitempty"`
|
||||
Unique bool `json:"unique,omitempty"`
|
||||
Nillable bool `json:"nillable,omitempty"`
|
||||
Optional bool `json:"optional,omitempty"`
|
||||
Default bool `json:"default,omitempty"`
|
||||
Validators int `json:"validators,omitempty"`
|
||||
}
|
||||
|
||||
// Edge represents an ent.Edge that was loaded from a complied user package.
|
||||
@@ -81,7 +80,6 @@ func MarshalSchema(schema ent.Interface) (b []byte, err error) {
|
||||
Name: f.Name(),
|
||||
Type: f.Type(),
|
||||
Tag: f.Tag(),
|
||||
Value: f.Value(),
|
||||
Unique: f.IsUnique(),
|
||||
Default: f.HasDefault(),
|
||||
Nillable: f.IsNillable(),
|
||||
|
||||
@@ -156,11 +156,7 @@ func TestMarshalDefaults(t *testing.T) {
|
||||
|
||||
require.Equal(t, "WithDefaults", schema.Name)
|
||||
require.True(t, schema.Fields[0].Default)
|
||||
require.Equal(t, 1.0, schema.Fields[0].Value, "marshaling converts int to float")
|
||||
require.True(t, schema.Fields[1].Default)
|
||||
require.Equal(t, math.Pi, schema.Fields[1].Value)
|
||||
require.True(t, schema.Fields[2].Default)
|
||||
require.Equal(t, "foo", schema.Fields[2].Value)
|
||||
require.True(t, schema.Fields[3].Default)
|
||||
require.Equal(t, true, schema.Fields[3].Value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user