Fix tests
This commit is contained in:
parent
8dab834a3b
commit
56882c3b14
|
@ -995,7 +995,6 @@ WHERE c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.att
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// fmt.Println(args, colName, isNullable, dataType, maxLenStr, colDefault, isPK, isUnique)
|
|
||||||
var maxLen int
|
var maxLen int
|
||||||
if maxLenStr != nil {
|
if maxLenStr != nil {
|
||||||
maxLen, err = strconv.Atoi(*maxLenStr)
|
maxLen, err = strconv.Atoi(*maxLenStr)
|
||||||
|
@ -1007,7 +1006,22 @@ WHERE c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.att
|
||||||
col.Name = strings.Trim(colName, `" `)
|
col.Name = strings.Trim(colName, `" `)
|
||||||
|
|
||||||
if colDefault != nil {
|
if colDefault != nil {
|
||||||
col.Default = *colDefault
|
var theDefault = *colDefault
|
||||||
|
// cockroach has type with the default value with :::
|
||||||
|
// and postgres with ::, we should remove them before store them
|
||||||
|
idx := strings.Index(theDefault, ":::")
|
||||||
|
if idx == -1 {
|
||||||
|
idx = strings.Index(theDefault, "::")
|
||||||
|
}
|
||||||
|
if idx > -1 {
|
||||||
|
theDefault = theDefault[:idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasSuffix(theDefault, "+00:00'") {
|
||||||
|
theDefault = theDefault[:len(theDefault)-7] + "'"
|
||||||
|
}
|
||||||
|
|
||||||
|
col.Default = theDefault
|
||||||
col.DefaultIsEmpty = false
|
col.DefaultIsEmpty = false
|
||||||
if strings.HasPrefix(col.Default, "nextval(") {
|
if strings.HasPrefix(col.Default, "nextval(") {
|
||||||
col.IsAutoIncrement = true
|
col.IsAutoIncrement = true
|
||||||
|
|
|
@ -1031,6 +1031,7 @@ func TestTagDefault4(t *testing.T) {
|
||||||
}
|
}
|
||||||
assert.True(t, isDefaultExist)
|
assert.True(t, isDefaultExist)
|
||||||
assert.True(t, "CURRENT_TIMESTAMP" == defaultVal ||
|
assert.True(t, "CURRENT_TIMESTAMP" == defaultVal ||
|
||||||
|
"current_timestamp()" == defaultVal || // for cockroach
|
||||||
"now()" == defaultVal ||
|
"now()" == defaultVal ||
|
||||||
"getdate" == defaultVal, defaultVal)
|
"getdate" == defaultVal, defaultVal)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue