From 01ed4ea61b0ae082d139d702a6ee2ee36cb1c988 Mon Sep 17 00:00:00 2001 From: godcong Date: Mon, 6 Nov 2023 14:36:24 +0800 Subject: [PATCH] feat(database): optimize database format --- ent/client.go | 8 +- ent/crud.go | 65 ++-- ent/migrate/schema.go | 17 +- ent/mutation.go | 722 +++++++++++++++++------------------ ent/ncharacter.go | 152 ++++---- ent/ncharacter/ncharacter.go | 100 +++-- ent/ncharacter/where.go | 479 ++++++++++------------- ent/ncharacter_create.go | 652 +++++++++++++++---------------- ent/ncharacter_delete.go | 2 +- ent/ncharacter_query.go | 18 +- ent/ncharacter_update.go | 329 ++++++++-------- ent/runtime.go | 11 + ent/schema/ncharacter.go | 35 +- 13 files changed, 1213 insertions(+), 1377 deletions(-) diff --git a/ent/client.go b/ent/client.go index bb679bd..3d35ba6 100644 --- a/ent/client.go +++ b/ent/client.go @@ -426,7 +426,7 @@ func (c *NCharacterClient) UpdateOne(n *NCharacter) *NCharacterUpdateOne { } // UpdateOneID returns an update builder for the given id. -func (c *NCharacterClient) UpdateOneID(id string) *NCharacterUpdateOne { +func (c *NCharacterClient) UpdateOneID(id int32) *NCharacterUpdateOne { mutation := newNCharacterMutation(c.config, OpUpdateOne, withNCharacterID(id)) return &NCharacterUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -443,7 +443,7 @@ func (c *NCharacterClient) DeleteOne(n *NCharacter) *NCharacterDeleteOne { } // DeleteOneID returns a builder for deleting the given entity by its id. -func (c *NCharacterClient) DeleteOneID(id string) *NCharacterDeleteOne { +func (c *NCharacterClient) DeleteOneID(id int32) *NCharacterDeleteOne { builder := c.Delete().Where(ncharacter.ID(id)) builder.mutation.id = &id builder.mutation.op = OpDeleteOne @@ -460,12 +460,12 @@ func (c *NCharacterClient) Query() *NCharacterQuery { } // Get returns a NCharacter entity by its id. -func (c *NCharacterClient) Get(ctx context.Context, id string) (*NCharacter, error) { +func (c *NCharacterClient) Get(ctx context.Context, id int32) (*NCharacter, error) { return c.Query().Where(ncharacter.ID(id)).Only(ctx) } // GetX is like Get, but panics if an error occurs. -func (c *NCharacterClient) GetX(ctx context.Context, id string) *NCharacter { +func (c *NCharacterClient) GetX(ctx context.Context, id int32) *NCharacter { obj, err := c.Get(ctx, id) if err != nil { panic(err) diff --git a/ent/crud.go b/ent/crud.go index 49fea9e..940bdfa 100644 --- a/ent/crud.go +++ b/ent/crud.go @@ -134,105 +134,100 @@ func (cu *CharacterUpdate) SetCharacterWithOptional(input *Character) *Character func (nc *NCharacterCreate) SetNCharacter(input *NCharacter) *NCharacterCreate { nc.SetPinYin(input.PinYin) - nc.SetChID(input.ChID) nc.SetCh(input.Ch) + nc.SetChStroke(input.ChStroke) + nc.SetChType(input.ChType) nc.SetRadical(input.Radical) nc.SetRadicalStroke(input.RadicalStroke) - nc.SetTotalStroke(input.TotalStroke) - nc.SetIsKangXi(input.IsKangXi) + nc.SetRelate(input.Relate) nc.SetRelateKangXi(input.RelateKangXi) - nc.SetRelateSimple(input.RelateSimple) nc.SetRelateTraditional(input.RelateTraditional) nc.SetRelateVariant(input.RelateVariant) - nc.SetNameScience(input.NameScience) - nc.SetScienceStroke(input.ScienceStroke) + nc.SetIsNameScience(input.IsNameScience) + nc.SetNameScienceChStroke(input.NameScienceChStroke) + nc.SetIsRegular(input.IsRegular) nc.SetWuXing(input.WuXing) nc.SetLucky(input.Lucky) - nc.SetRegular(input.Regular) nc.SetComment(input.Comment) return nc } func (nc *NCharacterCreate) SetNCharacterWithOptional(input *NCharacter) *NCharacterCreate { nc.SetPinYin(input.PinYin) - nc.SetChID(input.ChID) nc.SetCh(input.Ch) + nc.SetChStroke(input.ChStroke) + nc.SetChType(input.ChType) nc.SetRadical(input.Radical) nc.SetRadicalStroke(input.RadicalStroke) - nc.SetTotalStroke(input.TotalStroke) - nc.SetIsKangXi(input.IsKangXi) + nc.SetRelate(input.Relate) nc.SetRelateKangXi(input.RelateKangXi) - nc.SetRelateSimple(input.RelateSimple) nc.SetRelateTraditional(input.RelateTraditional) nc.SetRelateVariant(input.RelateVariant) - nc.SetNameScience(input.NameScience) - nc.SetScienceStroke(input.ScienceStroke) + nc.SetIsNameScience(input.IsNameScience) + nc.SetNameScienceChStroke(input.NameScienceChStroke) + nc.SetIsRegular(input.IsRegular) nc.SetWuXing(input.WuXing) nc.SetLucky(input.Lucky) - nc.SetRegular(input.Regular) nc.SetComment(input.Comment) return nc } func (nuo *NCharacterUpdateOne) SetNCharacter(input *NCharacter) *NCharacterUpdateOne { nuo.SetPinYin(input.PinYin) - nuo.SetChID(input.ChID) nuo.SetCh(input.Ch) + nuo.SetChStroke(input.ChStroke) + nuo.SetChType(input.ChType) nuo.SetRadical(input.Radical) nuo.SetRadicalStroke(input.RadicalStroke) - nuo.SetTotalStroke(input.TotalStroke) - nuo.SetIsKangXi(input.IsKangXi) + nuo.SetRelate(input.Relate) nuo.SetRelateKangXi(input.RelateKangXi) - nuo.SetRelateSimple(input.RelateSimple) nuo.SetRelateTraditional(input.RelateTraditional) nuo.SetRelateVariant(input.RelateVariant) - nuo.SetNameScience(input.NameScience) - nuo.SetScienceStroke(input.ScienceStroke) + nuo.SetIsNameScience(input.IsNameScience) + nuo.SetNameScienceChStroke(input.NameScienceChStroke) + nuo.SetIsRegular(input.IsRegular) nuo.SetWuXing(input.WuXing) nuo.SetLucky(input.Lucky) - nuo.SetRegular(input.Regular) nuo.SetComment(input.Comment) return nuo } func (nu *NCharacterUpdate) SetNCharacter(input *NCharacter) *NCharacterUpdate { nu.SetPinYin(input.PinYin) - nu.SetChID(input.ChID) nu.SetCh(input.Ch) + nu.SetChStroke(input.ChStroke) + nu.SetChType(input.ChType) nu.SetRadical(input.Radical) nu.SetRadicalStroke(input.RadicalStroke) - nu.SetTotalStroke(input.TotalStroke) - nu.SetIsKangXi(input.IsKangXi) + nu.SetRelate(input.Relate) nu.SetRelateKangXi(input.RelateKangXi) - nu.SetRelateSimple(input.RelateSimple) nu.SetRelateTraditional(input.RelateTraditional) nu.SetRelateVariant(input.RelateVariant) - nu.SetNameScience(input.NameScience) - nu.SetScienceStroke(input.ScienceStroke) + nu.SetIsNameScience(input.IsNameScience) + nu.SetNameScienceChStroke(input.NameScienceChStroke) + nu.SetIsRegular(input.IsRegular) nu.SetWuXing(input.WuXing) nu.SetLucky(input.Lucky) - nu.SetRegular(input.Regular) nu.SetComment(input.Comment) return nu } func (nu *NCharacterUpdate) SetNCharacterWithOptional(input *NCharacter) *NCharacterUpdate { nu.SetPinYin(input.PinYin) - nu.SetChID(input.ChID) nu.SetCh(input.Ch) + nu.SetChStroke(input.ChStroke) + nu.SetChType(input.ChType) nu.SetRadical(input.Radical) nu.SetRadicalStroke(input.RadicalStroke) - nu.SetTotalStroke(input.TotalStroke) - nu.SetIsKangXi(input.IsKangXi) + nu.SetRelate(input.Relate) nu.SetRelateKangXi(input.RelateKangXi) - nu.SetRelateSimple(input.RelateSimple) nu.SetRelateTraditional(input.RelateTraditional) nu.SetRelateVariant(input.RelateVariant) - nu.SetNameScience(input.NameScience) - nu.SetScienceStroke(input.ScienceStroke) + nu.SetIsNameScience(input.IsNameScience) + nu.SetNameScienceChStroke(input.NameScienceChStroke) + nu.SetIsRegular(input.IsRegular) nu.SetWuXing(input.WuXing) nu.SetLucky(input.Lucky) - nu.SetRegular(input.Regular) nu.SetComment(input.Comment) return nu } diff --git a/ent/migrate/schema.go b/ent/migrate/schema.go index f4b0516..33a2e75 100644 --- a/ent/migrate/schema.go +++ b/ent/migrate/schema.go @@ -43,23 +43,22 @@ var ( } // NCharacterColumns holds the columns for the "n_character" table. NCharacterColumns = []*schema.Column{ - {Name: "hash", Type: field.TypeString}, + {Name: "id", Type: field.TypeInt32, Increment: true}, {Name: "pin_yin", Type: field.TypeString}, - {Name: "ch_id", Type: field.TypeInt64}, {Name: "ch", Type: field.TypeString}, + {Name: "ch_stroke", Type: field.TypeInt}, + {Name: "ch_type", Type: field.TypeInt, Default: 0}, {Name: "radical", Type: field.TypeString}, {Name: "radical_stroke", Type: field.TypeInt}, - {Name: "total_stroke", Type: field.TypeInt}, - {Name: "is_kang_xi", Type: field.TypeBool}, + {Name: "relate", Type: field.TypeString}, {Name: "relate_kang_xi", Type: field.TypeString}, - {Name: "relate_simple", Type: field.TypeString}, {Name: "relate_traditional", Type: field.TypeString}, - {Name: "relate_variant", Type: field.TypeString}, - {Name: "name_science", Type: field.TypeBool}, - {Name: "science_stroke", Type: field.TypeInt}, + {Name: "relate_variant", Type: field.TypeJSON}, + {Name: "is_name_science", Type: field.TypeBool}, + {Name: "name_science_ch_stroke", Type: field.TypeInt}, + {Name: "is_regular", Type: field.TypeBool}, {Name: "wu_xing", Type: field.TypeString}, {Name: "lucky", Type: field.TypeString}, - {Name: "regular", Type: field.TypeBool}, {Name: "comment", Type: field.TypeString}, } // NCharacterTable holds the schema information for the "n_character" table. diff --git a/ent/mutation.go b/ent/mutation.go index 63009f7..aa2f07a 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -1772,34 +1772,34 @@ func (m *CharacterMutation) ResetEdge(name string) error { // NCharacterMutation represents an operation that mutates the NCharacter nodes in the graph. type NCharacterMutation struct { config - op Op - typ string - id *string - pin_yin *string - ch_id *int64 - addch_id *int64 - ch *string - radical *string - radical_stroke *int - addradical_stroke *int - total_stroke *int - addtotal_stroke *int - is_kang_xi *bool - relate_kang_xi *string - relate_simple *string - relate_traditional *string - relate_variant *string - name_science *bool - science_stroke *int - addscience_stroke *int - wu_xing *string - lucky *string - regular *bool - comment *string - clearedFields map[string]struct{} - done bool - oldValue func(context.Context) (*NCharacter, error) - predicates []predicate.NCharacter + op Op + typ string + id *int32 + pin_yin *string + ch *string + ch_stroke *int + addch_stroke *int + ch_type *int + addch_type *int + radical *string + radical_stroke *int + addradical_stroke *int + relate *string + relate_kang_xi *string + relate_traditional *string + relate_variant *[]string + appendrelate_variant []string + is_name_science *bool + name_science_ch_stroke *int + addname_science_ch_stroke *int + is_regular *bool + wu_xing *string + lucky *string + comment *string + clearedFields map[string]struct{} + done bool + oldValue func(context.Context) (*NCharacter, error) + predicates []predicate.NCharacter } var _ ent.Mutation = (*NCharacterMutation)(nil) @@ -1822,7 +1822,7 @@ func newNCharacterMutation(c config, op Op, opts ...ncharacterOption) *NCharacte } // withNCharacterID sets the ID field of the mutation. -func withNCharacterID(id string) ncharacterOption { +func withNCharacterID(id int32) ncharacterOption { return func(m *NCharacterMutation) { var ( err error @@ -1874,13 +1874,13 @@ func (m NCharacterMutation) Tx() (*Tx, error) { // SetID sets the value of the id field. Note that this // operation is only accepted on creation of NCharacter entities. -func (m *NCharacterMutation) SetID(id string) { +func (m *NCharacterMutation) SetID(id int32) { m.id = &id } // ID returns the ID value in the mutation. Note that the ID is only available // if it was provided to the builder or after it was returned from the database. -func (m *NCharacterMutation) ID() (id string, exists bool) { +func (m *NCharacterMutation) ID() (id int32, exists bool) { if m.id == nil { return } @@ -1891,12 +1891,12 @@ func (m *NCharacterMutation) ID() (id string, exists bool) { // That means, if the mutation is applied within a transaction with an isolation level such // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated // or updated by the mutation. -func (m *NCharacterMutation) IDs(ctx context.Context) ([]string, error) { +func (m *NCharacterMutation) IDs(ctx context.Context) ([]int32, error) { switch { case m.op.Is(OpUpdateOne | OpDeleteOne): id, exists := m.ID() if exists { - return []string{id}, nil + return []int32{id}, nil } fallthrough case m.op.Is(OpUpdate | OpDelete): @@ -1942,96 +1942,152 @@ func (m *NCharacterMutation) ResetPinYin() { m.pin_yin = nil } -// SetChID sets the "ch_id" field. -func (m *NCharacterMutation) SetChID(i int64) { - m.ch_id = &i - m.addch_id = nil +// SetCh sets the "ch" field. +func (m *NCharacterMutation) SetCh(s string) { + m.ch = &s } -// ChID returns the value of the "ch_id" field in the mutation. -func (m *NCharacterMutation) ChID() (r int64, exists bool) { - v := m.ch_id +// Ch returns the value of the "ch" field in the mutation. +func (m *NCharacterMutation) Ch() (r string, exists bool) { + v := m.ch if v == nil { return } return *v, true } -// OldChID returns the old "ch_id" field's value of the NCharacter entity. +// OldCh returns the old "ch" field's value of the NCharacter entity. // If the NCharacter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldChID(ctx context.Context) (v int64, err error) { +func (m *NCharacterMutation) OldCh(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldChID is only allowed on UpdateOne operations") + return v, errors.New("OldCh is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldChID requires an ID field in the mutation") + return v, errors.New("OldCh requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldChID: %w", err) + return v, fmt.Errorf("querying old value for OldCh: %w", err) } - return oldValue.ChID, nil + return oldValue.Ch, nil } -// AddChID adds i to the "ch_id" field. -func (m *NCharacterMutation) AddChID(i int64) { - if m.addch_id != nil { - *m.addch_id += i +// ResetCh resets all changes to the "ch" field. +func (m *NCharacterMutation) ResetCh() { + m.ch = nil +} + +// SetChStroke sets the "ch_stroke" field. +func (m *NCharacterMutation) SetChStroke(i int) { + m.ch_stroke = &i + m.addch_stroke = nil +} + +// ChStroke returns the value of the "ch_stroke" field in the mutation. +func (m *NCharacterMutation) ChStroke() (r int, exists bool) { + v := m.ch_stroke + if v == nil { + return + } + return *v, true +} + +// OldChStroke returns the old "ch_stroke" field's value of the NCharacter entity. +// If the NCharacter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NCharacterMutation) OldChStroke(ctx context.Context) (v int, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldChStroke is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldChStroke requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldChStroke: %w", err) + } + return oldValue.ChStroke, nil +} + +// AddChStroke adds i to the "ch_stroke" field. +func (m *NCharacterMutation) AddChStroke(i int) { + if m.addch_stroke != nil { + *m.addch_stroke += i } else { - m.addch_id = &i + m.addch_stroke = &i } } -// AddedChID returns the value that was added to the "ch_id" field in this mutation. -func (m *NCharacterMutation) AddedChID() (r int64, exists bool) { - v := m.addch_id +// AddedChStroke returns the value that was added to the "ch_stroke" field in this mutation. +func (m *NCharacterMutation) AddedChStroke() (r int, exists bool) { + v := m.addch_stroke if v == nil { return } return *v, true } -// ResetChID resets all changes to the "ch_id" field. -func (m *NCharacterMutation) ResetChID() { - m.ch_id = nil - m.addch_id = nil +// ResetChStroke resets all changes to the "ch_stroke" field. +func (m *NCharacterMutation) ResetChStroke() { + m.ch_stroke = nil + m.addch_stroke = nil } -// SetCh sets the "ch" field. -func (m *NCharacterMutation) SetCh(s string) { - m.ch = &s +// SetChType sets the "ch_type" field. +func (m *NCharacterMutation) SetChType(i int) { + m.ch_type = &i + m.addch_type = nil } -// Ch returns the value of the "ch" field in the mutation. -func (m *NCharacterMutation) Ch() (r string, exists bool) { - v := m.ch +// ChType returns the value of the "ch_type" field in the mutation. +func (m *NCharacterMutation) ChType() (r int, exists bool) { + v := m.ch_type if v == nil { return } return *v, true } -// OldCh returns the old "ch" field's value of the NCharacter entity. +// OldChType returns the old "ch_type" field's value of the NCharacter entity. // If the NCharacter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldCh(ctx context.Context) (v string, err error) { +func (m *NCharacterMutation) OldChType(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldCh is only allowed on UpdateOne operations") + return v, errors.New("OldChType is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldCh requires an ID field in the mutation") + return v, errors.New("OldChType requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldCh: %w", err) + return v, fmt.Errorf("querying old value for OldChType: %w", err) } - return oldValue.Ch, nil + return oldValue.ChType, nil } -// ResetCh resets all changes to the "ch" field. -func (m *NCharacterMutation) ResetCh() { - m.ch = nil +// AddChType adds i to the "ch_type" field. +func (m *NCharacterMutation) AddChType(i int) { + if m.addch_type != nil { + *m.addch_type += i + } else { + m.addch_type = &i + } +} + +// AddedChType returns the value that was added to the "ch_type" field in this mutation. +func (m *NCharacterMutation) AddedChType() (r int, exists bool) { + v := m.addch_type + if v == nil { + return + } + return *v, true +} + +// ResetChType resets all changes to the "ch_type" field. +func (m *NCharacterMutation) ResetChType() { + m.ch_type = nil + m.addch_type = nil } // SetRadical sets the "radical" field. @@ -2126,96 +2182,40 @@ func (m *NCharacterMutation) ResetRadicalStroke() { m.addradical_stroke = nil } -// SetTotalStroke sets the "total_stroke" field. -func (m *NCharacterMutation) SetTotalStroke(i int) { - m.total_stroke = &i - m.addtotal_stroke = nil -} - -// TotalStroke returns the value of the "total_stroke" field in the mutation. -func (m *NCharacterMutation) TotalStroke() (r int, exists bool) { - v := m.total_stroke - if v == nil { - return - } - return *v, true -} - -// OldTotalStroke returns the old "total_stroke" field's value of the NCharacter entity. -// If the NCharacter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldTotalStroke(ctx context.Context) (v int, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldTotalStroke is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldTotalStroke requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldTotalStroke: %w", err) - } - return oldValue.TotalStroke, nil +// SetRelate sets the "relate" field. +func (m *NCharacterMutation) SetRelate(s string) { + m.relate = &s } -// AddTotalStroke adds i to the "total_stroke" field. -func (m *NCharacterMutation) AddTotalStroke(i int) { - if m.addtotal_stroke != nil { - *m.addtotal_stroke += i - } else { - m.addtotal_stroke = &i - } -} - -// AddedTotalStroke returns the value that was added to the "total_stroke" field in this mutation. -func (m *NCharacterMutation) AddedTotalStroke() (r int, exists bool) { - v := m.addtotal_stroke +// Relate returns the value of the "relate" field in the mutation. +func (m *NCharacterMutation) Relate() (r string, exists bool) { + v := m.relate if v == nil { return } return *v, true } -// ResetTotalStroke resets all changes to the "total_stroke" field. -func (m *NCharacterMutation) ResetTotalStroke() { - m.total_stroke = nil - m.addtotal_stroke = nil -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (m *NCharacterMutation) SetIsKangXi(b bool) { - m.is_kang_xi = &b -} - -// IsKangXi returns the value of the "is_kang_xi" field in the mutation. -func (m *NCharacterMutation) IsKangXi() (r bool, exists bool) { - v := m.is_kang_xi - if v == nil { - return - } - return *v, true -} - -// OldIsKangXi returns the old "is_kang_xi" field's value of the NCharacter entity. +// OldRelate returns the old "relate" field's value of the NCharacter entity. // If the NCharacter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldIsKangXi(ctx context.Context) (v bool, err error) { +func (m *NCharacterMutation) OldRelate(ctx context.Context) (v string, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldIsKangXi is only allowed on UpdateOne operations") + return v, errors.New("OldRelate is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldIsKangXi requires an ID field in the mutation") + return v, errors.New("OldRelate requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldIsKangXi: %w", err) + return v, fmt.Errorf("querying old value for OldRelate: %w", err) } - return oldValue.IsKangXi, nil + return oldValue.Relate, nil } -// ResetIsKangXi resets all changes to the "is_kang_xi" field. -func (m *NCharacterMutation) ResetIsKangXi() { - m.is_kang_xi = nil +// ResetRelate resets all changes to the "relate" field. +func (m *NCharacterMutation) ResetRelate() { + m.relate = nil } // SetRelateKangXi sets the "relate_kang_xi" field. @@ -2254,42 +2254,6 @@ func (m *NCharacterMutation) ResetRelateKangXi() { m.relate_kang_xi = nil } -// SetRelateSimple sets the "relate_simple" field. -func (m *NCharacterMutation) SetRelateSimple(s string) { - m.relate_simple = &s -} - -// RelateSimple returns the value of the "relate_simple" field in the mutation. -func (m *NCharacterMutation) RelateSimple() (r string, exists bool) { - v := m.relate_simple - if v == nil { - return - } - return *v, true -} - -// OldRelateSimple returns the old "relate_simple" field's value of the NCharacter entity. -// If the NCharacter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldRelateSimple(ctx context.Context) (v string, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRelateSimple is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRelateSimple requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRelateSimple: %w", err) - } - return oldValue.RelateSimple, nil -} - -// ResetRelateSimple resets all changes to the "relate_simple" field. -func (m *NCharacterMutation) ResetRelateSimple() { - m.relate_simple = nil -} - // SetRelateTraditional sets the "relate_traditional" field. func (m *NCharacterMutation) SetRelateTraditional(s string) { m.relate_traditional = &s @@ -2327,12 +2291,13 @@ func (m *NCharacterMutation) ResetRelateTraditional() { } // SetRelateVariant sets the "relate_variant" field. -func (m *NCharacterMutation) SetRelateVariant(s string) { +func (m *NCharacterMutation) SetRelateVariant(s []string) { m.relate_variant = &s + m.appendrelate_variant = nil } // RelateVariant returns the value of the "relate_variant" field in the mutation. -func (m *NCharacterMutation) RelateVariant() (r string, exists bool) { +func (m *NCharacterMutation) RelateVariant() (r []string, exists bool) { v := m.relate_variant if v == nil { return @@ -2343,7 +2308,7 @@ func (m *NCharacterMutation) RelateVariant() (r string, exists bool) { // OldRelateVariant returns the old "relate_variant" field's value of the NCharacter entity. // If the NCharacter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldRelateVariant(ctx context.Context) (v string, err error) { +func (m *NCharacterMutation) OldRelateVariant(ctx context.Context) (v []string, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldRelateVariant is only allowed on UpdateOne operations") } @@ -2357,101 +2322,151 @@ func (m *NCharacterMutation) OldRelateVariant(ctx context.Context) (v string, er return oldValue.RelateVariant, nil } +// AppendRelateVariant adds s to the "relate_variant" field. +func (m *NCharacterMutation) AppendRelateVariant(s []string) { + m.appendrelate_variant = append(m.appendrelate_variant, s...) +} + +// AppendedRelateVariant returns the list of values that were appended to the "relate_variant" field in this mutation. +func (m *NCharacterMutation) AppendedRelateVariant() ([]string, bool) { + if len(m.appendrelate_variant) == 0 { + return nil, false + } + return m.appendrelate_variant, true +} + // ResetRelateVariant resets all changes to the "relate_variant" field. func (m *NCharacterMutation) ResetRelateVariant() { m.relate_variant = nil + m.appendrelate_variant = nil } -// SetNameScience sets the "name_science" field. -func (m *NCharacterMutation) SetNameScience(b bool) { - m.name_science = &b +// SetIsNameScience sets the "is_name_science" field. +func (m *NCharacterMutation) SetIsNameScience(b bool) { + m.is_name_science = &b } -// NameScience returns the value of the "name_science" field in the mutation. -func (m *NCharacterMutation) NameScience() (r bool, exists bool) { - v := m.name_science +// IsNameScience returns the value of the "is_name_science" field in the mutation. +func (m *NCharacterMutation) IsNameScience() (r bool, exists bool) { + v := m.is_name_science if v == nil { return } return *v, true } -// OldNameScience returns the old "name_science" field's value of the NCharacter entity. +// OldIsNameScience returns the old "is_name_science" field's value of the NCharacter entity. // If the NCharacter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldNameScience(ctx context.Context) (v bool, err error) { +func (m *NCharacterMutation) OldIsNameScience(ctx context.Context) (v bool, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldNameScience is only allowed on UpdateOne operations") + return v, errors.New("OldIsNameScience is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldNameScience requires an ID field in the mutation") + return v, errors.New("OldIsNameScience requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldNameScience: %w", err) + return v, fmt.Errorf("querying old value for OldIsNameScience: %w", err) } - return oldValue.NameScience, nil + return oldValue.IsNameScience, nil } -// ResetNameScience resets all changes to the "name_science" field. -func (m *NCharacterMutation) ResetNameScience() { - m.name_science = nil +// ResetIsNameScience resets all changes to the "is_name_science" field. +func (m *NCharacterMutation) ResetIsNameScience() { + m.is_name_science = nil } -// SetScienceStroke sets the "science_stroke" field. -func (m *NCharacterMutation) SetScienceStroke(i int) { - m.science_stroke = &i - m.addscience_stroke = nil +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (m *NCharacterMutation) SetNameScienceChStroke(i int) { + m.name_science_ch_stroke = &i + m.addname_science_ch_stroke = nil } -// ScienceStroke returns the value of the "science_stroke" field in the mutation. -func (m *NCharacterMutation) ScienceStroke() (r int, exists bool) { - v := m.science_stroke +// NameScienceChStroke returns the value of the "name_science_ch_stroke" field in the mutation. +func (m *NCharacterMutation) NameScienceChStroke() (r int, exists bool) { + v := m.name_science_ch_stroke if v == nil { return } return *v, true } -// OldScienceStroke returns the old "science_stroke" field's value of the NCharacter entity. +// OldNameScienceChStroke returns the old "name_science_ch_stroke" field's value of the NCharacter entity. // If the NCharacter object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldScienceStroke(ctx context.Context) (v int, err error) { +func (m *NCharacterMutation) OldNameScienceChStroke(ctx context.Context) (v int, err error) { if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldScienceStroke is only allowed on UpdateOne operations") + return v, errors.New("OldNameScienceChStroke is only allowed on UpdateOne operations") } if m.id == nil || m.oldValue == nil { - return v, errors.New("OldScienceStroke requires an ID field in the mutation") + return v, errors.New("OldNameScienceChStroke requires an ID field in the mutation") } oldValue, err := m.oldValue(ctx) if err != nil { - return v, fmt.Errorf("querying old value for OldScienceStroke: %w", err) + return v, fmt.Errorf("querying old value for OldNameScienceChStroke: %w", err) } - return oldValue.ScienceStroke, nil + return oldValue.NameScienceChStroke, nil } -// AddScienceStroke adds i to the "science_stroke" field. -func (m *NCharacterMutation) AddScienceStroke(i int) { - if m.addscience_stroke != nil { - *m.addscience_stroke += i +// AddNameScienceChStroke adds i to the "name_science_ch_stroke" field. +func (m *NCharacterMutation) AddNameScienceChStroke(i int) { + if m.addname_science_ch_stroke != nil { + *m.addname_science_ch_stroke += i } else { - m.addscience_stroke = &i + m.addname_science_ch_stroke = &i } } -// AddedScienceStroke returns the value that was added to the "science_stroke" field in this mutation. -func (m *NCharacterMutation) AddedScienceStroke() (r int, exists bool) { - v := m.addscience_stroke +// AddedNameScienceChStroke returns the value that was added to the "name_science_ch_stroke" field in this mutation. +func (m *NCharacterMutation) AddedNameScienceChStroke() (r int, exists bool) { + v := m.addname_science_ch_stroke if v == nil { return } return *v, true } -// ResetScienceStroke resets all changes to the "science_stroke" field. -func (m *NCharacterMutation) ResetScienceStroke() { - m.science_stroke = nil - m.addscience_stroke = nil +// ResetNameScienceChStroke resets all changes to the "name_science_ch_stroke" field. +func (m *NCharacterMutation) ResetNameScienceChStroke() { + m.name_science_ch_stroke = nil + m.addname_science_ch_stroke = nil +} + +// SetIsRegular sets the "is_regular" field. +func (m *NCharacterMutation) SetIsRegular(b bool) { + m.is_regular = &b +} + +// IsRegular returns the value of the "is_regular" field in the mutation. +func (m *NCharacterMutation) IsRegular() (r bool, exists bool) { + v := m.is_regular + if v == nil { + return + } + return *v, true +} + +// OldIsRegular returns the old "is_regular" field's value of the NCharacter entity. +// If the NCharacter object wasn't provided to the builder, the object is fetched from the database. +// An error is returned if the mutation operation is not UpdateOne, or the database query fails. +func (m *NCharacterMutation) OldIsRegular(ctx context.Context) (v bool, err error) { + if !m.op.Is(OpUpdateOne) { + return v, errors.New("OldIsRegular is only allowed on UpdateOne operations") + } + if m.id == nil || m.oldValue == nil { + return v, errors.New("OldIsRegular requires an ID field in the mutation") + } + oldValue, err := m.oldValue(ctx) + if err != nil { + return v, fmt.Errorf("querying old value for OldIsRegular: %w", err) + } + return oldValue.IsRegular, nil +} + +// ResetIsRegular resets all changes to the "is_regular" field. +func (m *NCharacterMutation) ResetIsRegular() { + m.is_regular = nil } // SetWuXing sets the "wu_xing" field. @@ -2526,42 +2541,6 @@ func (m *NCharacterMutation) ResetLucky() { m.lucky = nil } -// SetRegular sets the "regular" field. -func (m *NCharacterMutation) SetRegular(b bool) { - m.regular = &b -} - -// Regular returns the value of the "regular" field in the mutation. -func (m *NCharacterMutation) Regular() (r bool, exists bool) { - v := m.regular - if v == nil { - return - } - return *v, true -} - -// OldRegular returns the old "regular" field's value of the NCharacter entity. -// If the NCharacter object wasn't provided to the builder, the object is fetched from the database. -// An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *NCharacterMutation) OldRegular(ctx context.Context) (v bool, err error) { - if !m.op.Is(OpUpdateOne) { - return v, errors.New("OldRegular is only allowed on UpdateOne operations") - } - if m.id == nil || m.oldValue == nil { - return v, errors.New("OldRegular requires an ID field in the mutation") - } - oldValue, err := m.oldValue(ctx) - if err != nil { - return v, fmt.Errorf("querying old value for OldRegular: %w", err) - } - return oldValue.Regular, nil -} - -// ResetRegular resets all changes to the "regular" field. -func (m *NCharacterMutation) ResetRegular() { - m.regular = nil -} - // SetComment sets the "comment" field. func (m *NCharacterMutation) SetComment(s string) { m.comment = &s @@ -2632,45 +2611,45 @@ func (m *NCharacterMutation) Type() string { // order to get all numeric fields that were incremented/decremented, call // AddedFields(). func (m *NCharacterMutation) Fields() []string { - fields := make([]string, 0, 17) + fields := make([]string, 0, 16) if m.pin_yin != nil { fields = append(fields, ncharacter.FieldPinYin) } - if m.ch_id != nil { - fields = append(fields, ncharacter.FieldChID) - } if m.ch != nil { fields = append(fields, ncharacter.FieldCh) } + if m.ch_stroke != nil { + fields = append(fields, ncharacter.FieldChStroke) + } + if m.ch_type != nil { + fields = append(fields, ncharacter.FieldChType) + } if m.radical != nil { fields = append(fields, ncharacter.FieldRadical) } if m.radical_stroke != nil { fields = append(fields, ncharacter.FieldRadicalStroke) } - if m.total_stroke != nil { - fields = append(fields, ncharacter.FieldTotalStroke) - } - if m.is_kang_xi != nil { - fields = append(fields, ncharacter.FieldIsKangXi) + if m.relate != nil { + fields = append(fields, ncharacter.FieldRelate) } if m.relate_kang_xi != nil { fields = append(fields, ncharacter.FieldRelateKangXi) } - if m.relate_simple != nil { - fields = append(fields, ncharacter.FieldRelateSimple) - } if m.relate_traditional != nil { fields = append(fields, ncharacter.FieldRelateTraditional) } if m.relate_variant != nil { fields = append(fields, ncharacter.FieldRelateVariant) } - if m.name_science != nil { - fields = append(fields, ncharacter.FieldNameScience) + if m.is_name_science != nil { + fields = append(fields, ncharacter.FieldIsNameScience) } - if m.science_stroke != nil { - fields = append(fields, ncharacter.FieldScienceStroke) + if m.name_science_ch_stroke != nil { + fields = append(fields, ncharacter.FieldNameScienceChStroke) + } + if m.is_regular != nil { + fields = append(fields, ncharacter.FieldIsRegular) } if m.wu_xing != nil { fields = append(fields, ncharacter.FieldWuXing) @@ -2678,9 +2657,6 @@ func (m *NCharacterMutation) Fields() []string { if m.lucky != nil { fields = append(fields, ncharacter.FieldLucky) } - if m.regular != nil { - fields = append(fields, ncharacter.FieldRegular) - } if m.comment != nil { fields = append(fields, ncharacter.FieldComment) } @@ -2694,36 +2670,34 @@ func (m *NCharacterMutation) Field(name string) (ent.Value, bool) { switch name { case ncharacter.FieldPinYin: return m.PinYin() - case ncharacter.FieldChID: - return m.ChID() case ncharacter.FieldCh: return m.Ch() + case ncharacter.FieldChStroke: + return m.ChStroke() + case ncharacter.FieldChType: + return m.ChType() case ncharacter.FieldRadical: return m.Radical() case ncharacter.FieldRadicalStroke: return m.RadicalStroke() - case ncharacter.FieldTotalStroke: - return m.TotalStroke() - case ncharacter.FieldIsKangXi: - return m.IsKangXi() + case ncharacter.FieldRelate: + return m.Relate() case ncharacter.FieldRelateKangXi: return m.RelateKangXi() - case ncharacter.FieldRelateSimple: - return m.RelateSimple() case ncharacter.FieldRelateTraditional: return m.RelateTraditional() case ncharacter.FieldRelateVariant: return m.RelateVariant() - case ncharacter.FieldNameScience: - return m.NameScience() - case ncharacter.FieldScienceStroke: - return m.ScienceStroke() + case ncharacter.FieldIsNameScience: + return m.IsNameScience() + case ncharacter.FieldNameScienceChStroke: + return m.NameScienceChStroke() + case ncharacter.FieldIsRegular: + return m.IsRegular() case ncharacter.FieldWuXing: return m.WuXing() case ncharacter.FieldLucky: return m.Lucky() - case ncharacter.FieldRegular: - return m.Regular() case ncharacter.FieldComment: return m.Comment() } @@ -2737,36 +2711,34 @@ func (m *NCharacterMutation) OldField(ctx context.Context, name string) (ent.Val switch name { case ncharacter.FieldPinYin: return m.OldPinYin(ctx) - case ncharacter.FieldChID: - return m.OldChID(ctx) case ncharacter.FieldCh: return m.OldCh(ctx) + case ncharacter.FieldChStroke: + return m.OldChStroke(ctx) + case ncharacter.FieldChType: + return m.OldChType(ctx) case ncharacter.FieldRadical: return m.OldRadical(ctx) case ncharacter.FieldRadicalStroke: return m.OldRadicalStroke(ctx) - case ncharacter.FieldTotalStroke: - return m.OldTotalStroke(ctx) - case ncharacter.FieldIsKangXi: - return m.OldIsKangXi(ctx) + case ncharacter.FieldRelate: + return m.OldRelate(ctx) case ncharacter.FieldRelateKangXi: return m.OldRelateKangXi(ctx) - case ncharacter.FieldRelateSimple: - return m.OldRelateSimple(ctx) case ncharacter.FieldRelateTraditional: return m.OldRelateTraditional(ctx) case ncharacter.FieldRelateVariant: return m.OldRelateVariant(ctx) - case ncharacter.FieldNameScience: - return m.OldNameScience(ctx) - case ncharacter.FieldScienceStroke: - return m.OldScienceStroke(ctx) + case ncharacter.FieldIsNameScience: + return m.OldIsNameScience(ctx) + case ncharacter.FieldNameScienceChStroke: + return m.OldNameScienceChStroke(ctx) + case ncharacter.FieldIsRegular: + return m.OldIsRegular(ctx) case ncharacter.FieldWuXing: return m.OldWuXing(ctx) case ncharacter.FieldLucky: return m.OldLucky(ctx) - case ncharacter.FieldRegular: - return m.OldRegular(ctx) case ncharacter.FieldComment: return m.OldComment(ctx) } @@ -2785,13 +2757,6 @@ func (m *NCharacterMutation) SetField(name string, value ent.Value) error { } m.SetPinYin(v) return nil - case ncharacter.FieldChID: - v, ok := value.(int64) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetChID(v) - return nil case ncharacter.FieldCh: v, ok := value.(string) if !ok { @@ -2799,47 +2764,47 @@ func (m *NCharacterMutation) SetField(name string, value ent.Value) error { } m.SetCh(v) return nil - case ncharacter.FieldRadical: - v, ok := value.(string) + case ncharacter.FieldChStroke: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRadical(v) + m.SetChStroke(v) return nil - case ncharacter.FieldRadicalStroke: + case ncharacter.FieldChType: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRadicalStroke(v) + m.SetChType(v) return nil - case ncharacter.FieldTotalStroke: - v, ok := value.(int) + case ncharacter.FieldRadical: + v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetTotalStroke(v) + m.SetRadical(v) return nil - case ncharacter.FieldIsKangXi: - v, ok := value.(bool) + case ncharacter.FieldRadicalStroke: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetIsKangXi(v) + m.SetRadicalStroke(v) return nil - case ncharacter.FieldRelateKangXi: + case ncharacter.FieldRelate: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRelateKangXi(v) + m.SetRelate(v) return nil - case ncharacter.FieldRelateSimple: + case ncharacter.FieldRelateKangXi: v, ok := value.(string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetRelateSimple(v) + m.SetRelateKangXi(v) return nil case ncharacter.FieldRelateTraditional: v, ok := value.(string) @@ -2849,25 +2814,32 @@ func (m *NCharacterMutation) SetField(name string, value ent.Value) error { m.SetRelateTraditional(v) return nil case ncharacter.FieldRelateVariant: - v, ok := value.(string) + v, ok := value.([]string) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } m.SetRelateVariant(v) return nil - case ncharacter.FieldNameScience: + case ncharacter.FieldIsNameScience: v, ok := value.(bool) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetNameScience(v) + m.SetIsNameScience(v) return nil - case ncharacter.FieldScienceStroke: + case ncharacter.FieldNameScienceChStroke: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.SetScienceStroke(v) + m.SetNameScienceChStroke(v) + return nil + case ncharacter.FieldIsRegular: + v, ok := value.(bool) + if !ok { + return fmt.Errorf("unexpected type %T for field %s", value, name) + } + m.SetIsRegular(v) return nil case ncharacter.FieldWuXing: v, ok := value.(string) @@ -2883,13 +2855,6 @@ func (m *NCharacterMutation) SetField(name string, value ent.Value) error { } m.SetLucky(v) return nil - case ncharacter.FieldRegular: - v, ok := value.(bool) - if !ok { - return fmt.Errorf("unexpected type %T for field %s", value, name) - } - m.SetRegular(v) - return nil case ncharacter.FieldComment: v, ok := value.(string) if !ok { @@ -2905,17 +2870,17 @@ func (m *NCharacterMutation) SetField(name string, value ent.Value) error { // this mutation. func (m *NCharacterMutation) AddedFields() []string { var fields []string - if m.addch_id != nil { - fields = append(fields, ncharacter.FieldChID) + if m.addch_stroke != nil { + fields = append(fields, ncharacter.FieldChStroke) + } + if m.addch_type != nil { + fields = append(fields, ncharacter.FieldChType) } if m.addradical_stroke != nil { fields = append(fields, ncharacter.FieldRadicalStroke) } - if m.addtotal_stroke != nil { - fields = append(fields, ncharacter.FieldTotalStroke) - } - if m.addscience_stroke != nil { - fields = append(fields, ncharacter.FieldScienceStroke) + if m.addname_science_ch_stroke != nil { + fields = append(fields, ncharacter.FieldNameScienceChStroke) } return fields } @@ -2925,14 +2890,14 @@ func (m *NCharacterMutation) AddedFields() []string { // was not set, or was not defined in the schema. func (m *NCharacterMutation) AddedField(name string) (ent.Value, bool) { switch name { - case ncharacter.FieldChID: - return m.AddedChID() + case ncharacter.FieldChStroke: + return m.AddedChStroke() + case ncharacter.FieldChType: + return m.AddedChType() case ncharacter.FieldRadicalStroke: return m.AddedRadicalStroke() - case ncharacter.FieldTotalStroke: - return m.AddedTotalStroke() - case ncharacter.FieldScienceStroke: - return m.AddedScienceStroke() + case ncharacter.FieldNameScienceChStroke: + return m.AddedNameScienceChStroke() } return nil, false } @@ -2942,33 +2907,33 @@ func (m *NCharacterMutation) AddedField(name string) (ent.Value, bool) { // type. func (m *NCharacterMutation) AddField(name string, value ent.Value) error { switch name { - case ncharacter.FieldChID: - v, ok := value.(int64) + case ncharacter.FieldChStroke: + v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddChID(v) + m.AddChStroke(v) return nil - case ncharacter.FieldRadicalStroke: + case ncharacter.FieldChType: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddRadicalStroke(v) + m.AddChType(v) return nil - case ncharacter.FieldTotalStroke: + case ncharacter.FieldRadicalStroke: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddTotalStroke(v) + m.AddRadicalStroke(v) return nil - case ncharacter.FieldScienceStroke: + case ncharacter.FieldNameScienceChStroke: v, ok := value.(int) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } - m.AddScienceStroke(v) + m.AddNameScienceChStroke(v) return nil } return fmt.Errorf("unknown NCharacter numeric field %s", name) @@ -3000,41 +2965,41 @@ func (m *NCharacterMutation) ResetField(name string) error { case ncharacter.FieldPinYin: m.ResetPinYin() return nil - case ncharacter.FieldChID: - m.ResetChID() - return nil case ncharacter.FieldCh: m.ResetCh() return nil + case ncharacter.FieldChStroke: + m.ResetChStroke() + return nil + case ncharacter.FieldChType: + m.ResetChType() + return nil case ncharacter.FieldRadical: m.ResetRadical() return nil case ncharacter.FieldRadicalStroke: m.ResetRadicalStroke() return nil - case ncharacter.FieldTotalStroke: - m.ResetTotalStroke() - return nil - case ncharacter.FieldIsKangXi: - m.ResetIsKangXi() + case ncharacter.FieldRelate: + m.ResetRelate() return nil case ncharacter.FieldRelateKangXi: m.ResetRelateKangXi() return nil - case ncharacter.FieldRelateSimple: - m.ResetRelateSimple() - return nil case ncharacter.FieldRelateTraditional: m.ResetRelateTraditional() return nil case ncharacter.FieldRelateVariant: m.ResetRelateVariant() return nil - case ncharacter.FieldNameScience: - m.ResetNameScience() + case ncharacter.FieldIsNameScience: + m.ResetIsNameScience() return nil - case ncharacter.FieldScienceStroke: - m.ResetScienceStroke() + case ncharacter.FieldNameScienceChStroke: + m.ResetNameScienceChStroke() + return nil + case ncharacter.FieldIsRegular: + m.ResetIsRegular() return nil case ncharacter.FieldWuXing: m.ResetWuXing() @@ -3042,9 +3007,6 @@ func (m *NCharacterMutation) ResetField(name string) error { case ncharacter.FieldLucky: m.ResetLucky() return nil - case ncharacter.FieldRegular: - m.ResetRegular() - return nil case ncharacter.FieldComment: m.ResetComment() return nil diff --git a/ent/ncharacter.go b/ent/ncharacter.go index 0d28a85..f3e3691 100644 --- a/ent/ncharacter.go +++ b/ent/ncharacter.go @@ -3,6 +3,7 @@ package ent import ( + "encoding/json" "fmt" "strings" @@ -15,39 +16,37 @@ import ( type NCharacter struct { config `json:"-"` // ID of the ent. - ID string `json:"id,omitempty"` + ID int32 `json:"id,omitempty"` // PinYin holds the value of the "pin_yin" field. PinYin string `json:"pin_yin,omitempty"` - // ChID holds the value of the "ch_id" field. - ChID int64 `json:"ch_id,omitempty"` // Ch holds the value of the "ch" field. Ch string `json:"ch,omitempty"` + // ChStroke holds the value of the "ch_stroke" field. + ChStroke int `json:"ch_stroke,omitempty"` + // ChType holds the value of the "ch_type" field. + ChType int `json:"ch_type,omitempty"` // Radical holds the value of the "radical" field. Radical string `json:"radical,omitempty"` // RadicalStroke holds the value of the "radical_stroke" field. RadicalStroke int `json:"radical_stroke,omitempty"` - // TotalStroke holds the value of the "total_stroke" field. - TotalStroke int `json:"total_stroke,omitempty"` - // IsKangXi holds the value of the "is_kang_xi" field. - IsKangXi bool `json:"is_kang_xi,omitempty"` + // Relate holds the value of the "relate" field. + Relate string `json:"relate,omitempty"` // RelateKangXi holds the value of the "relate_kang_xi" field. RelateKangXi string `json:"relate_kang_xi,omitempty"` - // RelateSimple holds the value of the "relate_simple" field. - RelateSimple string `json:"relate_simple,omitempty"` // RelateTraditional holds the value of the "relate_traditional" field. RelateTraditional string `json:"relate_traditional,omitempty"` // RelateVariant holds the value of the "relate_variant" field. - RelateVariant string `json:"relate_variant,omitempty"` - // NameScience holds the value of the "name_science" field. - NameScience bool `json:"name_science,omitempty"` - // ScienceStroke holds the value of the "science_stroke" field. - ScienceStroke int `json:"science_stroke,omitempty"` + RelateVariant []string `json:"relate_variant,omitempty"` + // IsNameScience holds the value of the "is_name_science" field. + IsNameScience bool `json:"is_name_science,omitempty"` + // NameScienceChStroke holds the value of the "name_science_ch_stroke" field. + NameScienceChStroke int `json:"name_science_ch_stroke,omitempty"` + // IsRegular holds the value of the "is_regular" field. + IsRegular bool `json:"is_regular,omitempty"` // WuXing holds the value of the "wu_xing" field. WuXing string `json:"wu_xing,omitempty"` // Lucky holds the value of the "lucky" field. Lucky string `json:"lucky,omitempty"` - // Regular holds the value of the "regular" field. - Regular bool `json:"regular,omitempty"` // Comment holds the value of the "comment" field. Comment string `json:"comment,omitempty"` selectValues sql.SelectValues @@ -58,11 +57,13 @@ func (*NCharacter) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { - case ncharacter.FieldIsKangXi, ncharacter.FieldNameScience, ncharacter.FieldRegular: + case ncharacter.FieldRelateVariant: + values[i] = new([]byte) + case ncharacter.FieldIsNameScience, ncharacter.FieldIsRegular: values[i] = new(sql.NullBool) - case ncharacter.FieldChID, ncharacter.FieldRadicalStroke, ncharacter.FieldTotalStroke, ncharacter.FieldScienceStroke: + case ncharacter.FieldID, ncharacter.FieldChStroke, ncharacter.FieldChType, ncharacter.FieldRadicalStroke, ncharacter.FieldNameScienceChStroke: values[i] = new(sql.NullInt64) - case ncharacter.FieldID, ncharacter.FieldPinYin, ncharacter.FieldCh, ncharacter.FieldRadical, ncharacter.FieldRelateKangXi, ncharacter.FieldRelateSimple, ncharacter.FieldRelateTraditional, ncharacter.FieldRelateVariant, ncharacter.FieldWuXing, ncharacter.FieldLucky, ncharacter.FieldComment: + case ncharacter.FieldPinYin, ncharacter.FieldCh, ncharacter.FieldRadical, ncharacter.FieldRelate, ncharacter.FieldRelateKangXi, ncharacter.FieldRelateTraditional, ncharacter.FieldWuXing, ncharacter.FieldLucky, ncharacter.FieldComment: values[i] = new(sql.NullString) default: values[i] = new(sql.UnknownType) @@ -80,29 +81,35 @@ func (n *NCharacter) assignValues(columns []string, values []any) error { for i := range columns { switch columns[i] { case ncharacter.FieldID: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field id", values[i]) - } else if value.Valid { - n.ID = value.String + value, ok := values[i].(*sql.NullInt64) + if !ok { + return fmt.Errorf("unexpected type %T for field id", value) } + n.ID = int32(value.Int64) case ncharacter.FieldPinYin: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field pin_yin", values[i]) } else if value.Valid { n.PinYin = value.String } - case ncharacter.FieldChID: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field ch_id", values[i]) - } else if value.Valid { - n.ChID = value.Int64 - } case ncharacter.FieldCh: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field ch", values[i]) } else if value.Valid { n.Ch = value.String } + case ncharacter.FieldChStroke: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ch_stroke", values[i]) + } else if value.Valid { + n.ChStroke = int(value.Int64) + } + case ncharacter.FieldChType: + if value, ok := values[i].(*sql.NullInt64); !ok { + return fmt.Errorf("unexpected type %T for field ch_type", values[i]) + } else if value.Valid { + n.ChType = int(value.Int64) + } case ncharacter.FieldRadical: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field radical", values[i]) @@ -115,17 +122,11 @@ func (n *NCharacter) assignValues(columns []string, values []any) error { } else if value.Valid { n.RadicalStroke = int(value.Int64) } - case ncharacter.FieldTotalStroke: - if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field total_stroke", values[i]) - } else if value.Valid { - n.TotalStroke = int(value.Int64) - } - case ncharacter.FieldIsKangXi: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field is_kang_xi", values[i]) + case ncharacter.FieldRelate: + if value, ok := values[i].(*sql.NullString); !ok { + return fmt.Errorf("unexpected type %T for field relate", values[i]) } else if value.Valid { - n.IsKangXi = value.Bool + n.Relate = value.String } case ncharacter.FieldRelateKangXi: if value, ok := values[i].(*sql.NullString); !ok { @@ -133,12 +134,6 @@ func (n *NCharacter) assignValues(columns []string, values []any) error { } else if value.Valid { n.RelateKangXi = value.String } - case ncharacter.FieldRelateSimple: - if value, ok := values[i].(*sql.NullString); !ok { - return fmt.Errorf("unexpected type %T for field relate_simple", values[i]) - } else if value.Valid { - n.RelateSimple = value.String - } case ncharacter.FieldRelateTraditional: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field relate_traditional", values[i]) @@ -146,22 +141,30 @@ func (n *NCharacter) assignValues(columns []string, values []any) error { n.RelateTraditional = value.String } case ncharacter.FieldRelateVariant: - if value, ok := values[i].(*sql.NullString); !ok { + if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field relate_variant", values[i]) - } else if value.Valid { - n.RelateVariant = value.String + } else if value != nil && len(*value) > 0 { + if err := json.Unmarshal(*value, &n.RelateVariant); err != nil { + return fmt.Errorf("unmarshal field relate_variant: %w", err) + } } - case ncharacter.FieldNameScience: + case ncharacter.FieldIsNameScience: if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field name_science", values[i]) + return fmt.Errorf("unexpected type %T for field is_name_science", values[i]) } else if value.Valid { - n.NameScience = value.Bool + n.IsNameScience = value.Bool } - case ncharacter.FieldScienceStroke: + case ncharacter.FieldNameScienceChStroke: if value, ok := values[i].(*sql.NullInt64); !ok { - return fmt.Errorf("unexpected type %T for field science_stroke", values[i]) + return fmt.Errorf("unexpected type %T for field name_science_ch_stroke", values[i]) } else if value.Valid { - n.ScienceStroke = int(value.Int64) + n.NameScienceChStroke = int(value.Int64) + } + case ncharacter.FieldIsRegular: + if value, ok := values[i].(*sql.NullBool); !ok { + return fmt.Errorf("unexpected type %T for field is_regular", values[i]) + } else if value.Valid { + n.IsRegular = value.Bool } case ncharacter.FieldWuXing: if value, ok := values[i].(*sql.NullString); !ok { @@ -175,12 +178,6 @@ func (n *NCharacter) assignValues(columns []string, values []any) error { } else if value.Valid { n.Lucky = value.String } - case ncharacter.FieldRegular: - if value, ok := values[i].(*sql.NullBool); !ok { - return fmt.Errorf("unexpected type %T for field regular", values[i]) - } else if value.Valid { - n.Regular = value.Bool - } case ncharacter.FieldComment: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field comment", values[i]) @@ -226,41 +223,41 @@ func (n *NCharacter) String() string { builder.WriteString("pin_yin=") builder.WriteString(n.PinYin) builder.WriteString(", ") - builder.WriteString("ch_id=") - builder.WriteString(fmt.Sprintf("%v", n.ChID)) - builder.WriteString(", ") builder.WriteString("ch=") builder.WriteString(n.Ch) builder.WriteString(", ") + builder.WriteString("ch_stroke=") + builder.WriteString(fmt.Sprintf("%v", n.ChStroke)) + builder.WriteString(", ") + builder.WriteString("ch_type=") + builder.WriteString(fmt.Sprintf("%v", n.ChType)) + builder.WriteString(", ") builder.WriteString("radical=") builder.WriteString(n.Radical) builder.WriteString(", ") builder.WriteString("radical_stroke=") builder.WriteString(fmt.Sprintf("%v", n.RadicalStroke)) builder.WriteString(", ") - builder.WriteString("total_stroke=") - builder.WriteString(fmt.Sprintf("%v", n.TotalStroke)) - builder.WriteString(", ") - builder.WriteString("is_kang_xi=") - builder.WriteString(fmt.Sprintf("%v", n.IsKangXi)) + builder.WriteString("relate=") + builder.WriteString(n.Relate) builder.WriteString(", ") builder.WriteString("relate_kang_xi=") builder.WriteString(n.RelateKangXi) builder.WriteString(", ") - builder.WriteString("relate_simple=") - builder.WriteString(n.RelateSimple) - builder.WriteString(", ") builder.WriteString("relate_traditional=") builder.WriteString(n.RelateTraditional) builder.WriteString(", ") builder.WriteString("relate_variant=") - builder.WriteString(n.RelateVariant) + builder.WriteString(fmt.Sprintf("%v", n.RelateVariant)) builder.WriteString(", ") - builder.WriteString("name_science=") - builder.WriteString(fmt.Sprintf("%v", n.NameScience)) + builder.WriteString("is_name_science=") + builder.WriteString(fmt.Sprintf("%v", n.IsNameScience)) builder.WriteString(", ") - builder.WriteString("science_stroke=") - builder.WriteString(fmt.Sprintf("%v", n.ScienceStroke)) + builder.WriteString("name_science_ch_stroke=") + builder.WriteString(fmt.Sprintf("%v", n.NameScienceChStroke)) + builder.WriteString(", ") + builder.WriteString("is_regular=") + builder.WriteString(fmt.Sprintf("%v", n.IsRegular)) builder.WriteString(", ") builder.WriteString("wu_xing=") builder.WriteString(n.WuXing) @@ -268,9 +265,6 @@ func (n *NCharacter) String() string { builder.WriteString("lucky=") builder.WriteString(n.Lucky) builder.WriteString(", ") - builder.WriteString("regular=") - builder.WriteString(fmt.Sprintf("%v", n.Regular)) - builder.WriteString(", ") builder.WriteString("comment=") builder.WriteString(n.Comment) builder.WriteByte(')') diff --git a/ent/ncharacter/ncharacter.go b/ent/ncharacter/ncharacter.go index de4c5c5..4dc592e 100644 --- a/ent/ncharacter/ncharacter.go +++ b/ent/ncharacter/ncharacter.go @@ -10,39 +10,37 @@ const ( // Label holds the string label denoting the ncharacter type in the database. Label = "ncharacter" // FieldID holds the string denoting the id field in the database. - FieldID = "hash" + FieldID = "id" // FieldPinYin holds the string denoting the pin_yin field in the database. FieldPinYin = "pin_yin" - // FieldChID holds the string denoting the ch_id field in the database. - FieldChID = "ch_id" // FieldCh holds the string denoting the ch field in the database. FieldCh = "ch" + // FieldChStroke holds the string denoting the ch_stroke field in the database. + FieldChStroke = "ch_stroke" + // FieldChType holds the string denoting the ch_type field in the database. + FieldChType = "ch_type" // FieldRadical holds the string denoting the radical field in the database. FieldRadical = "radical" // FieldRadicalStroke holds the string denoting the radical_stroke field in the database. FieldRadicalStroke = "radical_stroke" - // FieldTotalStroke holds the string denoting the total_stroke field in the database. - FieldTotalStroke = "total_stroke" - // FieldIsKangXi holds the string denoting the is_kang_xi field in the database. - FieldIsKangXi = "is_kang_xi" + // FieldRelate holds the string denoting the relate field in the database. + FieldRelate = "relate" // FieldRelateKangXi holds the string denoting the relate_kang_xi field in the database. FieldRelateKangXi = "relate_kang_xi" - // FieldRelateSimple holds the string denoting the relate_simple field in the database. - FieldRelateSimple = "relate_simple" // FieldRelateTraditional holds the string denoting the relate_traditional field in the database. FieldRelateTraditional = "relate_traditional" // FieldRelateVariant holds the string denoting the relate_variant field in the database. FieldRelateVariant = "relate_variant" - // FieldNameScience holds the string denoting the name_science field in the database. - FieldNameScience = "name_science" - // FieldScienceStroke holds the string denoting the science_stroke field in the database. - FieldScienceStroke = "science_stroke" + // FieldIsNameScience holds the string denoting the is_name_science field in the database. + FieldIsNameScience = "is_name_science" + // FieldNameScienceChStroke holds the string denoting the name_science_ch_stroke field in the database. + FieldNameScienceChStroke = "name_science_ch_stroke" + // FieldIsRegular holds the string denoting the is_regular field in the database. + FieldIsRegular = "is_regular" // FieldWuXing holds the string denoting the wu_xing field in the database. FieldWuXing = "wu_xing" // FieldLucky holds the string denoting the lucky field in the database. FieldLucky = "lucky" - // FieldRegular holds the string denoting the regular field in the database. - FieldRegular = "regular" // FieldComment holds the string denoting the comment field in the database. FieldComment = "comment" // Table holds the table name of the ncharacter in the database. @@ -53,21 +51,20 @@ const ( var Columns = []string{ FieldID, FieldPinYin, - FieldChID, FieldCh, + FieldChStroke, + FieldChType, FieldRadical, FieldRadicalStroke, - FieldTotalStroke, - FieldIsKangXi, + FieldRelate, FieldRelateKangXi, - FieldRelateSimple, FieldRelateTraditional, FieldRelateVariant, - FieldNameScience, - FieldScienceStroke, + FieldIsNameScience, + FieldNameScienceChStroke, + FieldIsRegular, FieldWuXing, FieldLucky, - FieldRegular, FieldComment, } @@ -81,6 +78,11 @@ func ValidColumn(column string) bool { return false } +var ( + // DefaultChType holds the default value on creation for the "ch_type" field. + DefaultChType int +) + // OrderOption defines the ordering options for the NCharacter queries. type OrderOption func(*sql.Selector) @@ -94,16 +96,21 @@ func ByPinYin(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldPinYin, opts...).ToFunc() } -// ByChID orders the results by the ch_id field. -func ByChID(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldChID, opts...).ToFunc() -} - // ByCh orders the results by the ch field. func ByCh(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldCh, opts...).ToFunc() } +// ByChStroke orders the results by the ch_stroke field. +func ByChStroke(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChStroke, opts...).ToFunc() +} + +// ByChType orders the results by the ch_type field. +func ByChType(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldChType, opts...).ToFunc() +} + // ByRadical orders the results by the radical field. func ByRadical(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldRadical, opts...).ToFunc() @@ -114,14 +121,9 @@ func ByRadicalStroke(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldRadicalStroke, opts...).ToFunc() } -// ByTotalStroke orders the results by the total_stroke field. -func ByTotalStroke(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldTotalStroke, opts...).ToFunc() -} - -// ByIsKangXi orders the results by the is_kang_xi field. -func ByIsKangXi(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldIsKangXi, opts...).ToFunc() +// ByRelate orders the results by the relate field. +func ByRelate(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldRelate, opts...).ToFunc() } // ByRelateKangXi orders the results by the relate_kang_xi field. @@ -129,29 +131,24 @@ func ByRelateKangXi(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldRelateKangXi, opts...).ToFunc() } -// ByRelateSimple orders the results by the relate_simple field. -func ByRelateSimple(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRelateSimple, opts...).ToFunc() -} - // ByRelateTraditional orders the results by the relate_traditional field. func ByRelateTraditional(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldRelateTraditional, opts...).ToFunc() } -// ByRelateVariant orders the results by the relate_variant field. -func ByRelateVariant(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRelateVariant, opts...).ToFunc() +// ByIsNameScience orders the results by the is_name_science field. +func ByIsNameScience(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsNameScience, opts...).ToFunc() } -// ByNameScience orders the results by the name_science field. -func ByNameScience(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldNameScience, opts...).ToFunc() +// ByNameScienceChStroke orders the results by the name_science_ch_stroke field. +func ByNameScienceChStroke(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldNameScienceChStroke, opts...).ToFunc() } -// ByScienceStroke orders the results by the science_stroke field. -func ByScienceStroke(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldScienceStroke, opts...).ToFunc() +// ByIsRegular orders the results by the is_regular field. +func ByIsRegular(opts ...sql.OrderTermOption) OrderOption { + return sql.OrderByField(FieldIsRegular, opts...).ToFunc() } // ByWuXing orders the results by the wu_xing field. @@ -164,11 +161,6 @@ func ByLucky(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldLucky, opts...).ToFunc() } -// ByRegular orders the results by the regular field. -func ByRegular(opts ...sql.OrderTermOption) OrderOption { - return sql.OrderByField(FieldRegular, opts...).ToFunc() -} - // ByComment orders the results by the comment field. func ByComment(opts ...sql.OrderTermOption) OrderOption { return sql.OrderByField(FieldComment, opts...).ToFunc() diff --git a/ent/ncharacter/where.go b/ent/ncharacter/where.go index 475ca6a..52e1dbd 100644 --- a/ent/ncharacter/where.go +++ b/ent/ncharacter/where.go @@ -8,75 +8,70 @@ import ( ) // ID filters vertices based on their ID field. -func ID(id string) predicate.NCharacter { +func ID(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. -func IDEQ(id string) predicate.NCharacter { +func IDEQ(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. -func IDNEQ(id string) predicate.NCharacter { +func IDNEQ(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. -func IDIn(ids ...string) predicate.NCharacter { +func IDIn(ids ...int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. -func IDNotIn(ids ...string) predicate.NCharacter { +func IDNotIn(ids ...int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. -func IDGT(id string) predicate.NCharacter { +func IDGT(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. -func IDGTE(id string) predicate.NCharacter { +func IDGTE(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. -func IDLT(id string) predicate.NCharacter { +func IDLT(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. -func IDLTE(id string) predicate.NCharacter { +func IDLTE(id int32) predicate.NCharacter { return predicate.NCharacter(sql.FieldLTE(FieldID, id)) } -// IDEqualFold applies the EqualFold predicate on the ID field. -func IDEqualFold(id string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEqualFold(FieldID, id)) -} - -// IDContainsFold applies the ContainsFold predicate on the ID field. -func IDContainsFold(id string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldContainsFold(FieldID, id)) -} - // PinYin applies equality check predicate on the "pin_yin" field. It's identical to PinYinEQ. func PinYin(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldPinYin, v)) } -// ChID applies equality check predicate on the "ch_id" field. It's identical to ChIDEQ. -func ChID(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldChID, v)) -} - // Ch applies equality check predicate on the "ch" field. It's identical to ChEQ. func Ch(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldCh, v)) } +// ChStroke applies equality check predicate on the "ch_stroke" field. It's identical to ChStrokeEQ. +func ChStroke(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldChStroke, v)) +} + +// ChType applies equality check predicate on the "ch_type" field. It's identical to ChTypeEQ. +func ChType(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldChType, v)) +} + // Radical applies equality check predicate on the "radical" field. It's identical to RadicalEQ. func Radical(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldRadical, v)) @@ -87,14 +82,9 @@ func RadicalStroke(v int) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldRadicalStroke, v)) } -// TotalStroke applies equality check predicate on the "total_stroke" field. It's identical to TotalStrokeEQ. -func TotalStroke(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldTotalStroke, v)) -} - -// IsKangXi applies equality check predicate on the "is_kang_xi" field. It's identical to IsKangXiEQ. -func IsKangXi(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldIsKangXi, v)) +// Relate applies equality check predicate on the "relate" field. It's identical to RelateEQ. +func Relate(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldRelate, v)) } // RelateKangXi applies equality check predicate on the "relate_kang_xi" field. It's identical to RelateKangXiEQ. @@ -102,29 +92,24 @@ func RelateKangXi(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldRelateKangXi, v)) } -// RelateSimple applies equality check predicate on the "relate_simple" field. It's identical to RelateSimpleEQ. -func RelateSimple(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldRelateSimple, v)) -} - // RelateTraditional applies equality check predicate on the "relate_traditional" field. It's identical to RelateTraditionalEQ. func RelateTraditional(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldRelateTraditional, v)) } -// RelateVariant applies equality check predicate on the "relate_variant" field. It's identical to RelateVariantEQ. -func RelateVariant(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldRelateVariant, v)) +// IsNameScience applies equality check predicate on the "is_name_science" field. It's identical to IsNameScienceEQ. +func IsNameScience(v bool) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldIsNameScience, v)) } -// NameScience applies equality check predicate on the "name_science" field. It's identical to NameScienceEQ. -func NameScience(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldNameScience, v)) +// NameScienceChStroke applies equality check predicate on the "name_science_ch_stroke" field. It's identical to NameScienceChStrokeEQ. +func NameScienceChStroke(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldNameScienceChStroke, v)) } -// ScienceStroke applies equality check predicate on the "science_stroke" field. It's identical to ScienceStrokeEQ. -func ScienceStroke(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldScienceStroke, v)) +// IsRegular applies equality check predicate on the "is_regular" field. It's identical to IsRegularEQ. +func IsRegular(v bool) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldIsRegular, v)) } // WuXing applies equality check predicate on the "wu_xing" field. It's identical to WuXingEQ. @@ -137,11 +122,6 @@ func Lucky(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldLucky, v)) } -// Regular applies equality check predicate on the "regular" field. It's identical to RegularEQ. -func Regular(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldRegular, v)) -} - // Comment applies equality check predicate on the "comment" field. It's identical to CommentEQ. func Comment(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldComment, v)) @@ -212,46 +192,6 @@ func PinYinContainsFold(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldContainsFold(FieldPinYin, v)) } -// ChIDEQ applies the EQ predicate on the "ch_id" field. -func ChIDEQ(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldChID, v)) -} - -// ChIDNEQ applies the NEQ predicate on the "ch_id" field. -func ChIDNEQ(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldChID, v)) -} - -// ChIDIn applies the In predicate on the "ch_id" field. -func ChIDIn(vs ...int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldIn(FieldChID, vs...)) -} - -// ChIDNotIn applies the NotIn predicate on the "ch_id" field. -func ChIDNotIn(vs ...int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNotIn(FieldChID, vs...)) -} - -// ChIDGT applies the GT predicate on the "ch_id" field. -func ChIDGT(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGT(FieldChID, v)) -} - -// ChIDGTE applies the GTE predicate on the "ch_id" field. -func ChIDGTE(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGTE(FieldChID, v)) -} - -// ChIDLT applies the LT predicate on the "ch_id" field. -func ChIDLT(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLT(FieldChID, v)) -} - -// ChIDLTE applies the LTE predicate on the "ch_id" field. -func ChIDLTE(v int64) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLTE(FieldChID, v)) -} - // ChEQ applies the EQ predicate on the "ch" field. func ChEQ(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldCh, v)) @@ -317,6 +257,86 @@ func ChContainsFold(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldContainsFold(FieldCh, v)) } +// ChStrokeEQ applies the EQ predicate on the "ch_stroke" field. +func ChStrokeEQ(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldChStroke, v)) +} + +// ChStrokeNEQ applies the NEQ predicate on the "ch_stroke" field. +func ChStrokeNEQ(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNEQ(FieldChStroke, v)) +} + +// ChStrokeIn applies the In predicate on the "ch_stroke" field. +func ChStrokeIn(vs ...int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldIn(FieldChStroke, vs...)) +} + +// ChStrokeNotIn applies the NotIn predicate on the "ch_stroke" field. +func ChStrokeNotIn(vs ...int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNotIn(FieldChStroke, vs...)) +} + +// ChStrokeGT applies the GT predicate on the "ch_stroke" field. +func ChStrokeGT(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGT(FieldChStroke, v)) +} + +// ChStrokeGTE applies the GTE predicate on the "ch_stroke" field. +func ChStrokeGTE(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGTE(FieldChStroke, v)) +} + +// ChStrokeLT applies the LT predicate on the "ch_stroke" field. +func ChStrokeLT(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLT(FieldChStroke, v)) +} + +// ChStrokeLTE applies the LTE predicate on the "ch_stroke" field. +func ChStrokeLTE(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLTE(FieldChStroke, v)) +} + +// ChTypeEQ applies the EQ predicate on the "ch_type" field. +func ChTypeEQ(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldChType, v)) +} + +// ChTypeNEQ applies the NEQ predicate on the "ch_type" field. +func ChTypeNEQ(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNEQ(FieldChType, v)) +} + +// ChTypeIn applies the In predicate on the "ch_type" field. +func ChTypeIn(vs ...int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldIn(FieldChType, vs...)) +} + +// ChTypeNotIn applies the NotIn predicate on the "ch_type" field. +func ChTypeNotIn(vs ...int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNotIn(FieldChType, vs...)) +} + +// ChTypeGT applies the GT predicate on the "ch_type" field. +func ChTypeGT(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGT(FieldChType, v)) +} + +// ChTypeGTE applies the GTE predicate on the "ch_type" field. +func ChTypeGTE(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGTE(FieldChType, v)) +} + +// ChTypeLT applies the LT predicate on the "ch_type" field. +func ChTypeLT(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLT(FieldChType, v)) +} + +// ChTypeLTE applies the LTE predicate on the "ch_type" field. +func ChTypeLTE(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLTE(FieldChType, v)) +} + // RadicalEQ applies the EQ predicate on the "radical" field. func RadicalEQ(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldRadical, v)) @@ -422,54 +442,69 @@ func RadicalStrokeLTE(v int) predicate.NCharacter { return predicate.NCharacter(sql.FieldLTE(FieldRadicalStroke, v)) } -// TotalStrokeEQ applies the EQ predicate on the "total_stroke" field. -func TotalStrokeEQ(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldTotalStroke, v)) +// RelateEQ applies the EQ predicate on the "relate" field. +func RelateEQ(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldRelate, v)) +} + +// RelateNEQ applies the NEQ predicate on the "relate" field. +func RelateNEQ(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNEQ(FieldRelate, v)) +} + +// RelateIn applies the In predicate on the "relate" field. +func RelateIn(vs ...string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldIn(FieldRelate, vs...)) +} + +// RelateNotIn applies the NotIn predicate on the "relate" field. +func RelateNotIn(vs ...string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNotIn(FieldRelate, vs...)) } -// TotalStrokeNEQ applies the NEQ predicate on the "total_stroke" field. -func TotalStrokeNEQ(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldTotalStroke, v)) +// RelateGT applies the GT predicate on the "relate" field. +func RelateGT(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGT(FieldRelate, v)) } -// TotalStrokeIn applies the In predicate on the "total_stroke" field. -func TotalStrokeIn(vs ...int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldIn(FieldTotalStroke, vs...)) +// RelateGTE applies the GTE predicate on the "relate" field. +func RelateGTE(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGTE(FieldRelate, v)) } -// TotalStrokeNotIn applies the NotIn predicate on the "total_stroke" field. -func TotalStrokeNotIn(vs ...int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNotIn(FieldTotalStroke, vs...)) +// RelateLT applies the LT predicate on the "relate" field. +func RelateLT(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLT(FieldRelate, v)) } -// TotalStrokeGT applies the GT predicate on the "total_stroke" field. -func TotalStrokeGT(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGT(FieldTotalStroke, v)) +// RelateLTE applies the LTE predicate on the "relate" field. +func RelateLTE(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLTE(FieldRelate, v)) } -// TotalStrokeGTE applies the GTE predicate on the "total_stroke" field. -func TotalStrokeGTE(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGTE(FieldTotalStroke, v)) +// RelateContains applies the Contains predicate on the "relate" field. +func RelateContains(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldContains(FieldRelate, v)) } -// TotalStrokeLT applies the LT predicate on the "total_stroke" field. -func TotalStrokeLT(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLT(FieldTotalStroke, v)) +// RelateHasPrefix applies the HasPrefix predicate on the "relate" field. +func RelateHasPrefix(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldHasPrefix(FieldRelate, v)) } -// TotalStrokeLTE applies the LTE predicate on the "total_stroke" field. -func TotalStrokeLTE(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLTE(FieldTotalStroke, v)) +// RelateHasSuffix applies the HasSuffix predicate on the "relate" field. +func RelateHasSuffix(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldHasSuffix(FieldRelate, v)) } -// IsKangXiEQ applies the EQ predicate on the "is_kang_xi" field. -func IsKangXiEQ(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldIsKangXi, v)) +// RelateEqualFold applies the EqualFold predicate on the "relate" field. +func RelateEqualFold(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEqualFold(FieldRelate, v)) } -// IsKangXiNEQ applies the NEQ predicate on the "is_kang_xi" field. -func IsKangXiNEQ(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldIsKangXi, v)) +// RelateContainsFold applies the ContainsFold predicate on the "relate" field. +func RelateContainsFold(v string) predicate.NCharacter { + return predicate.NCharacter(sql.FieldContainsFold(FieldRelate, v)) } // RelateKangXiEQ applies the EQ predicate on the "relate_kang_xi" field. @@ -537,71 +572,6 @@ func RelateKangXiContainsFold(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldContainsFold(FieldRelateKangXi, v)) } -// RelateSimpleEQ applies the EQ predicate on the "relate_simple" field. -func RelateSimpleEQ(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldRelateSimple, v)) -} - -// RelateSimpleNEQ applies the NEQ predicate on the "relate_simple" field. -func RelateSimpleNEQ(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldRelateSimple, v)) -} - -// RelateSimpleIn applies the In predicate on the "relate_simple" field. -func RelateSimpleIn(vs ...string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldIn(FieldRelateSimple, vs...)) -} - -// RelateSimpleNotIn applies the NotIn predicate on the "relate_simple" field. -func RelateSimpleNotIn(vs ...string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNotIn(FieldRelateSimple, vs...)) -} - -// RelateSimpleGT applies the GT predicate on the "relate_simple" field. -func RelateSimpleGT(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGT(FieldRelateSimple, v)) -} - -// RelateSimpleGTE applies the GTE predicate on the "relate_simple" field. -func RelateSimpleGTE(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGTE(FieldRelateSimple, v)) -} - -// RelateSimpleLT applies the LT predicate on the "relate_simple" field. -func RelateSimpleLT(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLT(FieldRelateSimple, v)) -} - -// RelateSimpleLTE applies the LTE predicate on the "relate_simple" field. -func RelateSimpleLTE(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLTE(FieldRelateSimple, v)) -} - -// RelateSimpleContains applies the Contains predicate on the "relate_simple" field. -func RelateSimpleContains(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldContains(FieldRelateSimple, v)) -} - -// RelateSimpleHasPrefix applies the HasPrefix predicate on the "relate_simple" field. -func RelateSimpleHasPrefix(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldHasPrefix(FieldRelateSimple, v)) -} - -// RelateSimpleHasSuffix applies the HasSuffix predicate on the "relate_simple" field. -func RelateSimpleHasSuffix(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldHasSuffix(FieldRelateSimple, v)) -} - -// RelateSimpleEqualFold applies the EqualFold predicate on the "relate_simple" field. -func RelateSimpleEqualFold(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEqualFold(FieldRelateSimple, v)) -} - -// RelateSimpleContainsFold applies the ContainsFold predicate on the "relate_simple" field. -func RelateSimpleContainsFold(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldContainsFold(FieldRelateSimple, v)) -} - // RelateTraditionalEQ applies the EQ predicate on the "relate_traditional" field. func RelateTraditionalEQ(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldRelateTraditional, v)) @@ -667,119 +637,64 @@ func RelateTraditionalContainsFold(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldContainsFold(FieldRelateTraditional, v)) } -// RelateVariantEQ applies the EQ predicate on the "relate_variant" field. -func RelateVariantEQ(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldRelateVariant, v)) -} - -// RelateVariantNEQ applies the NEQ predicate on the "relate_variant" field. -func RelateVariantNEQ(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldRelateVariant, v)) -} - -// RelateVariantIn applies the In predicate on the "relate_variant" field. -func RelateVariantIn(vs ...string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldIn(FieldRelateVariant, vs...)) -} - -// RelateVariantNotIn applies the NotIn predicate on the "relate_variant" field. -func RelateVariantNotIn(vs ...string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNotIn(FieldRelateVariant, vs...)) -} - -// RelateVariantGT applies the GT predicate on the "relate_variant" field. -func RelateVariantGT(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGT(FieldRelateVariant, v)) -} - -// RelateVariantGTE applies the GTE predicate on the "relate_variant" field. -func RelateVariantGTE(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGTE(FieldRelateVariant, v)) -} - -// RelateVariantLT applies the LT predicate on the "relate_variant" field. -func RelateVariantLT(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLT(FieldRelateVariant, v)) -} - -// RelateVariantLTE applies the LTE predicate on the "relate_variant" field. -func RelateVariantLTE(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLTE(FieldRelateVariant, v)) -} - -// RelateVariantContains applies the Contains predicate on the "relate_variant" field. -func RelateVariantContains(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldContains(FieldRelateVariant, v)) -} - -// RelateVariantHasPrefix applies the HasPrefix predicate on the "relate_variant" field. -func RelateVariantHasPrefix(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldHasPrefix(FieldRelateVariant, v)) +// IsNameScienceEQ applies the EQ predicate on the "is_name_science" field. +func IsNameScienceEQ(v bool) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldIsNameScience, v)) } -// RelateVariantHasSuffix applies the HasSuffix predicate on the "relate_variant" field. -func RelateVariantHasSuffix(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldHasSuffix(FieldRelateVariant, v)) +// IsNameScienceNEQ applies the NEQ predicate on the "is_name_science" field. +func IsNameScienceNEQ(v bool) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNEQ(FieldIsNameScience, v)) } -// RelateVariantEqualFold applies the EqualFold predicate on the "relate_variant" field. -func RelateVariantEqualFold(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEqualFold(FieldRelateVariant, v)) +// NameScienceChStrokeEQ applies the EQ predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeEQ(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldNameScienceChStroke, v)) } -// RelateVariantContainsFold applies the ContainsFold predicate on the "relate_variant" field. -func RelateVariantContainsFold(v string) predicate.NCharacter { - return predicate.NCharacter(sql.FieldContainsFold(FieldRelateVariant, v)) +// NameScienceChStrokeNEQ applies the NEQ predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeNEQ(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNEQ(FieldNameScienceChStroke, v)) } -// NameScienceEQ applies the EQ predicate on the "name_science" field. -func NameScienceEQ(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldNameScience, v)) +// NameScienceChStrokeIn applies the In predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeIn(vs ...int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldIn(FieldNameScienceChStroke, vs...)) } -// NameScienceNEQ applies the NEQ predicate on the "name_science" field. -func NameScienceNEQ(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldNameScience, v)) +// NameScienceChStrokeNotIn applies the NotIn predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeNotIn(vs ...int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNotIn(FieldNameScienceChStroke, vs...)) } -// ScienceStrokeEQ applies the EQ predicate on the "science_stroke" field. -func ScienceStrokeEQ(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldScienceStroke, v)) +// NameScienceChStrokeGT applies the GT predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeGT(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGT(FieldNameScienceChStroke, v)) } -// ScienceStrokeNEQ applies the NEQ predicate on the "science_stroke" field. -func ScienceStrokeNEQ(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldScienceStroke, v)) +// NameScienceChStrokeGTE applies the GTE predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeGTE(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldGTE(FieldNameScienceChStroke, v)) } -// ScienceStrokeIn applies the In predicate on the "science_stroke" field. -func ScienceStrokeIn(vs ...int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldIn(FieldScienceStroke, vs...)) +// NameScienceChStrokeLT applies the LT predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeLT(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLT(FieldNameScienceChStroke, v)) } -// ScienceStrokeNotIn applies the NotIn predicate on the "science_stroke" field. -func ScienceStrokeNotIn(vs ...int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNotIn(FieldScienceStroke, vs...)) +// NameScienceChStrokeLTE applies the LTE predicate on the "name_science_ch_stroke" field. +func NameScienceChStrokeLTE(v int) predicate.NCharacter { + return predicate.NCharacter(sql.FieldLTE(FieldNameScienceChStroke, v)) } -// ScienceStrokeGT applies the GT predicate on the "science_stroke" field. -func ScienceStrokeGT(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGT(FieldScienceStroke, v)) +// IsRegularEQ applies the EQ predicate on the "is_regular" field. +func IsRegularEQ(v bool) predicate.NCharacter { + return predicate.NCharacter(sql.FieldEQ(FieldIsRegular, v)) } -// ScienceStrokeGTE applies the GTE predicate on the "science_stroke" field. -func ScienceStrokeGTE(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldGTE(FieldScienceStroke, v)) -} - -// ScienceStrokeLT applies the LT predicate on the "science_stroke" field. -func ScienceStrokeLT(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLT(FieldScienceStroke, v)) -} - -// ScienceStrokeLTE applies the LTE predicate on the "science_stroke" field. -func ScienceStrokeLTE(v int) predicate.NCharacter { - return predicate.NCharacter(sql.FieldLTE(FieldScienceStroke, v)) +// IsRegularNEQ applies the NEQ predicate on the "is_regular" field. +func IsRegularNEQ(v bool) predicate.NCharacter { + return predicate.NCharacter(sql.FieldNEQ(FieldIsRegular, v)) } // WuXingEQ applies the EQ predicate on the "wu_xing" field. @@ -912,16 +827,6 @@ func LuckyContainsFold(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldContainsFold(FieldLucky, v)) } -// RegularEQ applies the EQ predicate on the "regular" field. -func RegularEQ(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldEQ(FieldRegular, v)) -} - -// RegularNEQ applies the NEQ predicate on the "regular" field. -func RegularNEQ(v bool) predicate.NCharacter { - return predicate.NCharacter(sql.FieldNEQ(FieldRegular, v)) -} - // CommentEQ applies the EQ predicate on the "comment" field. func CommentEQ(v string) predicate.NCharacter { return predicate.NCharacter(sql.FieldEQ(FieldComment, v)) diff --git a/ent/ncharacter_create.go b/ent/ncharacter_create.go index 99b6f31..3e9a2ae 100644 --- a/ent/ncharacter_create.go +++ b/ent/ncharacter_create.go @@ -7,7 +7,6 @@ import ( "errors" "fmt" - "entgo.io/ent/dialect" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -28,18 +27,32 @@ func (nc *NCharacterCreate) SetPinYin(s string) *NCharacterCreate { return nc } -// SetChID sets the "ch_id" field. -func (nc *NCharacterCreate) SetChID(i int64) *NCharacterCreate { - nc.mutation.SetChID(i) - return nc -} - // SetCh sets the "ch" field. func (nc *NCharacterCreate) SetCh(s string) *NCharacterCreate { nc.mutation.SetCh(s) return nc } +// SetChStroke sets the "ch_stroke" field. +func (nc *NCharacterCreate) SetChStroke(i int) *NCharacterCreate { + nc.mutation.SetChStroke(i) + return nc +} + +// SetChType sets the "ch_type" field. +func (nc *NCharacterCreate) SetChType(i int) *NCharacterCreate { + nc.mutation.SetChType(i) + return nc +} + +// SetNillableChType sets the "ch_type" field if the given value is not nil. +func (nc *NCharacterCreate) SetNillableChType(i *int) *NCharacterCreate { + if i != nil { + nc.SetChType(*i) + } + return nc +} + // SetRadical sets the "radical" field. func (nc *NCharacterCreate) SetRadical(s string) *NCharacterCreate { nc.mutation.SetRadical(s) @@ -52,15 +65,9 @@ func (nc *NCharacterCreate) SetRadicalStroke(i int) *NCharacterCreate { return nc } -// SetTotalStroke sets the "total_stroke" field. -func (nc *NCharacterCreate) SetTotalStroke(i int) *NCharacterCreate { - nc.mutation.SetTotalStroke(i) - return nc -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (nc *NCharacterCreate) SetIsKangXi(b bool) *NCharacterCreate { - nc.mutation.SetIsKangXi(b) +// SetRelate sets the "relate" field. +func (nc *NCharacterCreate) SetRelate(s string) *NCharacterCreate { + nc.mutation.SetRelate(s) return nc } @@ -70,12 +77,6 @@ func (nc *NCharacterCreate) SetRelateKangXi(s string) *NCharacterCreate { return nc } -// SetRelateSimple sets the "relate_simple" field. -func (nc *NCharacterCreate) SetRelateSimple(s string) *NCharacterCreate { - nc.mutation.SetRelateSimple(s) - return nc -} - // SetRelateTraditional sets the "relate_traditional" field. func (nc *NCharacterCreate) SetRelateTraditional(s string) *NCharacterCreate { nc.mutation.SetRelateTraditional(s) @@ -83,20 +84,26 @@ func (nc *NCharacterCreate) SetRelateTraditional(s string) *NCharacterCreate { } // SetRelateVariant sets the "relate_variant" field. -func (nc *NCharacterCreate) SetRelateVariant(s string) *NCharacterCreate { +func (nc *NCharacterCreate) SetRelateVariant(s []string) *NCharacterCreate { nc.mutation.SetRelateVariant(s) return nc } -// SetNameScience sets the "name_science" field. -func (nc *NCharacterCreate) SetNameScience(b bool) *NCharacterCreate { - nc.mutation.SetNameScience(b) +// SetIsNameScience sets the "is_name_science" field. +func (nc *NCharacterCreate) SetIsNameScience(b bool) *NCharacterCreate { + nc.mutation.SetIsNameScience(b) return nc } -// SetScienceStroke sets the "science_stroke" field. -func (nc *NCharacterCreate) SetScienceStroke(i int) *NCharacterCreate { - nc.mutation.SetScienceStroke(i) +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (nc *NCharacterCreate) SetNameScienceChStroke(i int) *NCharacterCreate { + nc.mutation.SetNameScienceChStroke(i) + return nc +} + +// SetIsRegular sets the "is_regular" field. +func (nc *NCharacterCreate) SetIsRegular(b bool) *NCharacterCreate { + nc.mutation.SetIsRegular(b) return nc } @@ -112,12 +119,6 @@ func (nc *NCharacterCreate) SetLucky(s string) *NCharacterCreate { return nc } -// SetRegular sets the "regular" field. -func (nc *NCharacterCreate) SetRegular(b bool) *NCharacterCreate { - nc.mutation.SetRegular(b) - return nc -} - // SetComment sets the "comment" field. func (nc *NCharacterCreate) SetComment(s string) *NCharacterCreate { nc.mutation.SetComment(s) @@ -125,8 +126,8 @@ func (nc *NCharacterCreate) SetComment(s string) *NCharacterCreate { } // SetID sets the "id" field. -func (nc *NCharacterCreate) SetID(s string) *NCharacterCreate { - nc.mutation.SetID(s) +func (nc *NCharacterCreate) SetID(i int32) *NCharacterCreate { + nc.mutation.SetID(i) return nc } @@ -137,6 +138,7 @@ func (nc *NCharacterCreate) Mutation() *NCharacterMutation { // Save creates the NCharacter in the database. func (nc *NCharacterCreate) Save(ctx context.Context) (*NCharacter, error) { + nc.defaults() return withHooks(ctx, nc.sqlSave, nc.mutation, nc.hooks) } @@ -162,46 +164,54 @@ func (nc *NCharacterCreate) ExecX(ctx context.Context) { } } +// defaults sets the default values of the builder before save. +func (nc *NCharacterCreate) defaults() { + if _, ok := nc.mutation.ChType(); !ok { + v := ncharacter.DefaultChType + nc.mutation.SetChType(v) + } +} + // check runs all checks and user-defined validators on the builder. func (nc *NCharacterCreate) check() error { if _, ok := nc.mutation.PinYin(); !ok { return &ValidationError{Name: "pin_yin", err: errors.New(`ent: missing required field "NCharacter.pin_yin"`)} } - if _, ok := nc.mutation.ChID(); !ok { - return &ValidationError{Name: "ch_id", err: errors.New(`ent: missing required field "NCharacter.ch_id"`)} - } if _, ok := nc.mutation.Ch(); !ok { return &ValidationError{Name: "ch", err: errors.New(`ent: missing required field "NCharacter.ch"`)} } + if _, ok := nc.mutation.ChStroke(); !ok { + return &ValidationError{Name: "ch_stroke", err: errors.New(`ent: missing required field "NCharacter.ch_stroke"`)} + } + if _, ok := nc.mutation.ChType(); !ok { + return &ValidationError{Name: "ch_type", err: errors.New(`ent: missing required field "NCharacter.ch_type"`)} + } if _, ok := nc.mutation.Radical(); !ok { return &ValidationError{Name: "radical", err: errors.New(`ent: missing required field "NCharacter.radical"`)} } if _, ok := nc.mutation.RadicalStroke(); !ok { return &ValidationError{Name: "radical_stroke", err: errors.New(`ent: missing required field "NCharacter.radical_stroke"`)} } - if _, ok := nc.mutation.TotalStroke(); !ok { - return &ValidationError{Name: "total_stroke", err: errors.New(`ent: missing required field "NCharacter.total_stroke"`)} - } - if _, ok := nc.mutation.IsKangXi(); !ok { - return &ValidationError{Name: "is_kang_xi", err: errors.New(`ent: missing required field "NCharacter.is_kang_xi"`)} + if _, ok := nc.mutation.Relate(); !ok { + return &ValidationError{Name: "relate", err: errors.New(`ent: missing required field "NCharacter.relate"`)} } if _, ok := nc.mutation.RelateKangXi(); !ok { return &ValidationError{Name: "relate_kang_xi", err: errors.New(`ent: missing required field "NCharacter.relate_kang_xi"`)} } - if _, ok := nc.mutation.RelateSimple(); !ok { - return &ValidationError{Name: "relate_simple", err: errors.New(`ent: missing required field "NCharacter.relate_simple"`)} - } if _, ok := nc.mutation.RelateTraditional(); !ok { return &ValidationError{Name: "relate_traditional", err: errors.New(`ent: missing required field "NCharacter.relate_traditional"`)} } if _, ok := nc.mutation.RelateVariant(); !ok { return &ValidationError{Name: "relate_variant", err: errors.New(`ent: missing required field "NCharacter.relate_variant"`)} } - if _, ok := nc.mutation.NameScience(); !ok { - return &ValidationError{Name: "name_science", err: errors.New(`ent: missing required field "NCharacter.name_science"`)} + if _, ok := nc.mutation.IsNameScience(); !ok { + return &ValidationError{Name: "is_name_science", err: errors.New(`ent: missing required field "NCharacter.is_name_science"`)} + } + if _, ok := nc.mutation.NameScienceChStroke(); !ok { + return &ValidationError{Name: "name_science_ch_stroke", err: errors.New(`ent: missing required field "NCharacter.name_science_ch_stroke"`)} } - if _, ok := nc.mutation.ScienceStroke(); !ok { - return &ValidationError{Name: "science_stroke", err: errors.New(`ent: missing required field "NCharacter.science_stroke"`)} + if _, ok := nc.mutation.IsRegular(); !ok { + return &ValidationError{Name: "is_regular", err: errors.New(`ent: missing required field "NCharacter.is_regular"`)} } if _, ok := nc.mutation.WuXing(); !ok { return &ValidationError{Name: "wu_xing", err: errors.New(`ent: missing required field "NCharacter.wu_xing"`)} @@ -209,9 +219,6 @@ func (nc *NCharacterCreate) check() error { if _, ok := nc.mutation.Lucky(); !ok { return &ValidationError{Name: "lucky", err: errors.New(`ent: missing required field "NCharacter.lucky"`)} } - if _, ok := nc.mutation.Regular(); !ok { - return &ValidationError{Name: "regular", err: errors.New(`ent: missing required field "NCharacter.regular"`)} - } if _, ok := nc.mutation.Comment(); !ok { return &ValidationError{Name: "comment", err: errors.New(`ent: missing required field "NCharacter.comment"`)} } @@ -229,12 +236,9 @@ func (nc *NCharacterCreate) sqlSave(ctx context.Context) (*NCharacter, error) { } return nil, err } - if _spec.ID.Value != nil { - if id, ok := _spec.ID.Value.(string); ok { - _node.ID = id - } else { - return nil, fmt.Errorf("unexpected NCharacter.ID type: %T", _spec.ID.Value) - } + if _spec.ID.Value != _node.ID { + id := _spec.ID.Value.(int64) + _node.ID = int32(id) } nc.mutation.id = &_node.ID nc.mutation.done = true @@ -244,7 +248,7 @@ func (nc *NCharacterCreate) sqlSave(ctx context.Context) (*NCharacter, error) { func (nc *NCharacterCreate) createSpec() (*NCharacter, *sqlgraph.CreateSpec) { var ( _node = &NCharacter{config: nc.config} - _spec = sqlgraph.NewCreateSpec(ncharacter.Table, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeString)) + _spec = sqlgraph.NewCreateSpec(ncharacter.Table, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeInt32)) ) _spec.OnConflict = nc.conflict if id, ok := nc.mutation.ID(); ok { @@ -255,14 +259,18 @@ func (nc *NCharacterCreate) createSpec() (*NCharacter, *sqlgraph.CreateSpec) { _spec.SetField(ncharacter.FieldPinYin, field.TypeString, value) _node.PinYin = value } - if value, ok := nc.mutation.ChID(); ok { - _spec.SetField(ncharacter.FieldChID, field.TypeInt64, value) - _node.ChID = value - } if value, ok := nc.mutation.Ch(); ok { _spec.SetField(ncharacter.FieldCh, field.TypeString, value) _node.Ch = value } + if value, ok := nc.mutation.ChStroke(); ok { + _spec.SetField(ncharacter.FieldChStroke, field.TypeInt, value) + _node.ChStroke = value + } + if value, ok := nc.mutation.ChType(); ok { + _spec.SetField(ncharacter.FieldChType, field.TypeInt, value) + _node.ChType = value + } if value, ok := nc.mutation.Radical(); ok { _spec.SetField(ncharacter.FieldRadical, field.TypeString, value) _node.Radical = value @@ -271,37 +279,33 @@ func (nc *NCharacterCreate) createSpec() (*NCharacter, *sqlgraph.CreateSpec) { _spec.SetField(ncharacter.FieldRadicalStroke, field.TypeInt, value) _node.RadicalStroke = value } - if value, ok := nc.mutation.TotalStroke(); ok { - _spec.SetField(ncharacter.FieldTotalStroke, field.TypeInt, value) - _node.TotalStroke = value - } - if value, ok := nc.mutation.IsKangXi(); ok { - _spec.SetField(ncharacter.FieldIsKangXi, field.TypeBool, value) - _node.IsKangXi = value + if value, ok := nc.mutation.Relate(); ok { + _spec.SetField(ncharacter.FieldRelate, field.TypeString, value) + _node.Relate = value } if value, ok := nc.mutation.RelateKangXi(); ok { _spec.SetField(ncharacter.FieldRelateKangXi, field.TypeString, value) _node.RelateKangXi = value } - if value, ok := nc.mutation.RelateSimple(); ok { - _spec.SetField(ncharacter.FieldRelateSimple, field.TypeString, value) - _node.RelateSimple = value - } if value, ok := nc.mutation.RelateTraditional(); ok { _spec.SetField(ncharacter.FieldRelateTraditional, field.TypeString, value) _node.RelateTraditional = value } if value, ok := nc.mutation.RelateVariant(); ok { - _spec.SetField(ncharacter.FieldRelateVariant, field.TypeString, value) + _spec.SetField(ncharacter.FieldRelateVariant, field.TypeJSON, value) _node.RelateVariant = value } - if value, ok := nc.mutation.NameScience(); ok { - _spec.SetField(ncharacter.FieldNameScience, field.TypeBool, value) - _node.NameScience = value + if value, ok := nc.mutation.IsNameScience(); ok { + _spec.SetField(ncharacter.FieldIsNameScience, field.TypeBool, value) + _node.IsNameScience = value } - if value, ok := nc.mutation.ScienceStroke(); ok { - _spec.SetField(ncharacter.FieldScienceStroke, field.TypeInt, value) - _node.ScienceStroke = value + if value, ok := nc.mutation.NameScienceChStroke(); ok { + _spec.SetField(ncharacter.FieldNameScienceChStroke, field.TypeInt, value) + _node.NameScienceChStroke = value + } + if value, ok := nc.mutation.IsRegular(); ok { + _spec.SetField(ncharacter.FieldIsRegular, field.TypeBool, value) + _node.IsRegular = value } if value, ok := nc.mutation.WuXing(); ok { _spec.SetField(ncharacter.FieldWuXing, field.TypeString, value) @@ -311,10 +315,6 @@ func (nc *NCharacterCreate) createSpec() (*NCharacter, *sqlgraph.CreateSpec) { _spec.SetField(ncharacter.FieldLucky, field.TypeString, value) _node.Lucky = value } - if value, ok := nc.mutation.Regular(); ok { - _spec.SetField(ncharacter.FieldRegular, field.TypeBool, value) - _node.Regular = value - } if value, ok := nc.mutation.Comment(); ok { _spec.SetField(ncharacter.FieldComment, field.TypeString, value) _node.Comment = value @@ -383,33 +383,51 @@ func (u *NCharacterUpsert) UpdatePinYin() *NCharacterUpsert { return u } -// SetChID sets the "ch_id" field. -func (u *NCharacterUpsert) SetChID(v int64) *NCharacterUpsert { - u.Set(ncharacter.FieldChID, v) +// SetCh sets the "ch" field. +func (u *NCharacterUpsert) SetCh(v string) *NCharacterUpsert { + u.Set(ncharacter.FieldCh, v) return u } -// UpdateChID sets the "ch_id" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateChID() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldChID) +// UpdateCh sets the "ch" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateCh() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldCh) return u } -// AddChID adds v to the "ch_id" field. -func (u *NCharacterUpsert) AddChID(v int64) *NCharacterUpsert { - u.Add(ncharacter.FieldChID, v) +// SetChStroke sets the "ch_stroke" field. +func (u *NCharacterUpsert) SetChStroke(v int) *NCharacterUpsert { + u.Set(ncharacter.FieldChStroke, v) return u } -// SetCh sets the "ch" field. -func (u *NCharacterUpsert) SetCh(v string) *NCharacterUpsert { - u.Set(ncharacter.FieldCh, v) +// UpdateChStroke sets the "ch_stroke" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateChStroke() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldChStroke) return u } -// UpdateCh sets the "ch" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateCh() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldCh) +// AddChStroke adds v to the "ch_stroke" field. +func (u *NCharacterUpsert) AddChStroke(v int) *NCharacterUpsert { + u.Add(ncharacter.FieldChStroke, v) + return u +} + +// SetChType sets the "ch_type" field. +func (u *NCharacterUpsert) SetChType(v int) *NCharacterUpsert { + u.Set(ncharacter.FieldChType, v) + return u +} + +// UpdateChType sets the "ch_type" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateChType() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldChType) + return u +} + +// AddChType adds v to the "ch_type" field. +func (u *NCharacterUpsert) AddChType(v int) *NCharacterUpsert { + u.Add(ncharacter.FieldChType, v) return u } @@ -443,33 +461,15 @@ func (u *NCharacterUpsert) AddRadicalStroke(v int) *NCharacterUpsert { return u } -// SetTotalStroke sets the "total_stroke" field. -func (u *NCharacterUpsert) SetTotalStroke(v int) *NCharacterUpsert { - u.Set(ncharacter.FieldTotalStroke, v) +// SetRelate sets the "relate" field. +func (u *NCharacterUpsert) SetRelate(v string) *NCharacterUpsert { + u.Set(ncharacter.FieldRelate, v) return u } -// UpdateTotalStroke sets the "total_stroke" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateTotalStroke() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldTotalStroke) - return u -} - -// AddTotalStroke adds v to the "total_stroke" field. -func (u *NCharacterUpsert) AddTotalStroke(v int) *NCharacterUpsert { - u.Add(ncharacter.FieldTotalStroke, v) - return u -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (u *NCharacterUpsert) SetIsKangXi(v bool) *NCharacterUpsert { - u.Set(ncharacter.FieldIsKangXi, v) - return u -} - -// UpdateIsKangXi sets the "is_kang_xi" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateIsKangXi() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldIsKangXi) +// UpdateRelate sets the "relate" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateRelate() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldRelate) return u } @@ -485,18 +485,6 @@ func (u *NCharacterUpsert) UpdateRelateKangXi() *NCharacterUpsert { return u } -// SetRelateSimple sets the "relate_simple" field. -func (u *NCharacterUpsert) SetRelateSimple(v string) *NCharacterUpsert { - u.Set(ncharacter.FieldRelateSimple, v) - return u -} - -// UpdateRelateSimple sets the "relate_simple" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateRelateSimple() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldRelateSimple) - return u -} - // SetRelateTraditional sets the "relate_traditional" field. func (u *NCharacterUpsert) SetRelateTraditional(v string) *NCharacterUpsert { u.Set(ncharacter.FieldRelateTraditional, v) @@ -510,7 +498,7 @@ func (u *NCharacterUpsert) UpdateRelateTraditional() *NCharacterUpsert { } // SetRelateVariant sets the "relate_variant" field. -func (u *NCharacterUpsert) SetRelateVariant(v string) *NCharacterUpsert { +func (u *NCharacterUpsert) SetRelateVariant(v []string) *NCharacterUpsert { u.Set(ncharacter.FieldRelateVariant, v) return u } @@ -521,33 +509,45 @@ func (u *NCharacterUpsert) UpdateRelateVariant() *NCharacterUpsert { return u } -// SetNameScience sets the "name_science" field. -func (u *NCharacterUpsert) SetNameScience(v bool) *NCharacterUpsert { - u.Set(ncharacter.FieldNameScience, v) +// SetIsNameScience sets the "is_name_science" field. +func (u *NCharacterUpsert) SetIsNameScience(v bool) *NCharacterUpsert { + u.Set(ncharacter.FieldIsNameScience, v) return u } -// UpdateNameScience sets the "name_science" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateNameScience() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldNameScience) +// UpdateIsNameScience sets the "is_name_science" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateIsNameScience() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldIsNameScience) return u } -// SetScienceStroke sets the "science_stroke" field. -func (u *NCharacterUpsert) SetScienceStroke(v int) *NCharacterUpsert { - u.Set(ncharacter.FieldScienceStroke, v) +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (u *NCharacterUpsert) SetNameScienceChStroke(v int) *NCharacterUpsert { + u.Set(ncharacter.FieldNameScienceChStroke, v) return u } -// UpdateScienceStroke sets the "science_stroke" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateScienceStroke() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldScienceStroke) +// UpdateNameScienceChStroke sets the "name_science_ch_stroke" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateNameScienceChStroke() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldNameScienceChStroke) return u } -// AddScienceStroke adds v to the "science_stroke" field. -func (u *NCharacterUpsert) AddScienceStroke(v int) *NCharacterUpsert { - u.Add(ncharacter.FieldScienceStroke, v) +// AddNameScienceChStroke adds v to the "name_science_ch_stroke" field. +func (u *NCharacterUpsert) AddNameScienceChStroke(v int) *NCharacterUpsert { + u.Add(ncharacter.FieldNameScienceChStroke, v) + return u +} + +// SetIsRegular sets the "is_regular" field. +func (u *NCharacterUpsert) SetIsRegular(v bool) *NCharacterUpsert { + u.Set(ncharacter.FieldIsRegular, v) + return u +} + +// UpdateIsRegular sets the "is_regular" field to the value that was provided on create. +func (u *NCharacterUpsert) UpdateIsRegular() *NCharacterUpsert { + u.SetExcluded(ncharacter.FieldIsRegular) return u } @@ -575,18 +575,6 @@ func (u *NCharacterUpsert) UpdateLucky() *NCharacterUpsert { return u } -// SetRegular sets the "regular" field. -func (u *NCharacterUpsert) SetRegular(v bool) *NCharacterUpsert { - u.Set(ncharacter.FieldRegular, v) - return u -} - -// UpdateRegular sets the "regular" field to the value that was provided on create. -func (u *NCharacterUpsert) UpdateRegular() *NCharacterUpsert { - u.SetExcluded(ncharacter.FieldRegular) - return u -} - // SetComment sets the "comment" field. func (u *NCharacterUpsert) SetComment(v string) *NCharacterUpsert { u.Set(ncharacter.FieldComment, v) @@ -661,38 +649,59 @@ func (u *NCharacterUpsertOne) UpdatePinYin() *NCharacterUpsertOne { }) } -// SetChID sets the "ch_id" field. -func (u *NCharacterUpsertOne) SetChID(v int64) *NCharacterUpsertOne { +// SetCh sets the "ch" field. +func (u *NCharacterUpsertOne) SetCh(v string) *NCharacterUpsertOne { + return u.Update(func(s *NCharacterUpsert) { + s.SetCh(v) + }) +} + +// UpdateCh sets the "ch" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateCh() *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.SetChID(v) + s.UpdateCh() }) } -// AddChID adds v to the "ch_id" field. -func (u *NCharacterUpsertOne) AddChID(v int64) *NCharacterUpsertOne { +// SetChStroke sets the "ch_stroke" field. +func (u *NCharacterUpsertOne) SetChStroke(v int) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.AddChID(v) + s.SetChStroke(v) }) } -// UpdateChID sets the "ch_id" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateChID() *NCharacterUpsertOne { +// AddChStroke adds v to the "ch_stroke" field. +func (u *NCharacterUpsertOne) AddChStroke(v int) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.UpdateChID() + s.AddChStroke(v) }) } -// SetCh sets the "ch" field. -func (u *NCharacterUpsertOne) SetCh(v string) *NCharacterUpsertOne { +// UpdateChStroke sets the "ch_stroke" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateChStroke() *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.SetCh(v) + s.UpdateChStroke() }) } -// UpdateCh sets the "ch" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateCh() *NCharacterUpsertOne { +// SetChType sets the "ch_type" field. +func (u *NCharacterUpsertOne) SetChType(v int) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.UpdateCh() + s.SetChType(v) + }) +} + +// AddChType adds v to the "ch_type" field. +func (u *NCharacterUpsertOne) AddChType(v int) *NCharacterUpsertOne { + return u.Update(func(s *NCharacterUpsert) { + s.AddChType(v) + }) +} + +// UpdateChType sets the "ch_type" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateChType() *NCharacterUpsertOne { + return u.Update(func(s *NCharacterUpsert) { + s.UpdateChType() }) } @@ -731,38 +740,17 @@ func (u *NCharacterUpsertOne) UpdateRadicalStroke() *NCharacterUpsertOne { }) } -// SetTotalStroke sets the "total_stroke" field. -func (u *NCharacterUpsertOne) SetTotalStroke(v int) *NCharacterUpsertOne { +// SetRelate sets the "relate" field. +func (u *NCharacterUpsertOne) SetRelate(v string) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.SetTotalStroke(v) + s.SetRelate(v) }) } -// AddTotalStroke adds v to the "total_stroke" field. -func (u *NCharacterUpsertOne) AddTotalStroke(v int) *NCharacterUpsertOne { +// UpdateRelate sets the "relate" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateRelate() *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.AddTotalStroke(v) - }) -} - -// UpdateTotalStroke sets the "total_stroke" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateTotalStroke() *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateTotalStroke() - }) -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (u *NCharacterUpsertOne) SetIsKangXi(v bool) *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.SetIsKangXi(v) - }) -} - -// UpdateIsKangXi sets the "is_kang_xi" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateIsKangXi() *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateIsKangXi() + s.UpdateRelate() }) } @@ -780,20 +768,6 @@ func (u *NCharacterUpsertOne) UpdateRelateKangXi() *NCharacterUpsertOne { }) } -// SetRelateSimple sets the "relate_simple" field. -func (u *NCharacterUpsertOne) SetRelateSimple(v string) *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.SetRelateSimple(v) - }) -} - -// UpdateRelateSimple sets the "relate_simple" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateRelateSimple() *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateRelateSimple() - }) -} - // SetRelateTraditional sets the "relate_traditional" field. func (u *NCharacterUpsertOne) SetRelateTraditional(v string) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { @@ -809,7 +783,7 @@ func (u *NCharacterUpsertOne) UpdateRelateTraditional() *NCharacterUpsertOne { } // SetRelateVariant sets the "relate_variant" field. -func (u *NCharacterUpsertOne) SetRelateVariant(v string) *NCharacterUpsertOne { +func (u *NCharacterUpsertOne) SetRelateVariant(v []string) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { s.SetRelateVariant(v) }) @@ -822,38 +796,52 @@ func (u *NCharacterUpsertOne) UpdateRelateVariant() *NCharacterUpsertOne { }) } -// SetNameScience sets the "name_science" field. -func (u *NCharacterUpsertOne) SetNameScience(v bool) *NCharacterUpsertOne { +// SetIsNameScience sets the "is_name_science" field. +func (u *NCharacterUpsertOne) SetIsNameScience(v bool) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.SetNameScience(v) + s.SetIsNameScience(v) }) } -// UpdateNameScience sets the "name_science" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateNameScience() *NCharacterUpsertOne { +// UpdateIsNameScience sets the "is_name_science" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateIsNameScience() *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.UpdateNameScience() + s.UpdateIsNameScience() }) } -// SetScienceStroke sets the "science_stroke" field. -func (u *NCharacterUpsertOne) SetScienceStroke(v int) *NCharacterUpsertOne { +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (u *NCharacterUpsertOne) SetNameScienceChStroke(v int) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.SetScienceStroke(v) + s.SetNameScienceChStroke(v) }) } -// AddScienceStroke adds v to the "science_stroke" field. -func (u *NCharacterUpsertOne) AddScienceStroke(v int) *NCharacterUpsertOne { +// AddNameScienceChStroke adds v to the "name_science_ch_stroke" field. +func (u *NCharacterUpsertOne) AddNameScienceChStroke(v int) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.AddScienceStroke(v) + s.AddNameScienceChStroke(v) }) } -// UpdateScienceStroke sets the "science_stroke" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateScienceStroke() *NCharacterUpsertOne { +// UpdateNameScienceChStroke sets the "name_science_ch_stroke" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateNameScienceChStroke() *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { - s.UpdateScienceStroke() + s.UpdateNameScienceChStroke() + }) +} + +// SetIsRegular sets the "is_regular" field. +func (u *NCharacterUpsertOne) SetIsRegular(v bool) *NCharacterUpsertOne { + return u.Update(func(s *NCharacterUpsert) { + s.SetIsRegular(v) + }) +} + +// UpdateIsRegular sets the "is_regular" field to the value that was provided on create. +func (u *NCharacterUpsertOne) UpdateIsRegular() *NCharacterUpsertOne { + return u.Update(func(s *NCharacterUpsert) { + s.UpdateIsRegular() }) } @@ -885,20 +873,6 @@ func (u *NCharacterUpsertOne) UpdateLucky() *NCharacterUpsertOne { }) } -// SetRegular sets the "regular" field. -func (u *NCharacterUpsertOne) SetRegular(v bool) *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.SetRegular(v) - }) -} - -// UpdateRegular sets the "regular" field to the value that was provided on create. -func (u *NCharacterUpsertOne) UpdateRegular() *NCharacterUpsertOne { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateRegular() - }) -} - // SetComment sets the "comment" field. func (u *NCharacterUpsertOne) SetComment(v string) *NCharacterUpsertOne { return u.Update(func(s *NCharacterUpsert) { @@ -929,12 +903,7 @@ func (u *NCharacterUpsertOne) ExecX(ctx context.Context) { } // Exec executes the UPSERT query and returns the inserted/updated ID. -func (u *NCharacterUpsertOne) ID(ctx context.Context) (id string, err error) { - if u.create.driver.Dialect() == dialect.MySQL { - // In case of "ON CONFLICT", there is no way to get back non-numeric ID - // fields from the database since MySQL does not support the RETURNING clause. - return id, errors.New("ent: NCharacterUpsertOne.ID is not supported by MySQL driver. Use NCharacterUpsertOne.Exec instead") - } +func (u *NCharacterUpsertOne) ID(ctx context.Context) (id int32, err error) { node, err := u.create.Save(ctx) if err != nil { return id, err @@ -943,7 +912,7 @@ func (u *NCharacterUpsertOne) ID(ctx context.Context) (id string, err error) { } // IDX is like ID, but panics if an error occurs. -func (u *NCharacterUpsertOne) IDX(ctx context.Context) string { +func (u *NCharacterUpsertOne) IDX(ctx context.Context) int32 { id, err := u.ID(ctx) if err != nil { panic(err) @@ -970,6 +939,7 @@ func (ncb *NCharacterCreateBulk) Save(ctx context.Context) ([]*NCharacter, error for i := range ncb.builders { func(i int, root context.Context) { builder := ncb.builders[i] + builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*NCharacterMutation) if !ok { @@ -997,6 +967,10 @@ func (ncb *NCharacterCreateBulk) Save(ctx context.Context) ([]*NCharacter, error return nil, err } mutation.id = &nodes[i].ID + if specs[i].ID.Value != nil && nodes[i].ID == 0 { + id := specs[i].ID.Value.(int64) + nodes[i].ID = int32(id) + } mutation.done = true return nodes[i], nil }) @@ -1141,38 +1115,59 @@ func (u *NCharacterUpsertBulk) UpdatePinYin() *NCharacterUpsertBulk { }) } -// SetChID sets the "ch_id" field. -func (u *NCharacterUpsertBulk) SetChID(v int64) *NCharacterUpsertBulk { +// SetCh sets the "ch" field. +func (u *NCharacterUpsertBulk) SetCh(v string) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.SetChID(v) + s.SetCh(v) }) } -// AddChID adds v to the "ch_id" field. -func (u *NCharacterUpsertBulk) AddChID(v int64) *NCharacterUpsertBulk { +// UpdateCh sets the "ch" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateCh() *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.AddChID(v) + s.UpdateCh() }) } -// UpdateChID sets the "ch_id" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateChID() *NCharacterUpsertBulk { +// SetChStroke sets the "ch_stroke" field. +func (u *NCharacterUpsertBulk) SetChStroke(v int) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.UpdateChID() + s.SetChStroke(v) }) } -// SetCh sets the "ch" field. -func (u *NCharacterUpsertBulk) SetCh(v string) *NCharacterUpsertBulk { +// AddChStroke adds v to the "ch_stroke" field. +func (u *NCharacterUpsertBulk) AddChStroke(v int) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.SetCh(v) + s.AddChStroke(v) }) } -// UpdateCh sets the "ch" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateCh() *NCharacterUpsertBulk { +// UpdateChStroke sets the "ch_stroke" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateChStroke() *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.UpdateCh() + s.UpdateChStroke() + }) +} + +// SetChType sets the "ch_type" field. +func (u *NCharacterUpsertBulk) SetChType(v int) *NCharacterUpsertBulk { + return u.Update(func(s *NCharacterUpsert) { + s.SetChType(v) + }) +} + +// AddChType adds v to the "ch_type" field. +func (u *NCharacterUpsertBulk) AddChType(v int) *NCharacterUpsertBulk { + return u.Update(func(s *NCharacterUpsert) { + s.AddChType(v) + }) +} + +// UpdateChType sets the "ch_type" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateChType() *NCharacterUpsertBulk { + return u.Update(func(s *NCharacterUpsert) { + s.UpdateChType() }) } @@ -1211,38 +1206,17 @@ func (u *NCharacterUpsertBulk) UpdateRadicalStroke() *NCharacterUpsertBulk { }) } -// SetTotalStroke sets the "total_stroke" field. -func (u *NCharacterUpsertBulk) SetTotalStroke(v int) *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.SetTotalStroke(v) - }) -} - -// AddTotalStroke adds v to the "total_stroke" field. -func (u *NCharacterUpsertBulk) AddTotalStroke(v int) *NCharacterUpsertBulk { +// SetRelate sets the "relate" field. +func (u *NCharacterUpsertBulk) SetRelate(v string) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.AddTotalStroke(v) + s.SetRelate(v) }) } -// UpdateTotalStroke sets the "total_stroke" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateTotalStroke() *NCharacterUpsertBulk { +// UpdateRelate sets the "relate" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateRelate() *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.UpdateTotalStroke() - }) -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (u *NCharacterUpsertBulk) SetIsKangXi(v bool) *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.SetIsKangXi(v) - }) -} - -// UpdateIsKangXi sets the "is_kang_xi" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateIsKangXi() *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateIsKangXi() + s.UpdateRelate() }) } @@ -1260,20 +1234,6 @@ func (u *NCharacterUpsertBulk) UpdateRelateKangXi() *NCharacterUpsertBulk { }) } -// SetRelateSimple sets the "relate_simple" field. -func (u *NCharacterUpsertBulk) SetRelateSimple(v string) *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.SetRelateSimple(v) - }) -} - -// UpdateRelateSimple sets the "relate_simple" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateRelateSimple() *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateRelateSimple() - }) -} - // SetRelateTraditional sets the "relate_traditional" field. func (u *NCharacterUpsertBulk) SetRelateTraditional(v string) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { @@ -1289,7 +1249,7 @@ func (u *NCharacterUpsertBulk) UpdateRelateTraditional() *NCharacterUpsertBulk { } // SetRelateVariant sets the "relate_variant" field. -func (u *NCharacterUpsertBulk) SetRelateVariant(v string) *NCharacterUpsertBulk { +func (u *NCharacterUpsertBulk) SetRelateVariant(v []string) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { s.SetRelateVariant(v) }) @@ -1302,38 +1262,52 @@ func (u *NCharacterUpsertBulk) UpdateRelateVariant() *NCharacterUpsertBulk { }) } -// SetNameScience sets the "name_science" field. -func (u *NCharacterUpsertBulk) SetNameScience(v bool) *NCharacterUpsertBulk { +// SetIsNameScience sets the "is_name_science" field. +func (u *NCharacterUpsertBulk) SetIsNameScience(v bool) *NCharacterUpsertBulk { + return u.Update(func(s *NCharacterUpsert) { + s.SetIsNameScience(v) + }) +} + +// UpdateIsNameScience sets the "is_name_science" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateIsNameScience() *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.SetNameScience(v) + s.UpdateIsNameScience() }) } -// UpdateNameScience sets the "name_science" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateNameScience() *NCharacterUpsertBulk { +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (u *NCharacterUpsertBulk) SetNameScienceChStroke(v int) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.UpdateNameScience() + s.SetNameScienceChStroke(v) }) } -// SetScienceStroke sets the "science_stroke" field. -func (u *NCharacterUpsertBulk) SetScienceStroke(v int) *NCharacterUpsertBulk { +// AddNameScienceChStroke adds v to the "name_science_ch_stroke" field. +func (u *NCharacterUpsertBulk) AddNameScienceChStroke(v int) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.SetScienceStroke(v) + s.AddNameScienceChStroke(v) }) } -// AddScienceStroke adds v to the "science_stroke" field. -func (u *NCharacterUpsertBulk) AddScienceStroke(v int) *NCharacterUpsertBulk { +// UpdateNameScienceChStroke sets the "name_science_ch_stroke" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateNameScienceChStroke() *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.AddScienceStroke(v) + s.UpdateNameScienceChStroke() }) } -// UpdateScienceStroke sets the "science_stroke" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateScienceStroke() *NCharacterUpsertBulk { +// SetIsRegular sets the "is_regular" field. +func (u *NCharacterUpsertBulk) SetIsRegular(v bool) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { - s.UpdateScienceStroke() + s.SetIsRegular(v) + }) +} + +// UpdateIsRegular sets the "is_regular" field to the value that was provided on create. +func (u *NCharacterUpsertBulk) UpdateIsRegular() *NCharacterUpsertBulk { + return u.Update(func(s *NCharacterUpsert) { + s.UpdateIsRegular() }) } @@ -1365,20 +1339,6 @@ func (u *NCharacterUpsertBulk) UpdateLucky() *NCharacterUpsertBulk { }) } -// SetRegular sets the "regular" field. -func (u *NCharacterUpsertBulk) SetRegular(v bool) *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.SetRegular(v) - }) -} - -// UpdateRegular sets the "regular" field to the value that was provided on create. -func (u *NCharacterUpsertBulk) UpdateRegular() *NCharacterUpsertBulk { - return u.Update(func(s *NCharacterUpsert) { - s.UpdateRegular() - }) -} - // SetComment sets the "comment" field. func (u *NCharacterUpsertBulk) SetComment(v string) *NCharacterUpsertBulk { return u.Update(func(s *NCharacterUpsert) { diff --git a/ent/ncharacter_delete.go b/ent/ncharacter_delete.go index 38c568a..c4a5fec 100644 --- a/ent/ncharacter_delete.go +++ b/ent/ncharacter_delete.go @@ -40,7 +40,7 @@ func (nd *NCharacterDelete) ExecX(ctx context.Context) int { } func (nd *NCharacterDelete) sqlExec(ctx context.Context) (int, error) { - _spec := sqlgraph.NewDeleteSpec(ncharacter.Table, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeString)) + _spec := sqlgraph.NewDeleteSpec(ncharacter.Table, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeInt32)) if ps := nd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { diff --git a/ent/ncharacter_query.go b/ent/ncharacter_query.go index dac440c..3d23603 100644 --- a/ent/ncharacter_query.go +++ b/ent/ncharacter_query.go @@ -83,8 +83,8 @@ func (nq *NCharacterQuery) FirstX(ctx context.Context) *NCharacter { // FirstID returns the first NCharacter ID from the query. // Returns a *NotFoundError when no NCharacter ID was found. -func (nq *NCharacterQuery) FirstID(ctx context.Context) (id string, err error) { - var ids []string +func (nq *NCharacterQuery) FirstID(ctx context.Context) (id int32, err error) { + var ids []int32 if ids, err = nq.Limit(1).IDs(setContextOp(ctx, nq.ctx, "FirstID")); err != nil { return } @@ -96,7 +96,7 @@ func (nq *NCharacterQuery) FirstID(ctx context.Context) (id string, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (nq *NCharacterQuery) FirstIDX(ctx context.Context) string { +func (nq *NCharacterQuery) FirstIDX(ctx context.Context) int32 { id, err := nq.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) @@ -134,8 +134,8 @@ func (nq *NCharacterQuery) OnlyX(ctx context.Context) *NCharacter { // OnlyID is like Only, but returns the only NCharacter ID in the query. // Returns a *NotSingularError when more than one NCharacter ID is found. // Returns a *NotFoundError when no entities are found. -func (nq *NCharacterQuery) OnlyID(ctx context.Context) (id string, err error) { - var ids []string +func (nq *NCharacterQuery) OnlyID(ctx context.Context) (id int32, err error) { + var ids []int32 if ids, err = nq.Limit(2).IDs(setContextOp(ctx, nq.ctx, "OnlyID")); err != nil { return } @@ -151,7 +151,7 @@ func (nq *NCharacterQuery) OnlyID(ctx context.Context) (id string, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (nq *NCharacterQuery) OnlyIDX(ctx context.Context) string { +func (nq *NCharacterQuery) OnlyIDX(ctx context.Context) int32 { id, err := nq.OnlyID(ctx) if err != nil { panic(err) @@ -179,7 +179,7 @@ func (nq *NCharacterQuery) AllX(ctx context.Context) []*NCharacter { } // IDs executes the query and returns a list of NCharacter IDs. -func (nq *NCharacterQuery) IDs(ctx context.Context) (ids []string, err error) { +func (nq *NCharacterQuery) IDs(ctx context.Context) (ids []int32, err error) { if nq.ctx.Unique == nil && nq.path != nil { nq.Unique(true) } @@ -191,7 +191,7 @@ func (nq *NCharacterQuery) IDs(ctx context.Context) (ids []string, err error) { } // IDsX is like IDs, but panics if an error occurs. -func (nq *NCharacterQuery) IDsX(ctx context.Context) []string { +func (nq *NCharacterQuery) IDsX(ctx context.Context) []int32 { ids, err := nq.IDs(ctx) if err != nil { panic(err) @@ -372,7 +372,7 @@ func (nq *NCharacterQuery) sqlCount(ctx context.Context) (int, error) { } func (nq *NCharacterQuery) querySpec() *sqlgraph.QuerySpec { - _spec := sqlgraph.NewQuerySpec(ncharacter.Table, ncharacter.Columns, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeString)) + _spec := sqlgraph.NewQuerySpec(ncharacter.Table, ncharacter.Columns, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeInt32)) _spec.From = nq.sql if unique := nq.ctx.Unique; unique != nil { _spec.Unique = *unique diff --git a/ent/ncharacter_update.go b/ent/ncharacter_update.go index 93c5227..dd363b0 100644 --- a/ent/ncharacter_update.go +++ b/ent/ncharacter_update.go @@ -9,6 +9,7 @@ import ( "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" + "entgo.io/ent/dialect/sql/sqljson" "entgo.io/ent/schema/field" "github.com/babyname/fate/ent/ncharacter" "github.com/babyname/fate/ent/predicate" @@ -33,22 +34,43 @@ func (nu *NCharacterUpdate) SetPinYin(s string) *NCharacterUpdate { return nu } -// SetChID sets the "ch_id" field. -func (nu *NCharacterUpdate) SetChID(i int64) *NCharacterUpdate { - nu.mutation.ResetChID() - nu.mutation.SetChID(i) +// SetCh sets the "ch" field. +func (nu *NCharacterUpdate) SetCh(s string) *NCharacterUpdate { + nu.mutation.SetCh(s) return nu } -// AddChID adds i to the "ch_id" field. -func (nu *NCharacterUpdate) AddChID(i int64) *NCharacterUpdate { - nu.mutation.AddChID(i) +// SetChStroke sets the "ch_stroke" field. +func (nu *NCharacterUpdate) SetChStroke(i int) *NCharacterUpdate { + nu.mutation.ResetChStroke() + nu.mutation.SetChStroke(i) return nu } -// SetCh sets the "ch" field. -func (nu *NCharacterUpdate) SetCh(s string) *NCharacterUpdate { - nu.mutation.SetCh(s) +// AddChStroke adds i to the "ch_stroke" field. +func (nu *NCharacterUpdate) AddChStroke(i int) *NCharacterUpdate { + nu.mutation.AddChStroke(i) + return nu +} + +// SetChType sets the "ch_type" field. +func (nu *NCharacterUpdate) SetChType(i int) *NCharacterUpdate { + nu.mutation.ResetChType() + nu.mutation.SetChType(i) + return nu +} + +// SetNillableChType sets the "ch_type" field if the given value is not nil. +func (nu *NCharacterUpdate) SetNillableChType(i *int) *NCharacterUpdate { + if i != nil { + nu.SetChType(*i) + } + return nu +} + +// AddChType adds i to the "ch_type" field. +func (nu *NCharacterUpdate) AddChType(i int) *NCharacterUpdate { + nu.mutation.AddChType(i) return nu } @@ -71,22 +93,9 @@ func (nu *NCharacterUpdate) AddRadicalStroke(i int) *NCharacterUpdate { return nu } -// SetTotalStroke sets the "total_stroke" field. -func (nu *NCharacterUpdate) SetTotalStroke(i int) *NCharacterUpdate { - nu.mutation.ResetTotalStroke() - nu.mutation.SetTotalStroke(i) - return nu -} - -// AddTotalStroke adds i to the "total_stroke" field. -func (nu *NCharacterUpdate) AddTotalStroke(i int) *NCharacterUpdate { - nu.mutation.AddTotalStroke(i) - return nu -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (nu *NCharacterUpdate) SetIsKangXi(b bool) *NCharacterUpdate { - nu.mutation.SetIsKangXi(b) +// SetRelate sets the "relate" field. +func (nu *NCharacterUpdate) SetRelate(s string) *NCharacterUpdate { + nu.mutation.SetRelate(s) return nu } @@ -96,12 +105,6 @@ func (nu *NCharacterUpdate) SetRelateKangXi(s string) *NCharacterUpdate { return nu } -// SetRelateSimple sets the "relate_simple" field. -func (nu *NCharacterUpdate) SetRelateSimple(s string) *NCharacterUpdate { - nu.mutation.SetRelateSimple(s) - return nu -} - // SetRelateTraditional sets the "relate_traditional" field. func (nu *NCharacterUpdate) SetRelateTraditional(s string) *NCharacterUpdate { nu.mutation.SetRelateTraditional(s) @@ -109,27 +112,39 @@ func (nu *NCharacterUpdate) SetRelateTraditional(s string) *NCharacterUpdate { } // SetRelateVariant sets the "relate_variant" field. -func (nu *NCharacterUpdate) SetRelateVariant(s string) *NCharacterUpdate { +func (nu *NCharacterUpdate) SetRelateVariant(s []string) *NCharacterUpdate { nu.mutation.SetRelateVariant(s) return nu } -// SetNameScience sets the "name_science" field. -func (nu *NCharacterUpdate) SetNameScience(b bool) *NCharacterUpdate { - nu.mutation.SetNameScience(b) +// AppendRelateVariant appends s to the "relate_variant" field. +func (nu *NCharacterUpdate) AppendRelateVariant(s []string) *NCharacterUpdate { + nu.mutation.AppendRelateVariant(s) + return nu +} + +// SetIsNameScience sets the "is_name_science" field. +func (nu *NCharacterUpdate) SetIsNameScience(b bool) *NCharacterUpdate { + nu.mutation.SetIsNameScience(b) + return nu +} + +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (nu *NCharacterUpdate) SetNameScienceChStroke(i int) *NCharacterUpdate { + nu.mutation.ResetNameScienceChStroke() + nu.mutation.SetNameScienceChStroke(i) return nu } -// SetScienceStroke sets the "science_stroke" field. -func (nu *NCharacterUpdate) SetScienceStroke(i int) *NCharacterUpdate { - nu.mutation.ResetScienceStroke() - nu.mutation.SetScienceStroke(i) +// AddNameScienceChStroke adds i to the "name_science_ch_stroke" field. +func (nu *NCharacterUpdate) AddNameScienceChStroke(i int) *NCharacterUpdate { + nu.mutation.AddNameScienceChStroke(i) return nu } -// AddScienceStroke adds i to the "science_stroke" field. -func (nu *NCharacterUpdate) AddScienceStroke(i int) *NCharacterUpdate { - nu.mutation.AddScienceStroke(i) +// SetIsRegular sets the "is_regular" field. +func (nu *NCharacterUpdate) SetIsRegular(b bool) *NCharacterUpdate { + nu.mutation.SetIsRegular(b) return nu } @@ -145,12 +160,6 @@ func (nu *NCharacterUpdate) SetLucky(s string) *NCharacterUpdate { return nu } -// SetRegular sets the "regular" field. -func (nu *NCharacterUpdate) SetRegular(b bool) *NCharacterUpdate { - nu.mutation.SetRegular(b) - return nu -} - // SetComment sets the "comment" field. func (nu *NCharacterUpdate) SetComment(s string) *NCharacterUpdate { nu.mutation.SetComment(s) @@ -190,7 +199,7 @@ func (nu *NCharacterUpdate) ExecX(ctx context.Context) { } func (nu *NCharacterUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := sqlgraph.NewUpdateSpec(ncharacter.Table, ncharacter.Columns, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeString)) + _spec := sqlgraph.NewUpdateSpec(ncharacter.Table, ncharacter.Columns, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeInt32)) if ps := nu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -201,15 +210,21 @@ func (nu *NCharacterUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := nu.mutation.PinYin(); ok { _spec.SetField(ncharacter.FieldPinYin, field.TypeString, value) } - if value, ok := nu.mutation.ChID(); ok { - _spec.SetField(ncharacter.FieldChID, field.TypeInt64, value) - } - if value, ok := nu.mutation.AddedChID(); ok { - _spec.AddField(ncharacter.FieldChID, field.TypeInt64, value) - } if value, ok := nu.mutation.Ch(); ok { _spec.SetField(ncharacter.FieldCh, field.TypeString, value) } + if value, ok := nu.mutation.ChStroke(); ok { + _spec.SetField(ncharacter.FieldChStroke, field.TypeInt, value) + } + if value, ok := nu.mutation.AddedChStroke(); ok { + _spec.AddField(ncharacter.FieldChStroke, field.TypeInt, value) + } + if value, ok := nu.mutation.ChType(); ok { + _spec.SetField(ncharacter.FieldChType, field.TypeInt, value) + } + if value, ok := nu.mutation.AddedChType(); ok { + _spec.AddField(ncharacter.FieldChType, field.TypeInt, value) + } if value, ok := nu.mutation.Radical(); ok { _spec.SetField(ncharacter.FieldRadical, field.TypeString, value) } @@ -219,35 +234,34 @@ func (nu *NCharacterUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := nu.mutation.AddedRadicalStroke(); ok { _spec.AddField(ncharacter.FieldRadicalStroke, field.TypeInt, value) } - if value, ok := nu.mutation.TotalStroke(); ok { - _spec.SetField(ncharacter.FieldTotalStroke, field.TypeInt, value) - } - if value, ok := nu.mutation.AddedTotalStroke(); ok { - _spec.AddField(ncharacter.FieldTotalStroke, field.TypeInt, value) - } - if value, ok := nu.mutation.IsKangXi(); ok { - _spec.SetField(ncharacter.FieldIsKangXi, field.TypeBool, value) + if value, ok := nu.mutation.Relate(); ok { + _spec.SetField(ncharacter.FieldRelate, field.TypeString, value) } if value, ok := nu.mutation.RelateKangXi(); ok { _spec.SetField(ncharacter.FieldRelateKangXi, field.TypeString, value) } - if value, ok := nu.mutation.RelateSimple(); ok { - _spec.SetField(ncharacter.FieldRelateSimple, field.TypeString, value) - } if value, ok := nu.mutation.RelateTraditional(); ok { _spec.SetField(ncharacter.FieldRelateTraditional, field.TypeString, value) } if value, ok := nu.mutation.RelateVariant(); ok { - _spec.SetField(ncharacter.FieldRelateVariant, field.TypeString, value) + _spec.SetField(ncharacter.FieldRelateVariant, field.TypeJSON, value) + } + if value, ok := nu.mutation.AppendedRelateVariant(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, ncharacter.FieldRelateVariant, value) + }) } - if value, ok := nu.mutation.NameScience(); ok { - _spec.SetField(ncharacter.FieldNameScience, field.TypeBool, value) + if value, ok := nu.mutation.IsNameScience(); ok { + _spec.SetField(ncharacter.FieldIsNameScience, field.TypeBool, value) } - if value, ok := nu.mutation.ScienceStroke(); ok { - _spec.SetField(ncharacter.FieldScienceStroke, field.TypeInt, value) + if value, ok := nu.mutation.NameScienceChStroke(); ok { + _spec.SetField(ncharacter.FieldNameScienceChStroke, field.TypeInt, value) } - if value, ok := nu.mutation.AddedScienceStroke(); ok { - _spec.AddField(ncharacter.FieldScienceStroke, field.TypeInt, value) + if value, ok := nu.mutation.AddedNameScienceChStroke(); ok { + _spec.AddField(ncharacter.FieldNameScienceChStroke, field.TypeInt, value) + } + if value, ok := nu.mutation.IsRegular(); ok { + _spec.SetField(ncharacter.FieldIsRegular, field.TypeBool, value) } if value, ok := nu.mutation.WuXing(); ok { _spec.SetField(ncharacter.FieldWuXing, field.TypeString, value) @@ -255,9 +269,6 @@ func (nu *NCharacterUpdate) sqlSave(ctx context.Context) (n int, err error) { if value, ok := nu.mutation.Lucky(); ok { _spec.SetField(ncharacter.FieldLucky, field.TypeString, value) } - if value, ok := nu.mutation.Regular(); ok { - _spec.SetField(ncharacter.FieldRegular, field.TypeBool, value) - } if value, ok := nu.mutation.Comment(); ok { _spec.SetField(ncharacter.FieldComment, field.TypeString, value) } @@ -287,22 +298,43 @@ func (nuo *NCharacterUpdateOne) SetPinYin(s string) *NCharacterUpdateOne { return nuo } -// SetChID sets the "ch_id" field. -func (nuo *NCharacterUpdateOne) SetChID(i int64) *NCharacterUpdateOne { - nuo.mutation.ResetChID() - nuo.mutation.SetChID(i) +// SetCh sets the "ch" field. +func (nuo *NCharacterUpdateOne) SetCh(s string) *NCharacterUpdateOne { + nuo.mutation.SetCh(s) return nuo } -// AddChID adds i to the "ch_id" field. -func (nuo *NCharacterUpdateOne) AddChID(i int64) *NCharacterUpdateOne { - nuo.mutation.AddChID(i) +// SetChStroke sets the "ch_stroke" field. +func (nuo *NCharacterUpdateOne) SetChStroke(i int) *NCharacterUpdateOne { + nuo.mutation.ResetChStroke() + nuo.mutation.SetChStroke(i) return nuo } -// SetCh sets the "ch" field. -func (nuo *NCharacterUpdateOne) SetCh(s string) *NCharacterUpdateOne { - nuo.mutation.SetCh(s) +// AddChStroke adds i to the "ch_stroke" field. +func (nuo *NCharacterUpdateOne) AddChStroke(i int) *NCharacterUpdateOne { + nuo.mutation.AddChStroke(i) + return nuo +} + +// SetChType sets the "ch_type" field. +func (nuo *NCharacterUpdateOne) SetChType(i int) *NCharacterUpdateOne { + nuo.mutation.ResetChType() + nuo.mutation.SetChType(i) + return nuo +} + +// SetNillableChType sets the "ch_type" field if the given value is not nil. +func (nuo *NCharacterUpdateOne) SetNillableChType(i *int) *NCharacterUpdateOne { + if i != nil { + nuo.SetChType(*i) + } + return nuo +} + +// AddChType adds i to the "ch_type" field. +func (nuo *NCharacterUpdateOne) AddChType(i int) *NCharacterUpdateOne { + nuo.mutation.AddChType(i) return nuo } @@ -325,22 +357,9 @@ func (nuo *NCharacterUpdateOne) AddRadicalStroke(i int) *NCharacterUpdateOne { return nuo } -// SetTotalStroke sets the "total_stroke" field. -func (nuo *NCharacterUpdateOne) SetTotalStroke(i int) *NCharacterUpdateOne { - nuo.mutation.ResetTotalStroke() - nuo.mutation.SetTotalStroke(i) - return nuo -} - -// AddTotalStroke adds i to the "total_stroke" field. -func (nuo *NCharacterUpdateOne) AddTotalStroke(i int) *NCharacterUpdateOne { - nuo.mutation.AddTotalStroke(i) - return nuo -} - -// SetIsKangXi sets the "is_kang_xi" field. -func (nuo *NCharacterUpdateOne) SetIsKangXi(b bool) *NCharacterUpdateOne { - nuo.mutation.SetIsKangXi(b) +// SetRelate sets the "relate" field. +func (nuo *NCharacterUpdateOne) SetRelate(s string) *NCharacterUpdateOne { + nuo.mutation.SetRelate(s) return nuo } @@ -350,12 +369,6 @@ func (nuo *NCharacterUpdateOne) SetRelateKangXi(s string) *NCharacterUpdateOne { return nuo } -// SetRelateSimple sets the "relate_simple" field. -func (nuo *NCharacterUpdateOne) SetRelateSimple(s string) *NCharacterUpdateOne { - nuo.mutation.SetRelateSimple(s) - return nuo -} - // SetRelateTraditional sets the "relate_traditional" field. func (nuo *NCharacterUpdateOne) SetRelateTraditional(s string) *NCharacterUpdateOne { nuo.mutation.SetRelateTraditional(s) @@ -363,27 +376,39 @@ func (nuo *NCharacterUpdateOne) SetRelateTraditional(s string) *NCharacterUpdate } // SetRelateVariant sets the "relate_variant" field. -func (nuo *NCharacterUpdateOne) SetRelateVariant(s string) *NCharacterUpdateOne { +func (nuo *NCharacterUpdateOne) SetRelateVariant(s []string) *NCharacterUpdateOne { nuo.mutation.SetRelateVariant(s) return nuo } -// SetNameScience sets the "name_science" field. -func (nuo *NCharacterUpdateOne) SetNameScience(b bool) *NCharacterUpdateOne { - nuo.mutation.SetNameScience(b) +// AppendRelateVariant appends s to the "relate_variant" field. +func (nuo *NCharacterUpdateOne) AppendRelateVariant(s []string) *NCharacterUpdateOne { + nuo.mutation.AppendRelateVariant(s) + return nuo +} + +// SetIsNameScience sets the "is_name_science" field. +func (nuo *NCharacterUpdateOne) SetIsNameScience(b bool) *NCharacterUpdateOne { + nuo.mutation.SetIsNameScience(b) + return nuo +} + +// SetNameScienceChStroke sets the "name_science_ch_stroke" field. +func (nuo *NCharacterUpdateOne) SetNameScienceChStroke(i int) *NCharacterUpdateOne { + nuo.mutation.ResetNameScienceChStroke() + nuo.mutation.SetNameScienceChStroke(i) return nuo } -// SetScienceStroke sets the "science_stroke" field. -func (nuo *NCharacterUpdateOne) SetScienceStroke(i int) *NCharacterUpdateOne { - nuo.mutation.ResetScienceStroke() - nuo.mutation.SetScienceStroke(i) +// AddNameScienceChStroke adds i to the "name_science_ch_stroke" field. +func (nuo *NCharacterUpdateOne) AddNameScienceChStroke(i int) *NCharacterUpdateOne { + nuo.mutation.AddNameScienceChStroke(i) return nuo } -// AddScienceStroke adds i to the "science_stroke" field. -func (nuo *NCharacterUpdateOne) AddScienceStroke(i int) *NCharacterUpdateOne { - nuo.mutation.AddScienceStroke(i) +// SetIsRegular sets the "is_regular" field. +func (nuo *NCharacterUpdateOne) SetIsRegular(b bool) *NCharacterUpdateOne { + nuo.mutation.SetIsRegular(b) return nuo } @@ -399,12 +424,6 @@ func (nuo *NCharacterUpdateOne) SetLucky(s string) *NCharacterUpdateOne { return nuo } -// SetRegular sets the "regular" field. -func (nuo *NCharacterUpdateOne) SetRegular(b bool) *NCharacterUpdateOne { - nuo.mutation.SetRegular(b) - return nuo -} - // SetComment sets the "comment" field. func (nuo *NCharacterUpdateOne) SetComment(s string) *NCharacterUpdateOne { nuo.mutation.SetComment(s) @@ -457,7 +476,7 @@ func (nuo *NCharacterUpdateOne) ExecX(ctx context.Context) { } func (nuo *NCharacterUpdateOne) sqlSave(ctx context.Context) (_node *NCharacter, err error) { - _spec := sqlgraph.NewUpdateSpec(ncharacter.Table, ncharacter.Columns, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeString)) + _spec := sqlgraph.NewUpdateSpec(ncharacter.Table, ncharacter.Columns, sqlgraph.NewFieldSpec(ncharacter.FieldID, field.TypeInt32)) id, ok := nuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "NCharacter.id" for update`)} @@ -485,15 +504,21 @@ func (nuo *NCharacterUpdateOne) sqlSave(ctx context.Context) (_node *NCharacter, if value, ok := nuo.mutation.PinYin(); ok { _spec.SetField(ncharacter.FieldPinYin, field.TypeString, value) } - if value, ok := nuo.mutation.ChID(); ok { - _spec.SetField(ncharacter.FieldChID, field.TypeInt64, value) - } - if value, ok := nuo.mutation.AddedChID(); ok { - _spec.AddField(ncharacter.FieldChID, field.TypeInt64, value) - } if value, ok := nuo.mutation.Ch(); ok { _spec.SetField(ncharacter.FieldCh, field.TypeString, value) } + if value, ok := nuo.mutation.ChStroke(); ok { + _spec.SetField(ncharacter.FieldChStroke, field.TypeInt, value) + } + if value, ok := nuo.mutation.AddedChStroke(); ok { + _spec.AddField(ncharacter.FieldChStroke, field.TypeInt, value) + } + if value, ok := nuo.mutation.ChType(); ok { + _spec.SetField(ncharacter.FieldChType, field.TypeInt, value) + } + if value, ok := nuo.mutation.AddedChType(); ok { + _spec.AddField(ncharacter.FieldChType, field.TypeInt, value) + } if value, ok := nuo.mutation.Radical(); ok { _spec.SetField(ncharacter.FieldRadical, field.TypeString, value) } @@ -503,35 +528,34 @@ func (nuo *NCharacterUpdateOne) sqlSave(ctx context.Context) (_node *NCharacter, if value, ok := nuo.mutation.AddedRadicalStroke(); ok { _spec.AddField(ncharacter.FieldRadicalStroke, field.TypeInt, value) } - if value, ok := nuo.mutation.TotalStroke(); ok { - _spec.SetField(ncharacter.FieldTotalStroke, field.TypeInt, value) - } - if value, ok := nuo.mutation.AddedTotalStroke(); ok { - _spec.AddField(ncharacter.FieldTotalStroke, field.TypeInt, value) - } - if value, ok := nuo.mutation.IsKangXi(); ok { - _spec.SetField(ncharacter.FieldIsKangXi, field.TypeBool, value) + if value, ok := nuo.mutation.Relate(); ok { + _spec.SetField(ncharacter.FieldRelate, field.TypeString, value) } if value, ok := nuo.mutation.RelateKangXi(); ok { _spec.SetField(ncharacter.FieldRelateKangXi, field.TypeString, value) } - if value, ok := nuo.mutation.RelateSimple(); ok { - _spec.SetField(ncharacter.FieldRelateSimple, field.TypeString, value) - } if value, ok := nuo.mutation.RelateTraditional(); ok { _spec.SetField(ncharacter.FieldRelateTraditional, field.TypeString, value) } if value, ok := nuo.mutation.RelateVariant(); ok { - _spec.SetField(ncharacter.FieldRelateVariant, field.TypeString, value) + _spec.SetField(ncharacter.FieldRelateVariant, field.TypeJSON, value) + } + if value, ok := nuo.mutation.AppendedRelateVariant(); ok { + _spec.AddModifier(func(u *sql.UpdateBuilder) { + sqljson.Append(u, ncharacter.FieldRelateVariant, value) + }) } - if value, ok := nuo.mutation.NameScience(); ok { - _spec.SetField(ncharacter.FieldNameScience, field.TypeBool, value) + if value, ok := nuo.mutation.IsNameScience(); ok { + _spec.SetField(ncharacter.FieldIsNameScience, field.TypeBool, value) } - if value, ok := nuo.mutation.ScienceStroke(); ok { - _spec.SetField(ncharacter.FieldScienceStroke, field.TypeInt, value) + if value, ok := nuo.mutation.NameScienceChStroke(); ok { + _spec.SetField(ncharacter.FieldNameScienceChStroke, field.TypeInt, value) } - if value, ok := nuo.mutation.AddedScienceStroke(); ok { - _spec.AddField(ncharacter.FieldScienceStroke, field.TypeInt, value) + if value, ok := nuo.mutation.AddedNameScienceChStroke(); ok { + _spec.AddField(ncharacter.FieldNameScienceChStroke, field.TypeInt, value) + } + if value, ok := nuo.mutation.IsRegular(); ok { + _spec.SetField(ncharacter.FieldIsRegular, field.TypeBool, value) } if value, ok := nuo.mutation.WuXing(); ok { _spec.SetField(ncharacter.FieldWuXing, field.TypeString, value) @@ -539,9 +563,6 @@ func (nuo *NCharacterUpdateOne) sqlSave(ctx context.Context) (_node *NCharacter, if value, ok := nuo.mutation.Lucky(); ok { _spec.SetField(ncharacter.FieldLucky, field.TypeString, value) } - if value, ok := nuo.mutation.Regular(); ok { - _spec.SetField(ncharacter.FieldRegular, field.TypeBool, value) - } if value, ok := nuo.mutation.Comment(); ok { _spec.SetField(ncharacter.FieldComment, field.TypeString, value) } diff --git a/ent/runtime.go b/ent/runtime.go index 793d053..70ccc25 100644 --- a/ent/runtime.go +++ b/ent/runtime.go @@ -2,8 +2,19 @@ package ent +import ( + "github.com/babyname/fate/ent/ncharacter" + "github.com/babyname/fate/ent/schema" +) + // The init function reads all schema descriptors with runtime code // (default values, validators, hooks and policies) and stitches it // to their package variables. func init() { + ncharacterFields := schema.NCharacter{}.Fields() + _ = ncharacterFields + // ncharacterDescChType is the schema descriptor for ch_type field. + ncharacterDescChType := ncharacterFields[4].Descriptor() + // ncharacter.DefaultChType holds the default value on creation for the ch_type field. + ncharacter.DefaultChType = ncharacterDescChType.Default.(int) } diff --git a/ent/schema/ncharacter.go b/ent/schema/ncharacter.go index 72483ec..e99d8fd 100644 --- a/ent/schema/ncharacter.go +++ b/ent/schema/ncharacter.go @@ -11,35 +11,32 @@ type NCharacter struct { ent.Schema } +const ( + CharTypeUnknown = 0x00 + CharTypeSimple = 0x01 + CharTypeTraditional = 0x02 + CharTypeKangXi = 0x04 + CharTypeVariant = 0x08 +) + func (NCharacter) Fields() []ent.Field { return []ent.Field{ - field.String("id").StorageKey("hash"), + field.Int32("id"), //rune code field.String("pin_yin"), - field.Int64("ch_id"), field.String("ch"), + field.Int("ch_stroke"), + field.Int("ch_type").Default(CharTypeUnknown), field.String("radical"), field.Int("radical_stroke"), - field.Int("total_stroke"), - field.Bool("is_kang_xi"), + field.String("relate"), // relate simple chinese field.String("relate_kang_xi"), - field.String("relate_simple"), field.String("relate_traditional"), - field.String("relate_variant"), - //field.String("kang_xi"), - //field.Int("kang_xi_stroke"), - //field.String("simple_radical"), - //field.Int("simple_radical_stroke"), - //field.Int("simple_total_stroke"), - //field.String("traditional_radical"), - //field.Int("traditional_radical_stroke"), - //field.Int("traditional_total_stroke"), - field.Bool("name_science"), - field.Int("science_stroke"), + field.Strings("relate_variant"), //relate other variant characters + field.Bool("is_name_science"), + field.Int("name_science_ch_stroke"), + field.Bool("is_regular"), field.String("wu_xing"), field.String("lucky"), - field.Bool("regular"), - //field.String("traditional_character"), - //field.String("variant_character"), field.String("comment"), } }