mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
Merge pull request #1261 from swordqiu/hotfix/qj-update-vendor-20190617
fix: update vendor 20190617
This commit is contained in:
Generated
+2
-2
@@ -1792,11 +1792,11 @@
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:1640ede25f864bdbf1e1c00a5e3884b2184fa1c510f5e7dabcf0294f5f7eb4c2"
|
||||
digest = "1:01f3312e3e5efad1527fa9f65a2c8a23f1b88228b2898d5b695f8223c80147a3"
|
||||
name = "yunion.io/x/sqlchemy"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "54a3c244244554946225edd4d7e1c7043bc46663"
|
||||
revision = "e67c599d9d7a81a1a08738924b74c881ce6a5a57"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
||||
+2
@@ -21,9 +21,11 @@ import (
|
||||
var ErrNoDataToUpdate error
|
||||
var ErrDuplicateEntry error
|
||||
var ErrEmptyQuery error
|
||||
var ErrEmptyPrimaryKey error
|
||||
|
||||
func init() {
|
||||
ErrNoDataToUpdate = errors.New("No data to update")
|
||||
ErrDuplicateEntry = errors.New("duplicate entry")
|
||||
ErrEmptyQuery = errors.New("empty query")
|
||||
ErrEmptyPrimaryKey = errors.New("empty primary keys")
|
||||
}
|
||||
|
||||
+4
@@ -122,6 +122,10 @@ func (t *STableSpec) insertSqlPrep(dataFields reflectutils.SStructFieldValueSet,
|
||||
panic(fmt.Sprintf("multiple auto_increment columns: %q, %q", autoIncField, k))
|
||||
}
|
||||
autoIncField = k
|
||||
} else if c.IsText() {
|
||||
values = append(values, "")
|
||||
names = append(names, fmt.Sprintf("`%s`", k))
|
||||
format = append(format, "?")
|
||||
} else {
|
||||
return "", nil, fmt.Errorf("cannot insert for null primary key %q", k)
|
||||
}
|
||||
|
||||
+11
-1
@@ -101,6 +101,16 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (UpdateDiffs, error) {
|
||||
k := c.Name()
|
||||
of, _ := ofields.GetInterface(k)
|
||||
nf, _ := fields.GetInterface(k)
|
||||
if c.IsPrimary() {
|
||||
if !gotypes.IsNil(of) && !c.IsZero(of) {
|
||||
primaries[k] = of
|
||||
} else if c.IsText() {
|
||||
primaries[k] = ""
|
||||
} else {
|
||||
return nil, ErrEmptyPrimaryKey
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !gotypes.IsNil(of) {
|
||||
if c.IsPrimary() && !c.IsZero(of) { // skip update primary key
|
||||
primaries[k] = of
|
||||
@@ -156,7 +166,7 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (UpdateDiffs, error) {
|
||||
buf.WriteString(" WHERE ")
|
||||
first = true
|
||||
if len(primaries) == 0 {
|
||||
return nil, fmt.Errorf("primary key empty???")
|
||||
return nil, ErrEmptyPrimaryKey
|
||||
}
|
||||
for k, v := range primaries {
|
||||
if first {
|
||||
|
||||
Reference in New Issue
Block a user