mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): vendor update
This commit is contained in:
@@ -89,9 +89,9 @@ require (
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230417123225-5dcde3e4598b
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900
|
||||
yunion.io/x/pkg v1.0.1-0.20230327034731-79f520e7d373
|
||||
yunion.io/x/pkg v1.0.1-0.20230420104238-bbd084afbdfe
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
yunion.io/x/sqlchemy v1.1.2-0.20230326161357-912d44dd66d6
|
||||
yunion.io/x/sqlchemy v1.1.2-0.20230422192549-7a9668176f46
|
||||
yunion.io/x/structarg v0.0.0-20220312084958-9c6c79c7d1c6
|
||||
)
|
||||
|
||||
|
||||
@@ -1204,12 +1204,12 @@ yunion.io/x/pkg v0.0.0-20190620104149-945c25821dbf/go.mod h1:t6rEGG2sQ4J7DhFxSZV
|
||||
yunion.io/x/pkg v0.0.0-20190628082551-f4033ba2ea30/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v0.0.0-20200814072949-4f1b541857d6/go.mod h1:t6rEGG2sQ4J7DhFxSZVOTjNd0YO/KlfWQyK1W4tog+E=
|
||||
yunion.io/x/pkg v1.0.1-0.20220819080140-55b265a8658e/go.mod h1:nYOMflWG1wQC6301rGVglQva9bYbJxHThEJUxRAgMFc=
|
||||
yunion.io/x/pkg v1.0.1-0.20230327034731-79f520e7d373 h1:VdQgvUo6JoOZNsPzRdoFKbD+3tEt4saHRhI/kUf6DeM=
|
||||
yunion.io/x/pkg v1.0.1-0.20230327034731-79f520e7d373/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
|
||||
yunion.io/x/pkg v1.0.1-0.20230420104238-bbd084afbdfe h1:pwjs6kOP3cenRN+Oc2zyJerAhBAn4owaLbzZyLx5/rA=
|
||||
yunion.io/x/pkg v1.0.1-0.20230420104238-bbd084afbdfe/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
|
||||
yunion.io/x/sqlchemy v1.0.1/go.mod h1:FTdwPdGhMgh4E+UFXc9klI1Ok34fMuybTT+jLhOaIjI=
|
||||
yunion.io/x/sqlchemy v1.1.2-0.20230326161357-912d44dd66d6 h1:qs8BU3AH7MsKeWLzuaj2bCc2/VnwyYqzl55VJXS25X4=
|
||||
yunion.io/x/sqlchemy v1.1.2-0.20230326161357-912d44dd66d6/go.mod h1:xXVfJLIxxTRTnPEaVIIoRZXqWyO8+takIOYhc+zO5KE=
|
||||
yunion.io/x/sqlchemy v1.1.2-0.20230422192549-7a9668176f46 h1:M/Xv+Qu6/dSMyuvhgbs52/adr+O5k5NXtpF7czYVCJU=
|
||||
yunion.io/x/sqlchemy v1.1.2-0.20230422192549-7a9668176f46/go.mod h1:xXVfJLIxxTRTnPEaVIIoRZXqWyO8+takIOYhc+zO5KE=
|
||||
yunion.io/x/structarg v0.0.0-20220312084958-9c6c79c7d1c6 h1:WuWXhY3DvhdRTzWCJ/kwt3Ss6KIq7+KqJwb+esvNGwU=
|
||||
yunion.io/x/structarg v0.0.0-20220312084958-9c6c79c7d1c6/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=
|
||||
|
||||
Vendored
+2
-2
@@ -1548,7 +1548,7 @@ yunion.io/x/log/hooks
|
||||
yunion.io/x/ovsdb/cli_util
|
||||
yunion.io/x/ovsdb/schema/ovn_nb
|
||||
yunion.io/x/ovsdb/types
|
||||
# yunion.io/x/pkg v1.0.1-0.20230327034731-79f520e7d373
|
||||
# yunion.io/x/pkg v1.0.1-0.20230420104238-bbd084afbdfe
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/pkg/appctx
|
||||
yunion.io/x/pkg/errors
|
||||
@@ -1603,7 +1603,7 @@ yunion.io/x/pkg/utils
|
||||
# yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
## explicit; go 1.12
|
||||
yunion.io/x/s3cli
|
||||
# yunion.io/x/sqlchemy v1.1.2-0.20230326161357-912d44dd66d6
|
||||
# yunion.io/x/sqlchemy v1.1.2-0.20230422192549-7a9668176f46
|
||||
## explicit; go 1.17
|
||||
yunion.io/x/sqlchemy
|
||||
yunion.io/x/sqlchemy/backends
|
||||
|
||||
+6
@@ -16,6 +16,7 @@ package stringutils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -89,3 +90,8 @@ func SplitKeyValueBySep(line string, sep string) (string, string) {
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
|
||||
func ContainsWord(str, w string) bool {
|
||||
reg := regexp.MustCompile(fmt.Sprintf("\\b%s\\b", w))
|
||||
return reg.MatchString(str)
|
||||
}
|
||||
|
||||
+3
-2
@@ -24,6 +24,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/tristate"
|
||||
"yunion.io/x/pkg/util/stringutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/sqlchemy"
|
||||
@@ -190,7 +191,7 @@ func (click *SClickhouseBackend) FetchTableColumnSpecs(ts sqlchemy.ITableSpec) (
|
||||
clickSpec.SetOrderBy(true)
|
||||
}
|
||||
for _, part := range partitions {
|
||||
if strings.Contains(part, clickSpec.Name()) {
|
||||
if stringutils.ContainsWord(part, clickSpec.Name()) {
|
||||
clickSpec.SetPartitionBy(part)
|
||||
}
|
||||
}
|
||||
@@ -206,7 +207,7 @@ func (click *SClickhouseBackend) FetchTableColumnSpecs(ts sqlchemy.ITableSpec) (
|
||||
func (click *SClickhouseBackend) GetColumnSpecByFieldType(table *sqlchemy.STableSpec, fieldType reflect.Type, fieldname string, tagmap map[string]string, isPointer bool) sqlchemy.IColumnSpec {
|
||||
switch fieldType {
|
||||
case tristate.TriStateType:
|
||||
col := NewTristateColumn(fieldname, tagmap, isPointer)
|
||||
col := NewTristateColumn(table.Name(), fieldname, tagmap, isPointer)
|
||||
return &col
|
||||
case gotypes.TimeType:
|
||||
col := NewDateTimeColumn(fieldname, tagmap, isPointer)
|
||||
|
||||
+1
-1
@@ -240,7 +240,7 @@ func (c *STristateColumn) IsZero(val interface{}) bool {
|
||||
}
|
||||
|
||||
// NewTristateColumn return an instance of STristateColumn
|
||||
func NewTristateColumn(name string, tagmap map[string]string, isPointer bool) STristateColumn {
|
||||
func NewTristateColumn(table, name string, tagmap map[string]string, isPointer bool) STristateColumn {
|
||||
//if _, ok := tagmap[sqlchemy.TAG_NULLABLE]; ok {
|
||||
// tristate always nullable
|
||||
delete(tagmap, sqlchemy.TAG_NULLABLE)
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ func (info *sSqlColumnInfo) getType() string {
|
||||
}
|
||||
|
||||
func (info *sSqlColumnInfo) getDefault() string {
|
||||
if len(info.DefaultExpression) > 0 {
|
||||
if info.DefaultType == "DEFAULT" {
|
||||
if strings.HasPrefix(info.DefaultExpression, "CAST(") {
|
||||
defaultVals := strings.Split(info.DefaultExpression[len("CAST("):len(info.DefaultExpression)-1], ",")
|
||||
defaultVal := defaultVals[0]
|
||||
|
||||
+18
-3
@@ -23,6 +23,7 @@ import (
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/sortedstring"
|
||||
"yunion.io/x/pkg/util/stringutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
)
|
||||
@@ -60,6 +61,15 @@ func findPartitions(cols []sqlchemy.IColumnSpec) []string {
|
||||
return parts
|
||||
}
|
||||
|
||||
func arrayContainsWord(strs []string, word string) bool {
|
||||
for _, str := range strs {
|
||||
if stringutils.ContainsWord(str, word) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (clickhouse *SClickhouseBackend) CommitTableChangeSQL(ts sqlchemy.ITableSpec, changes sqlchemy.STableChanges) []string {
|
||||
ret := make([]string, 0)
|
||||
|
||||
@@ -119,9 +129,15 @@ func (clickhouse *SClickhouseBackend) CommitTableChangeSQL(ts sqlchemy.ITableSpe
|
||||
log.Errorf("column %s is not nullable but no default, drop not nullable attribute", col.Name())
|
||||
}
|
||||
}
|
||||
|
||||
oldPartitions := findPartitions(changes.OldColumns)
|
||||
for _, cols := range changes.UpdatedColumns {
|
||||
sql := fmt.Sprintf("MODIFY COLUMN %s", cols.NewCol.DefinitionString())
|
||||
alters = append(alters, sql)
|
||||
if cols.OldCol.IsNullable() && !cols.NewCol.IsNullable() && arrayContainsWord(oldPartitions, cols.NewCol.Name()) {
|
||||
needCopyTable = true
|
||||
} else {
|
||||
sql := fmt.Sprintf("MODIFY COLUMN %s", cols.NewCol.DefinitionString())
|
||||
alters = append(alters, sql)
|
||||
}
|
||||
}
|
||||
for _, col := range changes.AddColumns {
|
||||
sql := fmt.Sprintf("ADD COLUMN %s", col.DefinitionString())
|
||||
@@ -162,7 +178,6 @@ func (clickhouse *SClickhouseBackend) CommitTableChangeSQL(ts sqlchemy.ITableSpe
|
||||
}
|
||||
|
||||
// check partitions
|
||||
oldPartitions := findPartitions(changes.OldColumns)
|
||||
newPartitions := findPartitions(ts.Columns())
|
||||
if !sortedstring.Equals(oldPartitions, newPartitions) {
|
||||
log.Infof("partition inconsistemt: old=%s new=%s", oldPartitions, newPartitions)
|
||||
|
||||
+2
-2
@@ -168,12 +168,12 @@ func (c *STristateColumn) IsZero(val interface{}) bool {
|
||||
}
|
||||
|
||||
// NewTristateColumn return an instance of STristateColumn
|
||||
func NewTristateColumn(name string, tagmap map[string]string, isPointer bool) STristateColumn {
|
||||
func NewTristateColumn(table, name string, tagmap map[string]string, isPointer bool) STristateColumn {
|
||||
if _, ok := tagmap[sqlchemy.TAG_NULLABLE]; ok {
|
||||
// simply warning, for backward compatiblity reason
|
||||
// tristate always nullable
|
||||
// delete(tagmap, sqlchemy.TAG_NULLABLE)
|
||||
log.Warningf("TristateColumn %s should have no nullable tag", name)
|
||||
log.Warningf("%s TristateColumn %s should have no nullable tag", table, name)
|
||||
}
|
||||
bc := STristateColumn{SBaseWidthColumn: sqlchemy.NewBaseWidthColumn(name, "TINYINT", tagmap, isPointer)}
|
||||
return bc
|
||||
|
||||
+1
-1
@@ -156,7 +156,7 @@ func (mysql *SMySQLBackend) GetColumnSpecByFieldType(table *sqlchemy.STableSpec,
|
||||
switch fieldType {
|
||||
case tristate.TriStateType:
|
||||
tagmap[sqlchemy.TAG_WIDTH] = "1"
|
||||
col := NewTristateColumn(fieldname, tagmap, isPointer)
|
||||
col := NewTristateColumn(table.Name(), fieldname, tagmap, isPointer)
|
||||
return &col
|
||||
case gotypes.TimeType:
|
||||
col := NewDateTimeColumn(fieldname, tagmap, isPointer)
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@ func (c *STristateColumn) IsZero(val interface{}) bool {
|
||||
}
|
||||
|
||||
// NewTristateColumn return an instance of STristateColumn
|
||||
func NewTristateColumn(name string, tagmap map[string]string, isPointer bool) STristateColumn {
|
||||
func NewTristateColumn(table, name string, tagmap map[string]string, isPointer bool) STristateColumn {
|
||||
if _, ok := tagmap[sqlchemy.TAG_NULLABLE]; ok {
|
||||
// tristate always nullable
|
||||
delete(tagmap, sqlchemy.TAG_NULLABLE)
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ func (sqlite *SSqliteBackend) FetchTableColumnSpecs(ts sqlchemy.ITableSpec) ([]s
|
||||
func (sqlite *SSqliteBackend) GetColumnSpecByFieldType(table *sqlchemy.STableSpec, fieldType reflect.Type, fieldname string, tagmap map[string]string, isPointer bool) sqlchemy.IColumnSpec {
|
||||
switch fieldType {
|
||||
case tristate.TriStateType:
|
||||
col := NewTristateColumn(fieldname, tagmap, isPointer)
|
||||
col := NewTristateColumn(table.Name(), fieldname, tagmap, isPointer)
|
||||
return &col
|
||||
case gotypes.TimeType:
|
||||
col := NewDateTimeColumn(fieldname, tagmap, isPointer)
|
||||
|
||||
Reference in New Issue
Block a user