From 2b4fac6a8755999b4132bf02e1e0a5b765efe4d9 Mon Sep 17 00:00:00 2001 From: wanyaoqi Date: Thu, 17 Jan 2019 21:57:54 +0800 Subject: [PATCH] remove key index --- Gopkg.lock | 4 +-- pkg/compute/models/cloudproviders.go | 2 +- pkg/compute/models/groupguests.go | 4 +-- pkg/compute/models/groupjoints.go | 2 +- pkg/compute/models/groupnetworks.go | 2 +- pkg/compute/models/guestdisks.go | 2 +- pkg/compute/models/guestjoints.go | 2 +- pkg/compute/models/guestnetworks.go | 18 +++++----- pkg/compute/models/guestsecgroups.go | 2 +- pkg/compute/models/hostnetworks.go | 8 ++--- pkg/compute/models/hostschedtags.go | 4 +-- pkg/compute/models/hoststorages.go | 4 +-- pkg/compute/models/hostwires.go | 4 +-- pkg/compute/models/loadbalancernetworks.go | 4 +-- pkg/compute/models/networks.go | 40 ++++++++++++++++----- pkg/compute/models/snapshots.go | 2 +- pkg/compute/models/storagecachedimages.go | 4 +-- vendor/yunion.io/x/sqlchemy/column.go | 12 ------- vendor/yunion.io/x/sqlchemy/const.go | 1 - vendor/yunion.io/x/sqlchemy/field_update.go | 15 ++------ vendor/yunion.io/x/sqlchemy/update.go | 24 ++++--------- 21 files changed, 75 insertions(+), 85 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index fe0c39c55f..50a2d7c217 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1671,11 +1671,11 @@ [[projects]] branch = "master" - digest = "1:b885ec8656c1175dbaa7f27add70d85e4e53b99122293a945734732c3e57604b" + digest = "1:0e3c8da76b7b7ba0f67ef0737d361e117b65bd328bfbcb28fb030268df587ca9" name = "yunion.io/x/sqlchemy" packages = ["."] pruneopts = "UT" - revision = "cd413404bb8e78699df15a08e7f94a14835c6f1c" + revision = "0b1ca973f3e5140dee7e773fc51cfc8c07ce0f69" [[projects]] branch = "master" diff --git a/pkg/compute/models/cloudproviders.go b/pkg/compute/models/cloudproviders.go index c5613bc4f8..9b6072191f 100644 --- a/pkg/compute/models/cloudproviders.go +++ b/pkg/compute/models/cloudproviders.go @@ -75,7 +75,7 @@ type SCloudprovider struct { Account string `width:"128" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` // Column(VARCHAR(64, charset='ascii'), nullable=False) Secret string `width:"256" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` // Column(VARCHAR(256, charset='ascii'), nullable=False) - CloudaccountId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` + CloudaccountId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` ProjectId string `name:"tenant_id" width:"128" charset:"ascii" nullable:"true" list:"admin"` diff --git a/pkg/compute/models/groupguests.go b/pkg/compute/models/groupguests.go index d85a97e2d7..1160d81613 100644 --- a/pkg/compute/models/groupguests.go +++ b/pkg/compute/models/groupguests.go @@ -32,8 +32,8 @@ func init() { type SGroupguest struct { SGroupJointsBase - Tag string `width:"256" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"` // Column(VARCHAR(256, charset='ascii'), nullable=True) - GuestId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + Tag string `width:"256" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"` // Column(VARCHAR(256, charset='ascii'), nullable=True) + GuestId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) } func (joint *SGroupguest) Master() db.IStandaloneModel { diff --git a/pkg/compute/models/groupjoints.go b/pkg/compute/models/groupjoints.go index ae583de1bf..095983d555 100644 --- a/pkg/compute/models/groupjoints.go +++ b/pkg/compute/models/groupjoints.go @@ -22,7 +22,7 @@ func NewGroupJointsManager(dt interface{}, tableName string, keyword string, key type SGroupJointsBase struct { db.SVirtualJointResourceBase - SrvtagId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + SrvtagId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) } func (self *SGroupJointsBase) GetGroup() *SGuest { diff --git a/pkg/compute/models/groupnetworks.go b/pkg/compute/models/groupnetworks.go index a934d2785e..87384ecd4b 100644 --- a/pkg/compute/models/groupnetworks.go +++ b/pkg/compute/models/groupnetworks.go @@ -25,7 +25,7 @@ func init() { type SGroupnetwork struct { SGroupJointsBase - NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) IpAddr string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"optional"` // Column(VARCHAR(16, charset='ascii'), nullable=True) // # ip6_addr = Column(VARCHAR(64, charset='ascii'), nullable=True) diff --git a/pkg/compute/models/guestdisks.go b/pkg/compute/models/guestdisks.go index 1cee788cc4..d051c6c22d 100644 --- a/pkg/compute/models/guestdisks.go +++ b/pkg/compute/models/guestdisks.go @@ -36,7 +36,7 @@ func init() { type SGuestdisk struct { SGuestJointsBase - DiskId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + DiskId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) ImagePath string `width:"256" charset:"ascii" nullable:"false" get:"user" create:"required"` // Column(VARCHAR(256, charset='ascii'), nullable=False) diff --git a/pkg/compute/models/guestjoints.go b/pkg/compute/models/guestjoints.go index b288e3e70c..4f4371e4b9 100644 --- a/pkg/compute/models/guestjoints.go +++ b/pkg/compute/models/guestjoints.go @@ -22,7 +22,7 @@ func NewGuestJointsManager(dt interface{}, tableName string, keyword string, key type SGuestJointsBase struct { db.SVirtualJointResourceBase - GuestId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + GuestId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) } func (self *SGuestJointsBase) getGuest() *SGuest { diff --git a/pkg/compute/models/guestnetworks.go b/pkg/compute/models/guestnetworks.go index 57fc3b67a9..c815bfc632 100644 --- a/pkg/compute/models/guestnetworks.go +++ b/pkg/compute/models/guestnetworks.go @@ -49,15 +49,15 @@ func init() { type SGuestnetwork struct { SGuestJointsBase - NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"user" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) - MacAddr string `width:"32" charset:"ascii" nullable:"false" list:"user"` // Column(VARCHAR(32, charset='ascii'), nullable=False) - IpAddr string `width:"16" charset:"ascii" nullable:"false" list:"user"` // Column(VARCHAR(16, charset='ascii'), nullable=True) - Ip6Addr string `width:"64" charset:"ascii" nullable:"true" list:"user"` // Column(VARCHAR(64, charset='ascii'), nullable=True) - Driver string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user"` // Column(VARCHAR(16, charset='ascii'), nullable=True) - BwLimit int `nullable:"false" default:"0" list:"user"` // Column(Integer, nullable=False, default=0) # Mbps - Index int8 `nullable:"false" default:"0" list:"user" update:"user"` // Column(TINYINT, nullable=False, default=0) - Virtual bool `default:"false" list:"user"` // Column(Boolean, default=False) - Ifname string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user"` // Column(VARCHAR(16, charset='ascii'), nullable=True) + NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"user" ` // Column(VARCHAR(36, charset='ascii'), nullable=False) + MacAddr string `width:"32" charset:"ascii" nullable:"false" list:"user"` // Column(VARCHAR(32, charset='ascii'), nullable=False) + IpAddr string `width:"16" charset:"ascii" nullable:"false" list:"user"` // Column(VARCHAR(16, charset='ascii'), nullable=True) + Ip6Addr string `width:"64" charset:"ascii" nullable:"true" list:"user"` // Column(VARCHAR(64, charset='ascii'), nullable=True) + Driver string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user"` // Column(VARCHAR(16, charset='ascii'), nullable=True) + BwLimit int `nullable:"false" default:"0" list:"user"` // Column(Integer, nullable=False, default=0) # Mbps + Index int8 `nullable:"false" default:"0" list:"user" update:"user"` // Column(TINYINT, nullable=False, default=0) + Virtual bool `default:"false" list:"user"` // Column(Boolean, default=False) + Ifname string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user"` // Column(VARCHAR(16, charset='ascii'), nullable=True) } func (joint *SGuestnetwork) Master() db.IStandaloneModel { diff --git a/pkg/compute/models/guestsecgroups.go b/pkg/compute/models/guestsecgroups.go index cac51429fd..2c59c62132 100644 --- a/pkg/compute/models/guestsecgroups.go +++ b/pkg/compute/models/guestsecgroups.go @@ -33,7 +33,7 @@ func init() { type SGuestsecgroup struct { SGuestJointsBase - SecgroupId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + SecgroupId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) } func (self *SGuestsecgroup) getSecgroup() *SSecurityGroup { diff --git a/pkg/compute/models/hostnetworks.go b/pkg/compute/models/hostnetworks.go index 6d5fbcaa44..6fe4663733 100644 --- a/pkg/compute/models/hostnetworks.go +++ b/pkg/compute/models/hostnetworks.go @@ -33,10 +33,10 @@ func init() { type SHostnetwork struct { SHostJointsBase - BaremetalId string `width:"36" charset:"ascii" nullable:"false" list:"admin" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) - NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"admin" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) - IpAddr string `width:"16" charset:"ascii" list:"admin"` // Column(VARCHAR(16, charset='ascii')) - MacAddr string `width:"18" charset:"ascii" list:"admin"` // Column(VARCHAR(18, charset='ascii')) + BaremetalId string `width:"36" charset:"ascii" nullable:"false" list:"admin"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"admin"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + IpAddr string `width:"16" charset:"ascii" list:"admin"` // Column(VARCHAR(16, charset='ascii')) + MacAddr string `width:"18" charset:"ascii" list:"admin"` // Column(VARCHAR(18, charset='ascii')) } func (bn *SHostnetwork) Master() db.IStandaloneModel { diff --git a/pkg/compute/models/hostschedtags.go b/pkg/compute/models/hostschedtags.go index fed5a42b24..c909a6efdb 100644 --- a/pkg/compute/models/hostschedtags.go +++ b/pkg/compute/models/hostschedtags.go @@ -32,8 +32,8 @@ func init() { type SHostschedtag struct { SHostJointsBase - HostId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required" key_index:"true"` // Column(VARCHAR(36, charset='ascii'), nullable=False) - SchedtagId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required" key_index:"true"` // =Column(VARCHAR(36, charset='ascii'), nullable=False) + HostId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + SchedtagId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` // =Column(VARCHAR(36, charset='ascii'), nullable=False) } func (joint *SHostschedtag) Master() db.IStandaloneModel { diff --git a/pkg/compute/models/hoststorages.go b/pkg/compute/models/hoststorages.go index 5c2d7381c0..a42ccd736a 100644 --- a/pkg/compute/models/hoststorages.go +++ b/pkg/compute/models/hoststorages.go @@ -42,8 +42,8 @@ type SHoststorage struct { MountPoint string `width:"256" charset:"ascii" nullable:"false" list:"admin" update:"admin" create:"required"` // Column(VARCHAR(256, charset='ascii'), nullable=False) - HostId string `width:"36" charset:"ascii" nullable:"false" list:"admin" key_index:"true" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) - StorageId string `width:"36" charset:"ascii" nullable:"false" list:"admin" key_index:"true" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + HostId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + StorageId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) Config *jsonutils.JSONArray `nullable:"true" get:"admin"` // Column(JSONEncodedDict, nullable=True) RealCapacity int `nullable:"true" list:"admin"` // Column(Integer, nullable=True) diff --git a/pkg/compute/models/hostwires.go b/pkg/compute/models/hostwires.go index ae1415c2ed..af5f36013f 100644 --- a/pkg/compute/models/hostwires.go +++ b/pkg/compute/models/hostwires.go @@ -38,8 +38,8 @@ type SHostwire struct { IsMaster bool `nullable:"true" default:"false" update:"admin" create:"admin_optional"` // Column(Boolean, nullable=True, default=False) MacAddr string `width:"18" charset:"ascii" list:"admin" update:"admin" create:"admin_required"` // Column(VARCHAR(18, charset='ascii')) - HostId string `width:"128" charset:"ascii" nullable:"false" list:"admin" create:"admin_required" key_index:"true"` // = Column(VARCHAR(ID_LENGTH, charset='ascii'), nullable=False) - WireId string `width:"128" charset:"ascii" nullable:"false" list:"admin" create:"admin_required" key_index:"true"` // Column(VARCHAR(ID_LENGTH, charset='ascii'), nullable=False) + HostId string `width:"128" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` // = Column(VARCHAR(ID_LENGTH, charset='ascii'), nullable=False) + WireId string `width:"128" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` // Column(VARCHAR(ID_LENGTH, charset='ascii'), nullable=False) } func (joint *SHostwire) Master() db.IStandaloneModel { diff --git a/pkg/compute/models/loadbalancernetworks.go b/pkg/compute/models/loadbalancernetworks.go index 30e533c467..6ec9e399c3 100644 --- a/pkg/compute/models/loadbalancernetworks.go +++ b/pkg/compute/models/loadbalancernetworks.go @@ -35,8 +35,8 @@ func init() { type SLoadbalancerNetwork struct { db.SVirtualJointResourceBase - LoadbalancerId string `width:"36" charset:"ascii" nullable:"false" key_index:"true" list:"admin"` - NetworkId string `width:"36" charset:"ascii" nullable:"false" key_index:"true" list:"admin"` + LoadbalancerId string `width:"36" charset:"ascii" nullable:"false" list:"admin"` + NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"admin"` IpAddr string `width:"16" charset:"ascii" list:"admin"` } diff --git a/pkg/compute/models/networks.go b/pkg/compute/models/networks.go index 0fdd9b6ace..de478e5cb1 100644 --- a/pkg/compute/models/networks.go +++ b/pkg/compute/models/networks.go @@ -1560,10 +1560,13 @@ func (self *SNetwork) PerformMerge(ctx context.Context, userCred mcclient.TokenC for _, gn := range guestnetworks { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if self.isAddressInRange(addr) { - GuestnetworkManager.TableSpec().Update(gn, func() error { + _, err = GuestnetworkManager.TableSpec().Update(&gn, func() error { gn.NetworkId = net.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1576,10 +1579,13 @@ func (self *SNetwork) PerformMerge(ctx context.Context, userCred mcclient.TokenC for _, gn := range hostnetworks { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if self.isAddressInRange(addr) { - HostnetworkManager.TableSpec().Update(gn, func() error { + _, err = HostnetworkManager.TableSpec().Update(&gn, func() error { gn.NetworkId = net.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1592,10 +1598,13 @@ func (self *SNetwork) PerformMerge(ctx context.Context, userCred mcclient.TokenC for _, gn := range reservedips { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if self.isAddressInRange(addr) { - ReservedipManager.TableSpec().Update(gn, func() error { + _, err = ReservedipManager.TableSpec().Update(&gn, func() error { gn.NetworkId = net.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1608,10 +1617,13 @@ func (self *SNetwork) PerformMerge(ctx context.Context, userCred mcclient.TokenC for _, gn := range groupnetwroks { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if self.isAddressInRange(addr) { - GroupnetworkManager.TableSpec().Update(gn, func() error { + _, err = GroupnetworkManager.TableSpec().Update(&gn, func() error { gn.NetworkId = net.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1700,10 +1712,13 @@ func (self *SNetwork) PerformSplit(ctx context.Context, userCred mcclient.TokenC for _, gn := range guestnetworks { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if network.isAddressInRange(addr) { - GuestnetworkManager.TableSpec().Update(gn, func() error { + _, err := GuestnetworkManager.TableSpec().Update(&gn, func() error { gn.NetworkId = network.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1716,10 +1731,13 @@ func (self *SNetwork) PerformSplit(ctx context.Context, userCred mcclient.TokenC for _, gn := range hostnetworks { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if network.isAddressInRange(addr) { - HostnetworkManager.TableSpec().Update(gn, func() error { + _, err = HostnetworkManager.TableSpec().Update(&gn, func() error { gn.NetworkId = network.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1732,10 +1750,13 @@ func (self *SNetwork) PerformSplit(ctx context.Context, userCred mcclient.TokenC for _, gn := range reservedips { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if network.isAddressInRange(addr) { - ReservedipManager.TableSpec().Update(gn, func() error { + _, err = ReservedipManager.TableSpec().Update(&gn, func() error { gn.NetworkId = network.Id return nil }) + if err != nil { + log.Errorln(err) + } } } @@ -1748,10 +1769,13 @@ func (self *SNetwork) PerformSplit(ctx context.Context, userCred mcclient.TokenC for _, gn := range groupnetworks { addr, _ := netutils.NewIPV4Addr(gn.IpAddr) if network.isAddressInRange(addr) { - GroupnetworkManager.TableSpec().Update(gn, func() error { + _, err = GroupnetworkManager.TableSpec().Update(&gn, func() error { gn.NetworkId = network.Id return nil }) + if err != nil { + log.Errorln(err) + } } } diff --git a/pkg/compute/models/snapshots.go b/pkg/compute/models/snapshots.go index d4dc282d83..cdfa96b6be 100644 --- a/pkg/compute/models/snapshots.go +++ b/pkg/compute/models/snapshots.go @@ -40,7 +40,7 @@ type SSnapshot struct { db.SVirtualResourceBase SManagedResourceBase - DiskId string `width:"36" charset:"ascii" nullable:"true" create:"required" key_index:"true" list:"user"` + DiskId string `width:"36" charset:"ascii" nullable:"true" create:"required" list:"user"` StorageId string `width:"36" charset:"ascii" nullable:"true" list:"admin"` CreatedBy string `width:"36" charset:"ascii" nullable:"false" default:"manual" list:"admin"` Location string `charset:"ascii" nullable:"true" list:"admin"` diff --git a/pkg/compute/models/storagecachedimages.go b/pkg/compute/models/storagecachedimages.go index ff48453dec..05f1d58e8f 100644 --- a/pkg/compute/models/storagecachedimages.go +++ b/pkg/compute/models/storagecachedimages.go @@ -53,8 +53,8 @@ func init() { type SStoragecachedimage struct { db.SJointResourceBase - StoragecacheId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required" key_index:"true"` - CachedimageId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required" key_index:"true"` + StoragecacheId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` + CachedimageId string `width:"36" charset:"ascii" nullable:"false" list:"admin" create:"admin_required"` ExternalId string `width:"256" charset:"utf8" nullable:"false" get:"admin"` diff --git a/vendor/yunion.io/x/sqlchemy/column.go b/vendor/yunion.io/x/sqlchemy/column.go index bf3fa35a53..277412a07a 100644 --- a/vendor/yunion.io/x/sqlchemy/column.go +++ b/vendor/yunion.io/x/sqlchemy/column.go @@ -21,7 +21,6 @@ type IColumnSpec interface { IsSupportDefault() bool IsNullable() bool IsPrimary() bool - IsKeyIndex() bool IsUnique() bool IsIndex() bool ExtraDefs() string @@ -50,7 +49,6 @@ type SBaseColumn struct { isPointer bool isNullable bool isPrimary bool - isKeyIndex bool isUnique bool isIndex bool tags map[string]string @@ -92,10 +90,6 @@ func (c *SBaseColumn) IsPrimary() bool { return c.isPrimary } -func (c *SBaseColumn) IsKeyIndex() bool { - return c.isKeyIndex -} - func (c *SBaseColumn) IsUnique() bool { return c.isUnique } @@ -201,11 +195,6 @@ func NewBaseColumn(name string, sqltype string, tagmap map[string]string) SBaseC if ok { isPrimary = utils.ToBool(val) } - isKeyIndex := false - tagmap, val, ok = utils.TagPop(tagmap, TAG_KEY_INDEX) - if ok { - isKeyIndex = utils.ToBool(val) - } isUnique := false tagmap, val, ok = utils.TagPop(tagmap, TAG_UNIQUE) if ok { @@ -226,7 +215,6 @@ func NewBaseColumn(name string, sqltype string, tagmap map[string]string) SBaseC defaultString: defStr, isNullable: isNullable, isPrimary: isPrimary, - isKeyIndex: isKeyIndex, isUnique: isUnique, isIndex: isIndex, tags: tagmap, diff --git a/vendor/yunion.io/x/sqlchemy/const.go b/vendor/yunion.io/x/sqlchemy/const.go index e39de066c9..3bf5293677 100644 --- a/vendor/yunion.io/x/sqlchemy/const.go +++ b/vendor/yunion.io/x/sqlchemy/const.go @@ -31,5 +31,4 @@ const ( TAG_AUTOVERSION = "auto_version" TAG_UPDATE_TIMESTAMP = "updated_at" TAG_CREATE_TIMESTAMP = "created_at" - TAG_KEY_INDEX = "key_index" ) diff --git a/vendor/yunion.io/x/sqlchemy/field_update.go b/vendor/yunion.io/x/sqlchemy/field_update.go index a2e0d8b9d5..28df69bc15 100644 --- a/vendor/yunion.io/x/sqlchemy/field_update.go +++ b/vendor/yunion.io/x/sqlchemy/field_update.go @@ -62,7 +62,6 @@ func (ts *STableSpec) updateFields(dt interface{}, fields map[string]interface{} versionFields := make([]string, 0) updatedFields := make([]string, 0) primaryCols := make(map[string]interface{}, 0) - indexCols := make(map[string]interface{}, 0) for _, col := range ts.Columns() { name := col.Name() colValue, ok := fullFields.GetInterface(name) @@ -72,9 +71,6 @@ func (ts *STableSpec) updateFields(dt interface{}, fields map[string]interface{} if col.IsPrimary() && !col.IsZero(colValue) { primaryCols[name] = colValue continue - } else if col.IsKeyIndex() && !col.IsZero(colValue) { - indexCols[name] = colValue - continue } intCol, ok := col.(*SIntegerColumn) if ok && intCol.IsAutoVersion { @@ -112,16 +108,11 @@ func (ts *STableSpec) updateFields(dt interface{}, fields map[string]interface{} } buf.WriteString(" WHERE ") first = true - var indexFilter map[string]interface{} - if len(primaryCols) > 0 { - indexFilter = primaryCols - } else if len(indexCols) > 0 { - indexFilter = indexCols - } else { - return fmt.Errorf("neither primary key nor key indexes empty???") + if len(primaryCols) == 0 { + return fmt.Errorf("primary key empty???") } - for k, v := range indexFilter { + for k, v := range primaryCols { if first { first = false } else { diff --git a/vendor/yunion.io/x/sqlchemy/update.go b/vendor/yunion.io/x/sqlchemy/update.go index 32ff32e3a4..7dd3b2454e 100644 --- a/vendor/yunion.io/x/sqlchemy/update.go +++ b/vendor/yunion.io/x/sqlchemy/update.go @@ -25,7 +25,6 @@ func (ts *STableSpec) prepareUpdate(dt interface{}) (*SUpdateSession, error) { fields := reflectutils.FetchStructFieldValueSet(dataValue) // fetchStructFieldNameValue(dataType, dataValue) zeroPrimary := make([]string, 0) - zeroKeyIndex := make([]string, 0) for _, c := range ts.columns { k := c.Name() ov, ok := fields.GetInterface(k) @@ -34,14 +33,12 @@ func (ts *STableSpec) prepareUpdate(dt interface{}) (*SUpdateSession, error) { } if c.IsPrimary() && c.IsZero(ov) { zeroPrimary = append(zeroPrimary, k) - } else if c.IsKeyIndex() && c.IsZero(ov) { - zeroKeyIndex = append(zeroKeyIndex, k) } } - if len(zeroPrimary) > 0 && len(zeroKeyIndex) > 0 { - return nil, fmt.Errorf("not a valid data, primary key %s and key index %s are empty", - strings.Join(zeroPrimary, ","), strings.Join(zeroKeyIndex, ",")) + if len(zeroPrimary) > 0 { + return nil, fmt.Errorf("not a valid data, primary key %s empty", + strings.Join(zeroPrimary, ",")) } originValue := gotypes.DeepCopyRv(dataValue) @@ -79,7 +76,6 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er versionFields := make([]string, 0) updatedFields := make([]string, 0) primaries := make(map[string]interface{}) - keyIndexes := make(map[string]interface{}) setters := make(map[string]SUpdateDiff) for _, c := range us.tableSpec.columns { k := c.Name() @@ -89,9 +85,6 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er if c.IsPrimary() && !c.IsZero(of) { // skip update primary key primaries[k] = of continue - } else if c.IsKeyIndex() && !c.IsZero(of) { - keyIndexes[k] = of - continue } } nc, ok := c.(*SIntegerColumn) @@ -142,15 +135,10 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er } buf.WriteString(" WHERE ") first = true - var indexFields map[string]interface{} - if len(primaries) > 0 { - indexFields = primaries - } else if len(keyIndexes) > 0 { - indexFields = keyIndexes - } else { - return nil, fmt.Errorf("neither primary key nor key indexes empty???") + if len(primaries) == 0 { + return nil, fmt.Errorf("primary key empty???") } - for k, v := range indexFields { + for k, v := range primaries { if first { first = false } else {