diff --git a/dialect/sql/schema/mysql.go b/dialect/sql/schema/mysql.go index c8a4a9909..9397e50c6 100644 --- a/dialect/sql/schema/mysql.go +++ b/dialect/sql/schema/mysql.go @@ -294,6 +294,9 @@ func (d *MySQL) scanColumn(c *Column, rows *sql.Rows) error { }); parts[0] { case "int": c.Type = field.TypeInt32 + if len(parts) == 3 { // int(10) unsigned. + c.Type = field.TypeUint32 + } case "smallint": c.Type = field.TypeInt16 if len(parts) == 3 { // smallint(5) unsigned. diff --git a/entc/integration/ent/example_test.go b/entc/integration/ent/example_test.go index bc7c945ca..2b106ae08 100644 --- a/entc/integration/ent/example_test.go +++ b/entc/integration/ent/example_test.go @@ -108,6 +108,11 @@ func ExampleFieldType() { SetNillableInt32(1). SetNillableInt64(1). SetValidateOptionalInt32(1). + SetOptionalUint(1). + SetOptionalUint8(1). + SetOptionalUint16(1). + SetOptionalUint32(1). + SetOptionalUint64(1). SetState(fieldtype.StateOn). SaveX(ctx) log.Println("fieldtype created:", ft) diff --git a/entc/integration/ent/fieldtype.go b/entc/integration/ent/fieldtype.go index 20c75c2b7..56be70233 100644 --- a/entc/integration/ent/fieldtype.go +++ b/entc/integration/ent/fieldtype.go @@ -52,6 +52,16 @@ type FieldType struct { NillableInt64 *int64 `json:"nillable_int64,omitempty"` // ValidateOptionalInt32 holds the value of the "validate_optional_int32" field. ValidateOptionalInt32 int32 `json:"validate_optional_int32,omitempty"` + // OptionalUint holds the value of the "optional_uint" field. + OptionalUint uint `json:"optional_uint,omitempty"` + // OptionalUint8 holds the value of the "optional_uint8" field. + OptionalUint8 uint8 `json:"optional_uint8,omitempty"` + // OptionalUint16 holds the value of the "optional_uint16" field. + OptionalUint16 uint16 `json:"optional_uint16,omitempty"` + // OptionalUint32 holds the value of the "optional_uint32" field. + OptionalUint32 uint32 `json:"optional_uint32,omitempty"` + // OptionalUint64 holds the value of the "optional_uint64" field. + OptionalUint64 uint64 `json:"optional_uint64,omitempty"` // State holds the value of the "state" field. State fieldtype.State `json:"state,omitempty"` } @@ -76,6 +86,11 @@ func (*FieldType) scanValues() []interface{} { &sql.NullInt64{}, // nillable_int32 &sql.NullInt64{}, // nillable_int64 &sql.NullInt64{}, // validate_optional_int32 + &sql.NullInt64{}, // optional_uint + &sql.NullInt64{}, // optional_uint8 + &sql.NullInt64{}, // optional_uint16 + &sql.NullInt64{}, // optional_uint32 + &sql.NullInt64{}, // optional_uint64 &sql.NullString{}, // state } } @@ -177,8 +192,33 @@ func (ft *FieldType) assignValues(values ...interface{}) error { } else if value.Valid { ft.ValidateOptionalInt32 = int32(value.Int64) } - if value, ok := values[16].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field state", values[16]) + if value, ok := values[16].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field optional_uint", values[16]) + } else if value.Valid { + ft.OptionalUint = uint(value.Int64) + } + if value, ok := values[17].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field optional_uint8", values[17]) + } else if value.Valid { + ft.OptionalUint8 = uint8(value.Int64) + } + if value, ok := values[18].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field optional_uint16", values[18]) + } else if value.Valid { + ft.OptionalUint16 = uint16(value.Int64) + } + if value, ok := values[19].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field optional_uint32", values[19]) + } else if value.Valid { + ft.OptionalUint32 = uint32(value.Int64) + } + if value, ok := values[20].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field optional_uint64", values[20]) + } else if value.Valid { + ft.OptionalUint64 = uint64(value.Int64) + } + if value, ok := values[21].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field state", values[21]) } else if value.Valid { ft.State = fieldtype.State(value.String) } @@ -250,6 +290,16 @@ func (ft *FieldType) String() string { } builder.WriteString(", validate_optional_int32=") builder.WriteString(fmt.Sprintf("%v", ft.ValidateOptionalInt32)) + builder.WriteString(", optional_uint=") + builder.WriteString(fmt.Sprintf("%v", ft.OptionalUint)) + builder.WriteString(", optional_uint8=") + builder.WriteString(fmt.Sprintf("%v", ft.OptionalUint8)) + builder.WriteString(", optional_uint16=") + builder.WriteString(fmt.Sprintf("%v", ft.OptionalUint16)) + builder.WriteString(", optional_uint32=") + builder.WriteString(fmt.Sprintf("%v", ft.OptionalUint32)) + builder.WriteString(", optional_uint64=") + builder.WriteString(fmt.Sprintf("%v", ft.OptionalUint64)) builder.WriteString(", state=") builder.WriteString(fmt.Sprintf("%v", ft.State)) builder.WriteByte(')') diff --git a/entc/integration/ent/fieldtype/fieldtype.go b/entc/integration/ent/fieldtype/fieldtype.go index 12706947b..194f31855 100644 --- a/entc/integration/ent/fieldtype/fieldtype.go +++ b/entc/integration/ent/fieldtype/fieldtype.go @@ -49,6 +49,16 @@ const ( FieldNillableInt64 = "nillable_int64" // FieldValidateOptionalInt32 holds the string denoting the validate_optional_int32 vertex property in the database. FieldValidateOptionalInt32 = "validate_optional_int32" + // FieldOptionalUint holds the string denoting the optional_uint vertex property in the database. + FieldOptionalUint = "optional_uint" + // FieldOptionalUint8 holds the string denoting the optional_uint8 vertex property in the database. + FieldOptionalUint8 = "optional_uint8" + // FieldOptionalUint16 holds the string denoting the optional_uint16 vertex property in the database. + FieldOptionalUint16 = "optional_uint16" + // FieldOptionalUint32 holds the string denoting the optional_uint32 vertex property in the database. + FieldOptionalUint32 = "optional_uint32" + // FieldOptionalUint64 holds the string denoting the optional_uint64 vertex property in the database. + FieldOptionalUint64 = "optional_uint64" // FieldState holds the string denoting the state vertex property in the database. FieldState = "state" @@ -75,6 +85,11 @@ var Columns = []string{ FieldNillableInt32, FieldNillableInt64, FieldValidateOptionalInt32, + FieldOptionalUint, + FieldOptionalUint8, + FieldOptionalUint16, + FieldOptionalUint32, + FieldOptionalUint64, FieldState, } diff --git a/entc/integration/ent/fieldtype/where.go b/entc/integration/ent/fieldtype/where.go index c5f47e775..ebef90c50 100644 --- a/entc/integration/ent/fieldtype/where.go +++ b/entc/integration/ent/fieldtype/where.go @@ -241,6 +241,46 @@ func ValidateOptionalInt32(v int32) predicate.FieldType { ) } +// OptionalUint applies equality check predicate on the "optional_uint" field. It's identical to OptionalUintEQ. +func OptionalUint(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUint8 applies equality check predicate on the "optional_uint8" field. It's identical to OptionalUint8EQ. +func OptionalUint8(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint16 applies equality check predicate on the "optional_uint16" field. It's identical to OptionalUint16EQ. +func OptionalUint16(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint32 applies equality check predicate on the "optional_uint32" field. It's identical to OptionalUint32EQ. +func OptionalUint32(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint64 applies equality check predicate on the "optional_uint64" field. It's identical to OptionalUint64EQ. +func OptionalUint64(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint64), v)) + }, + ) +} + // IntEQ applies the EQ predicate on the "int" field. func IntEQ(v int) predicate.FieldType { return predicate.FieldType(func(s *sql.Selector) { @@ -1761,6 +1801,506 @@ func ValidateOptionalInt32NotNil() predicate.FieldType { ) } +// OptionalUintEQ applies the EQ predicate on the "optional_uint" field. +func OptionalUintEQ(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUintNEQ applies the NEQ predicate on the "optional_uint" field. +func OptionalUintNEQ(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUintIn applies the In predicate on the "optional_uint" field. +func OptionalUintIn(vs ...uint) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalUint), v...)) + }, + ) +} + +// OptionalUintNotIn applies the NotIn predicate on the "optional_uint" field. +func OptionalUintNotIn(vs ...uint) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalUint), v...)) + }, + ) +} + +// OptionalUintGT applies the GT predicate on the "optional_uint" field. +func OptionalUintGT(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUintGTE applies the GTE predicate on the "optional_uint" field. +func OptionalUintGTE(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUintLT applies the LT predicate on the "optional_uint" field. +func OptionalUintLT(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUintLTE applies the LTE predicate on the "optional_uint" field. +func OptionalUintLTE(v uint) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldOptionalUint), v)) + }, + ) +} + +// OptionalUintIsNil applies the IsNil predicate on the "optional_uint" field. +func OptionalUintIsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldOptionalUint))) + }, + ) +} + +// OptionalUintNotNil applies the NotNil predicate on the "optional_uint" field. +func OptionalUintNotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldOptionalUint))) + }, + ) +} + +// OptionalUint8EQ applies the EQ predicate on the "optional_uint8" field. +func OptionalUint8EQ(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint8NEQ applies the NEQ predicate on the "optional_uint8" field. +func OptionalUint8NEQ(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint8In applies the In predicate on the "optional_uint8" field. +func OptionalUint8In(vs ...uint8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalUint8), v...)) + }, + ) +} + +// OptionalUint8NotIn applies the NotIn predicate on the "optional_uint8" field. +func OptionalUint8NotIn(vs ...uint8) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalUint8), v...)) + }, + ) +} + +// OptionalUint8GT applies the GT predicate on the "optional_uint8" field. +func OptionalUint8GT(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint8GTE applies the GTE predicate on the "optional_uint8" field. +func OptionalUint8GTE(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint8LT applies the LT predicate on the "optional_uint8" field. +func OptionalUint8LT(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint8LTE applies the LTE predicate on the "optional_uint8" field. +func OptionalUint8LTE(v uint8) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldOptionalUint8), v)) + }, + ) +} + +// OptionalUint8IsNil applies the IsNil predicate on the "optional_uint8" field. +func OptionalUint8IsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldOptionalUint8))) + }, + ) +} + +// OptionalUint8NotNil applies the NotNil predicate on the "optional_uint8" field. +func OptionalUint8NotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldOptionalUint8))) + }, + ) +} + +// OptionalUint16EQ applies the EQ predicate on the "optional_uint16" field. +func OptionalUint16EQ(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint16NEQ applies the NEQ predicate on the "optional_uint16" field. +func OptionalUint16NEQ(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint16In applies the In predicate on the "optional_uint16" field. +func OptionalUint16In(vs ...uint16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalUint16), v...)) + }, + ) +} + +// OptionalUint16NotIn applies the NotIn predicate on the "optional_uint16" field. +func OptionalUint16NotIn(vs ...uint16) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalUint16), v...)) + }, + ) +} + +// OptionalUint16GT applies the GT predicate on the "optional_uint16" field. +func OptionalUint16GT(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint16GTE applies the GTE predicate on the "optional_uint16" field. +func OptionalUint16GTE(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint16LT applies the LT predicate on the "optional_uint16" field. +func OptionalUint16LT(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint16LTE applies the LTE predicate on the "optional_uint16" field. +func OptionalUint16LTE(v uint16) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldOptionalUint16), v)) + }, + ) +} + +// OptionalUint16IsNil applies the IsNil predicate on the "optional_uint16" field. +func OptionalUint16IsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldOptionalUint16))) + }, + ) +} + +// OptionalUint16NotNil applies the NotNil predicate on the "optional_uint16" field. +func OptionalUint16NotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldOptionalUint16))) + }, + ) +} + +// OptionalUint32EQ applies the EQ predicate on the "optional_uint32" field. +func OptionalUint32EQ(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint32NEQ applies the NEQ predicate on the "optional_uint32" field. +func OptionalUint32NEQ(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint32In applies the In predicate on the "optional_uint32" field. +func OptionalUint32In(vs ...uint32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalUint32), v...)) + }, + ) +} + +// OptionalUint32NotIn applies the NotIn predicate on the "optional_uint32" field. +func OptionalUint32NotIn(vs ...uint32) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalUint32), v...)) + }, + ) +} + +// OptionalUint32GT applies the GT predicate on the "optional_uint32" field. +func OptionalUint32GT(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint32GTE applies the GTE predicate on the "optional_uint32" field. +func OptionalUint32GTE(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint32LT applies the LT predicate on the "optional_uint32" field. +func OptionalUint32LT(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint32LTE applies the LTE predicate on the "optional_uint32" field. +func OptionalUint32LTE(v uint32) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldOptionalUint32), v)) + }, + ) +} + +// OptionalUint32IsNil applies the IsNil predicate on the "optional_uint32" field. +func OptionalUint32IsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldOptionalUint32))) + }, + ) +} + +// OptionalUint32NotNil applies the NotNil predicate on the "optional_uint32" field. +func OptionalUint32NotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldOptionalUint32))) + }, + ) +} + +// OptionalUint64EQ applies the EQ predicate on the "optional_uint64" field. +func OptionalUint64EQ(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.EQ(s.C(FieldOptionalUint64), v)) + }, + ) +} + +// OptionalUint64NEQ applies the NEQ predicate on the "optional_uint64" field. +func OptionalUint64NEQ(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NEQ(s.C(FieldOptionalUint64), v)) + }, + ) +} + +// OptionalUint64In applies the In predicate on the "optional_uint64" field. +func OptionalUint64In(vs ...uint64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.In(s.C(FieldOptionalUint64), v...)) + }, + ) +} + +// OptionalUint64NotIn applies the NotIn predicate on the "optional_uint64" field. +func OptionalUint64NotIn(vs ...uint64) predicate.FieldType { + v := make([]interface{}, len(vs)) + for i := range v { + v[i] = vs[i] + } + return predicate.FieldType(func(s *sql.Selector) { + // if not arguments were provided, append the FALSE constants, + // since we can't apply "IN ()". This will make this predicate falsy. + if len(vs) == 0 { + s.Where(sql.False()) + return + } + s.Where(sql.NotIn(s.C(FieldOptionalUint64), v...)) + }, + ) +} + +// OptionalUint64GT applies the GT predicate on the "optional_uint64" field. +func OptionalUint64GT(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GT(s.C(FieldOptionalUint64), v)) + }, + ) +} + +// OptionalUint64GTE applies the GTE predicate on the "optional_uint64" field. +func OptionalUint64GTE(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.GTE(s.C(FieldOptionalUint64), v)) + }, + ) +} + +// OptionalUint64LT applies the LT predicate on the "optional_uint64" field. +func OptionalUint64LT(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LT(s.C(FieldOptionalUint64), v)) + }, + ) +} + +// OptionalUint64LTE applies the LTE predicate on the "optional_uint64" field. +func OptionalUint64LTE(v uint64) predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.LTE(s.C(FieldOptionalUint64), v)) + }, + ) +} + +// OptionalUint64IsNil applies the IsNil predicate on the "optional_uint64" field. +func OptionalUint64IsNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.IsNull(s.C(FieldOptionalUint64))) + }, + ) +} + +// OptionalUint64NotNil applies the NotNil predicate on the "optional_uint64" field. +func OptionalUint64NotNil() predicate.FieldType { + return predicate.FieldType(func(s *sql.Selector) { + s.Where(sql.NotNull(s.C(FieldOptionalUint64))) + }, + ) +} + // StateEQ applies the EQ predicate on the "state" field. func StateEQ(v State) predicate.FieldType { return predicate.FieldType(func(s *sql.Selector) { diff --git a/entc/integration/ent/fieldtype_create.go b/entc/integration/ent/fieldtype_create.go index 6599095ca..f75896051 100644 --- a/entc/integration/ent/fieldtype_create.go +++ b/entc/integration/ent/fieldtype_create.go @@ -36,6 +36,11 @@ type FieldTypeCreate struct { nillable_int32 *int32 nillable_int64 *int64 validate_optional_int32 *int32 + optional_uint *uint + optional_uint8 *uint8 + optional_uint16 *uint16 + optional_uint32 *uint32 + optional_uint64 *uint64 state *fieldtype.State } @@ -223,6 +228,76 @@ func (ftc *FieldTypeCreate) SetNillableValidateOptionalInt32(i *int32) *FieldTyp return ftc } +// SetOptionalUint sets the optional_uint field. +func (ftc *FieldTypeCreate) SetOptionalUint(u uint) *FieldTypeCreate { + ftc.optional_uint = &u + return ftc +} + +// SetNillableOptionalUint sets the optional_uint field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableOptionalUint(u *uint) *FieldTypeCreate { + if u != nil { + ftc.SetOptionalUint(*u) + } + return ftc +} + +// SetOptionalUint8 sets the optional_uint8 field. +func (ftc *FieldTypeCreate) SetOptionalUint8(u uint8) *FieldTypeCreate { + ftc.optional_uint8 = &u + return ftc +} + +// SetNillableOptionalUint8 sets the optional_uint8 field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableOptionalUint8(u *uint8) *FieldTypeCreate { + if u != nil { + ftc.SetOptionalUint8(*u) + } + return ftc +} + +// SetOptionalUint16 sets the optional_uint16 field. +func (ftc *FieldTypeCreate) SetOptionalUint16(u uint16) *FieldTypeCreate { + ftc.optional_uint16 = &u + return ftc +} + +// SetNillableOptionalUint16 sets the optional_uint16 field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableOptionalUint16(u *uint16) *FieldTypeCreate { + if u != nil { + ftc.SetOptionalUint16(*u) + } + return ftc +} + +// SetOptionalUint32 sets the optional_uint32 field. +func (ftc *FieldTypeCreate) SetOptionalUint32(u uint32) *FieldTypeCreate { + ftc.optional_uint32 = &u + return ftc +} + +// SetNillableOptionalUint32 sets the optional_uint32 field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableOptionalUint32(u *uint32) *FieldTypeCreate { + if u != nil { + ftc.SetOptionalUint32(*u) + } + return ftc +} + +// SetOptionalUint64 sets the optional_uint64 field. +func (ftc *FieldTypeCreate) SetOptionalUint64(u uint64) *FieldTypeCreate { + ftc.optional_uint64 = &u + return ftc +} + +// SetNillableOptionalUint64 sets the optional_uint64 field if the given value is not nil. +func (ftc *FieldTypeCreate) SetNillableOptionalUint64(u *uint64) *FieldTypeCreate { + if u != nil { + ftc.SetOptionalUint64(*u) + } + return ftc +} + // SetState sets the state field. func (ftc *FieldTypeCreate) SetState(f fieldtype.State) *FieldTypeCreate { ftc.state = &f @@ -415,6 +490,46 @@ func (ftc *FieldTypeCreate) sqlSave(ctx context.Context) (*FieldType, error) { }) ft.ValidateOptionalInt32 = *value } + if value := ftc.optional_uint; value != nil { + spec.Fields = append(spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: *value, + Column: fieldtype.FieldOptionalUint, + }) + ft.OptionalUint = *value + } + if value := ftc.optional_uint8; value != nil { + spec.Fields = append(spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Value: *value, + Column: fieldtype.FieldOptionalUint8, + }) + ft.OptionalUint8 = *value + } + if value := ftc.optional_uint16; value != nil { + spec.Fields = append(spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Value: *value, + Column: fieldtype.FieldOptionalUint16, + }) + ft.OptionalUint16 = *value + } + if value := ftc.optional_uint32; value != nil { + spec.Fields = append(spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Value: *value, + Column: fieldtype.FieldOptionalUint32, + }) + ft.OptionalUint32 = *value + } + if value := ftc.optional_uint64; value != nil { + spec.Fields = append(spec.Fields, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: *value, + Column: fieldtype.FieldOptionalUint64, + }) + ft.OptionalUint64 = *value + } if value := ftc.state; value != nil { spec.Fields = append(spec.Fields, &sqlgraph.FieldSpec{ Type: field.TypeEnum, diff --git a/entc/integration/ent/fieldtype_update.go b/entc/integration/ent/fieldtype_update.go index bfe8e1f50..f3e53e5f2 100644 --- a/entc/integration/ent/fieldtype_update.go +++ b/entc/integration/ent/fieldtype_update.go @@ -63,6 +63,21 @@ type FieldTypeUpdate struct { validate_optional_int32 *int32 addvalidate_optional_int32 *int32 clearvalidate_optional_int32 bool + optional_uint *uint + addoptional_uint *uint + clearoptional_uint bool + optional_uint8 *uint8 + addoptional_uint8 *uint8 + clearoptional_uint8 bool + optional_uint16 *uint16 + addoptional_uint16 *uint16 + clearoptional_uint16 bool + optional_uint32 *uint32 + addoptional_uint32 *uint32 + clearoptional_uint32 bool + optional_uint64 *uint64 + addoptional_uint64 *uint64 + clearoptional_uint64 bool state *fieldtype.State clearstate bool predicates []predicate.FieldType @@ -511,6 +526,166 @@ func (ftu *FieldTypeUpdate) ClearValidateOptionalInt32() *FieldTypeUpdate { return ftu } +// SetOptionalUint sets the optional_uint field. +func (ftu *FieldTypeUpdate) SetOptionalUint(u uint) *FieldTypeUpdate { + ftu.optional_uint = &u + ftu.addoptional_uint = nil + return ftu +} + +// SetNillableOptionalUint sets the optional_uint field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableOptionalUint(u *uint) *FieldTypeUpdate { + if u != nil { + ftu.SetOptionalUint(*u) + } + return ftu +} + +// AddOptionalUint adds u to optional_uint. +func (ftu *FieldTypeUpdate) AddOptionalUint(u uint) *FieldTypeUpdate { + if ftu.addoptional_uint == nil { + ftu.addoptional_uint = &u + } else { + *ftu.addoptional_uint += u + } + return ftu +} + +// ClearOptionalUint clears the value of optional_uint. +func (ftu *FieldTypeUpdate) ClearOptionalUint() *FieldTypeUpdate { + ftu.optional_uint = nil + ftu.clearoptional_uint = true + return ftu +} + +// SetOptionalUint8 sets the optional_uint8 field. +func (ftu *FieldTypeUpdate) SetOptionalUint8(u uint8) *FieldTypeUpdate { + ftu.optional_uint8 = &u + ftu.addoptional_uint8 = nil + return ftu +} + +// SetNillableOptionalUint8 sets the optional_uint8 field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableOptionalUint8(u *uint8) *FieldTypeUpdate { + if u != nil { + ftu.SetOptionalUint8(*u) + } + return ftu +} + +// AddOptionalUint8 adds u to optional_uint8. +func (ftu *FieldTypeUpdate) AddOptionalUint8(u uint8) *FieldTypeUpdate { + if ftu.addoptional_uint8 == nil { + ftu.addoptional_uint8 = &u + } else { + *ftu.addoptional_uint8 += u + } + return ftu +} + +// ClearOptionalUint8 clears the value of optional_uint8. +func (ftu *FieldTypeUpdate) ClearOptionalUint8() *FieldTypeUpdate { + ftu.optional_uint8 = nil + ftu.clearoptional_uint8 = true + return ftu +} + +// SetOptionalUint16 sets the optional_uint16 field. +func (ftu *FieldTypeUpdate) SetOptionalUint16(u uint16) *FieldTypeUpdate { + ftu.optional_uint16 = &u + ftu.addoptional_uint16 = nil + return ftu +} + +// SetNillableOptionalUint16 sets the optional_uint16 field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableOptionalUint16(u *uint16) *FieldTypeUpdate { + if u != nil { + ftu.SetOptionalUint16(*u) + } + return ftu +} + +// AddOptionalUint16 adds u to optional_uint16. +func (ftu *FieldTypeUpdate) AddOptionalUint16(u uint16) *FieldTypeUpdate { + if ftu.addoptional_uint16 == nil { + ftu.addoptional_uint16 = &u + } else { + *ftu.addoptional_uint16 += u + } + return ftu +} + +// ClearOptionalUint16 clears the value of optional_uint16. +func (ftu *FieldTypeUpdate) ClearOptionalUint16() *FieldTypeUpdate { + ftu.optional_uint16 = nil + ftu.clearoptional_uint16 = true + return ftu +} + +// SetOptionalUint32 sets the optional_uint32 field. +func (ftu *FieldTypeUpdate) SetOptionalUint32(u uint32) *FieldTypeUpdate { + ftu.optional_uint32 = &u + ftu.addoptional_uint32 = nil + return ftu +} + +// SetNillableOptionalUint32 sets the optional_uint32 field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableOptionalUint32(u *uint32) *FieldTypeUpdate { + if u != nil { + ftu.SetOptionalUint32(*u) + } + return ftu +} + +// AddOptionalUint32 adds u to optional_uint32. +func (ftu *FieldTypeUpdate) AddOptionalUint32(u uint32) *FieldTypeUpdate { + if ftu.addoptional_uint32 == nil { + ftu.addoptional_uint32 = &u + } else { + *ftu.addoptional_uint32 += u + } + return ftu +} + +// ClearOptionalUint32 clears the value of optional_uint32. +func (ftu *FieldTypeUpdate) ClearOptionalUint32() *FieldTypeUpdate { + ftu.optional_uint32 = nil + ftu.clearoptional_uint32 = true + return ftu +} + +// SetOptionalUint64 sets the optional_uint64 field. +func (ftu *FieldTypeUpdate) SetOptionalUint64(u uint64) *FieldTypeUpdate { + ftu.optional_uint64 = &u + ftu.addoptional_uint64 = nil + return ftu +} + +// SetNillableOptionalUint64 sets the optional_uint64 field if the given value is not nil. +func (ftu *FieldTypeUpdate) SetNillableOptionalUint64(u *uint64) *FieldTypeUpdate { + if u != nil { + ftu.SetOptionalUint64(*u) + } + return ftu +} + +// AddOptionalUint64 adds u to optional_uint64. +func (ftu *FieldTypeUpdate) AddOptionalUint64(u uint64) *FieldTypeUpdate { + if ftu.addoptional_uint64 == nil { + ftu.addoptional_uint64 = &u + } else { + *ftu.addoptional_uint64 += u + } + return ftu +} + +// ClearOptionalUint64 clears the value of optional_uint64. +func (ftu *FieldTypeUpdate) ClearOptionalUint64() *FieldTypeUpdate { + ftu.optional_uint64 = nil + ftu.clearoptional_uint64 = true + return ftu +} + // SetState sets the state field. func (ftu *FieldTypeUpdate) SetState(f fieldtype.State) *FieldTypeUpdate { ftu.state = &f @@ -877,6 +1052,106 @@ func (ftu *FieldTypeUpdate) sqlSave(ctx context.Context) (n int, err error) { Column: fieldtype.FieldValidateOptionalInt32, }) } + if value := ftu.optional_uint; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: *value, + Column: fieldtype.FieldOptionalUint, + }) + } + if value := ftu.addoptional_uint; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: *value, + Column: fieldtype.FieldOptionalUint, + }) + } + if ftu.clearoptional_uint { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: fieldtype.FieldOptionalUint, + }) + } + if value := ftu.optional_uint8; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Value: *value, + Column: fieldtype.FieldOptionalUint8, + }) + } + if value := ftu.addoptional_uint8; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Value: *value, + Column: fieldtype.FieldOptionalUint8, + }) + } + if ftu.clearoptional_uint8 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Column: fieldtype.FieldOptionalUint8, + }) + } + if value := ftu.optional_uint16; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Value: *value, + Column: fieldtype.FieldOptionalUint16, + }) + } + if value := ftu.addoptional_uint16; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Value: *value, + Column: fieldtype.FieldOptionalUint16, + }) + } + if ftu.clearoptional_uint16 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Column: fieldtype.FieldOptionalUint16, + }) + } + if value := ftu.optional_uint32; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Value: *value, + Column: fieldtype.FieldOptionalUint32, + }) + } + if value := ftu.addoptional_uint32; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Value: *value, + Column: fieldtype.FieldOptionalUint32, + }) + } + if ftu.clearoptional_uint32 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Column: fieldtype.FieldOptionalUint32, + }) + } + if value := ftu.optional_uint64; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: *value, + Column: fieldtype.FieldOptionalUint64, + }) + } + if value := ftu.addoptional_uint64; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: *value, + Column: fieldtype.FieldOptionalUint64, + }) + } + if ftu.clearoptional_uint64 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: fieldtype.FieldOptionalUint64, + }) + } if value := ftu.state; value != nil { spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ Type: field.TypeEnum, @@ -946,6 +1221,21 @@ type FieldTypeUpdateOne struct { validate_optional_int32 *int32 addvalidate_optional_int32 *int32 clearvalidate_optional_int32 bool + optional_uint *uint + addoptional_uint *uint + clearoptional_uint bool + optional_uint8 *uint8 + addoptional_uint8 *uint8 + clearoptional_uint8 bool + optional_uint16 *uint16 + addoptional_uint16 *uint16 + clearoptional_uint16 bool + optional_uint32 *uint32 + addoptional_uint32 *uint32 + clearoptional_uint32 bool + optional_uint64 *uint64 + addoptional_uint64 *uint64 + clearoptional_uint64 bool state *fieldtype.State clearstate bool } @@ -1387,6 +1677,166 @@ func (ftuo *FieldTypeUpdateOne) ClearValidateOptionalInt32() *FieldTypeUpdateOne return ftuo } +// SetOptionalUint sets the optional_uint field. +func (ftuo *FieldTypeUpdateOne) SetOptionalUint(u uint) *FieldTypeUpdateOne { + ftuo.optional_uint = &u + ftuo.addoptional_uint = nil + return ftuo +} + +// SetNillableOptionalUint sets the optional_uint field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableOptionalUint(u *uint) *FieldTypeUpdateOne { + if u != nil { + ftuo.SetOptionalUint(*u) + } + return ftuo +} + +// AddOptionalUint adds u to optional_uint. +func (ftuo *FieldTypeUpdateOne) AddOptionalUint(u uint) *FieldTypeUpdateOne { + if ftuo.addoptional_uint == nil { + ftuo.addoptional_uint = &u + } else { + *ftuo.addoptional_uint += u + } + return ftuo +} + +// ClearOptionalUint clears the value of optional_uint. +func (ftuo *FieldTypeUpdateOne) ClearOptionalUint() *FieldTypeUpdateOne { + ftuo.optional_uint = nil + ftuo.clearoptional_uint = true + return ftuo +} + +// SetOptionalUint8 sets the optional_uint8 field. +func (ftuo *FieldTypeUpdateOne) SetOptionalUint8(u uint8) *FieldTypeUpdateOne { + ftuo.optional_uint8 = &u + ftuo.addoptional_uint8 = nil + return ftuo +} + +// SetNillableOptionalUint8 sets the optional_uint8 field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableOptionalUint8(u *uint8) *FieldTypeUpdateOne { + if u != nil { + ftuo.SetOptionalUint8(*u) + } + return ftuo +} + +// AddOptionalUint8 adds u to optional_uint8. +func (ftuo *FieldTypeUpdateOne) AddOptionalUint8(u uint8) *FieldTypeUpdateOne { + if ftuo.addoptional_uint8 == nil { + ftuo.addoptional_uint8 = &u + } else { + *ftuo.addoptional_uint8 += u + } + return ftuo +} + +// ClearOptionalUint8 clears the value of optional_uint8. +func (ftuo *FieldTypeUpdateOne) ClearOptionalUint8() *FieldTypeUpdateOne { + ftuo.optional_uint8 = nil + ftuo.clearoptional_uint8 = true + return ftuo +} + +// SetOptionalUint16 sets the optional_uint16 field. +func (ftuo *FieldTypeUpdateOne) SetOptionalUint16(u uint16) *FieldTypeUpdateOne { + ftuo.optional_uint16 = &u + ftuo.addoptional_uint16 = nil + return ftuo +} + +// SetNillableOptionalUint16 sets the optional_uint16 field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableOptionalUint16(u *uint16) *FieldTypeUpdateOne { + if u != nil { + ftuo.SetOptionalUint16(*u) + } + return ftuo +} + +// AddOptionalUint16 adds u to optional_uint16. +func (ftuo *FieldTypeUpdateOne) AddOptionalUint16(u uint16) *FieldTypeUpdateOne { + if ftuo.addoptional_uint16 == nil { + ftuo.addoptional_uint16 = &u + } else { + *ftuo.addoptional_uint16 += u + } + return ftuo +} + +// ClearOptionalUint16 clears the value of optional_uint16. +func (ftuo *FieldTypeUpdateOne) ClearOptionalUint16() *FieldTypeUpdateOne { + ftuo.optional_uint16 = nil + ftuo.clearoptional_uint16 = true + return ftuo +} + +// SetOptionalUint32 sets the optional_uint32 field. +func (ftuo *FieldTypeUpdateOne) SetOptionalUint32(u uint32) *FieldTypeUpdateOne { + ftuo.optional_uint32 = &u + ftuo.addoptional_uint32 = nil + return ftuo +} + +// SetNillableOptionalUint32 sets the optional_uint32 field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableOptionalUint32(u *uint32) *FieldTypeUpdateOne { + if u != nil { + ftuo.SetOptionalUint32(*u) + } + return ftuo +} + +// AddOptionalUint32 adds u to optional_uint32. +func (ftuo *FieldTypeUpdateOne) AddOptionalUint32(u uint32) *FieldTypeUpdateOne { + if ftuo.addoptional_uint32 == nil { + ftuo.addoptional_uint32 = &u + } else { + *ftuo.addoptional_uint32 += u + } + return ftuo +} + +// ClearOptionalUint32 clears the value of optional_uint32. +func (ftuo *FieldTypeUpdateOne) ClearOptionalUint32() *FieldTypeUpdateOne { + ftuo.optional_uint32 = nil + ftuo.clearoptional_uint32 = true + return ftuo +} + +// SetOptionalUint64 sets the optional_uint64 field. +func (ftuo *FieldTypeUpdateOne) SetOptionalUint64(u uint64) *FieldTypeUpdateOne { + ftuo.optional_uint64 = &u + ftuo.addoptional_uint64 = nil + return ftuo +} + +// SetNillableOptionalUint64 sets the optional_uint64 field if the given value is not nil. +func (ftuo *FieldTypeUpdateOne) SetNillableOptionalUint64(u *uint64) *FieldTypeUpdateOne { + if u != nil { + ftuo.SetOptionalUint64(*u) + } + return ftuo +} + +// AddOptionalUint64 adds u to optional_uint64. +func (ftuo *FieldTypeUpdateOne) AddOptionalUint64(u uint64) *FieldTypeUpdateOne { + if ftuo.addoptional_uint64 == nil { + ftuo.addoptional_uint64 = &u + } else { + *ftuo.addoptional_uint64 += u + } + return ftuo +} + +// ClearOptionalUint64 clears the value of optional_uint64. +func (ftuo *FieldTypeUpdateOne) ClearOptionalUint64() *FieldTypeUpdateOne { + ftuo.optional_uint64 = nil + ftuo.clearoptional_uint64 = true + return ftuo +} + // SetState sets the state field. func (ftuo *FieldTypeUpdateOne) SetState(f fieldtype.State) *FieldTypeUpdateOne { ftuo.state = &f @@ -1747,6 +2197,106 @@ func (ftuo *FieldTypeUpdateOne) sqlSave(ctx context.Context) (ft *FieldType, err Column: fieldtype.FieldValidateOptionalInt32, }) } + if value := ftuo.optional_uint; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: *value, + Column: fieldtype.FieldOptionalUint, + }) + } + if value := ftuo.addoptional_uint; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Value: *value, + Column: fieldtype.FieldOptionalUint, + }) + } + if ftuo.clearoptional_uint { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint, + Column: fieldtype.FieldOptionalUint, + }) + } + if value := ftuo.optional_uint8; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Value: *value, + Column: fieldtype.FieldOptionalUint8, + }) + } + if value := ftuo.addoptional_uint8; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Value: *value, + Column: fieldtype.FieldOptionalUint8, + }) + } + if ftuo.clearoptional_uint8 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint8, + Column: fieldtype.FieldOptionalUint8, + }) + } + if value := ftuo.optional_uint16; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Value: *value, + Column: fieldtype.FieldOptionalUint16, + }) + } + if value := ftuo.addoptional_uint16; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Value: *value, + Column: fieldtype.FieldOptionalUint16, + }) + } + if ftuo.clearoptional_uint16 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint16, + Column: fieldtype.FieldOptionalUint16, + }) + } + if value := ftuo.optional_uint32; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Value: *value, + Column: fieldtype.FieldOptionalUint32, + }) + } + if value := ftuo.addoptional_uint32; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Value: *value, + Column: fieldtype.FieldOptionalUint32, + }) + } + if ftuo.clearoptional_uint32 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint32, + Column: fieldtype.FieldOptionalUint32, + }) + } + if value := ftuo.optional_uint64; value != nil { + spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: *value, + Column: fieldtype.FieldOptionalUint64, + }) + } + if value := ftuo.addoptional_uint64; value != nil { + spec.Fields.Add = append(spec.Fields.Add, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Value: *value, + Column: fieldtype.FieldOptionalUint64, + }) + } + if ftuo.clearoptional_uint64 { + spec.Fields.Clear = append(spec.Fields.Clear, &sqlgraph.FieldSpec{ + Type: field.TypeUint64, + Column: fieldtype.FieldOptionalUint64, + }) + } if value := ftuo.state; value != nil { spec.Fields.Set = append(spec.Fields.Set, &sqlgraph.FieldSpec{ Type: field.TypeEnum, diff --git a/entc/integration/ent/migrate/schema.go b/entc/integration/ent/migrate/schema.go index 4375374d3..b2e112e44 100644 --- a/entc/integration/ent/migrate/schema.go +++ b/entc/integration/ent/migrate/schema.go @@ -74,6 +74,11 @@ var ( {Name: "nillable_int32", Type: field.TypeInt32, Nullable: true}, {Name: "nillable_int64", Type: field.TypeInt64, Nullable: true}, {Name: "validate_optional_int32", Type: field.TypeInt32, Nullable: true}, + {Name: "optional_uint", Type: field.TypeUint, Nullable: true}, + {Name: "optional_uint8", Type: field.TypeUint8, Nullable: true}, + {Name: "optional_uint16", Type: field.TypeUint16, Nullable: true}, + {Name: "optional_uint32", Type: field.TypeUint32, Nullable: true}, + {Name: "optional_uint64", Type: field.TypeUint64, Nullable: true}, {Name: "state", Type: field.TypeEnum, Nullable: true, Enums: []string{"on", "off"}}, } // FieldTypesTable holds the schema information for the "field_types" table. diff --git a/entc/integration/ent/schema/fieldtype.go b/entc/integration/ent/schema/fieldtype.go index b826fd303..374e8f42d 100644 --- a/entc/integration/ent/schema/fieldtype.go +++ b/entc/integration/ent/schema/fieldtype.go @@ -36,6 +36,11 @@ func (FieldType) Fields() []ent.Field { field.Int32("validate_optional_int32"). Optional(). Max(100), + field.Uint("optional_uint").Optional(), + field.Uint8("optional_uint8").Optional(), + field.Uint16("optional_uint16").Optional(), + field.Uint32("optional_uint32").Optional(), + field.Uint64("optional_uint64").Optional(), field.Enum("state"). Values("on", "off"). Optional(),