mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/entc: corrently reference default value on migrate generation
Summary:
Migration incorrectly generated field default value on storage key inclusion.
Example Field:
```
field.String("tenant").
StorageKey("organization").
Default("fb-test"),
```
Generated default of:
```
// DefaultTenant holds the default value on creation for the tenant field.
DefaultTenant = descTenant.Default.(string)
```
But migration references non existent default (storage key is used):
```
{Name: "organization", Type: field.TypeString, Default: user.DefaultOrganization},
```
Reviewed By: a8m
Differential Revision: D17578898
fbshipit-source-id: afca92ac3f34c16100c868a10d0a480139bf4262
This commit is contained in:
committed by
Facebook Github Bot
parent
6cf5b918c3
commit
dacc568413
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
// Card is the model entity for the Card schema.
|
||||
type Card struct {
|
||||
config
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Expired holds the value of the "expired" field.
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
// User is the model entity for the User schema.
|
||||
type User struct {
|
||||
config
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int `json:"id,omitempty"`
|
||||
// Age holds the value of the "age" field.
|
||||
|
||||
@@ -37,12 +37,17 @@ func (uu *UserUpdate) Where(ps ...predicate.User) *UserUpdate {
|
||||
// SetAge sets the age field.
|
||||
func (uu *UserUpdate) SetAge(i int) *UserUpdate {
|
||||
uu.age = &i
|
||||
uu.addage = nil
|
||||
return uu
|
||||
}
|
||||
|
||||
// AddAge adds i to age.
|
||||
func (uu *UserUpdate) AddAge(i int) *UserUpdate {
|
||||
uu.addage = &i
|
||||
if uu.addage == nil {
|
||||
uu.addage = &i
|
||||
} else {
|
||||
*uu.addage += i
|
||||
}
|
||||
return uu
|
||||
}
|
||||
|
||||
@@ -204,12 +209,17 @@ type UserUpdateOne struct {
|
||||
// SetAge sets the age field.
|
||||
func (uuo *UserUpdateOne) SetAge(i int) *UserUpdateOne {
|
||||
uuo.age = &i
|
||||
uuo.addage = nil
|
||||
return uuo
|
||||
}
|
||||
|
||||
// AddAge adds i to age.
|
||||
func (uuo *UserUpdateOne) AddAge(i int) *UserUpdateOne {
|
||||
uuo.addage = &i
|
||||
if uuo.addage == nil {
|
||||
uuo.addage = &i
|
||||
} else {
|
||||
*uuo.addage += i
|
||||
}
|
||||
return uuo
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user