mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.6.0 -> master
* commit 'b0a0ae12b89a935bd5a5ae1044ae9ec2968630bf': remove key index
This commit is contained in:
Generated
+2
-2
@@ -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"
|
||||
|
||||
@@ -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"`
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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"`
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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"`
|
||||
|
||||
|
||||
-12
@@ -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,
|
||||
|
||||
-1
@@ -31,5 +31,4 @@ const (
|
||||
TAG_AUTOVERSION = "auto_version"
|
||||
TAG_UPDATE_TIMESTAMP = "updated_at"
|
||||
TAG_CREATE_TIMESTAMP = "created_at"
|
||||
TAG_KEY_INDEX = "key_index"
|
||||
)
|
||||
|
||||
+3
-12
@@ -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 {
|
||||
|
||||
+6
-18
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user