diff --git a/.travis.yml b/.travis.yml index 4f17a64c..0fe939ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: go go: - - "1.8" - "1.9" - "1.10" - "1.11" diff --git a/plugin/clickhouse/src/clickhouse.go b/plugin/clickhouse/src/clickhouse.go index 95f539b8..21158557 100644 --- a/plugin/clickhouse/src/clickhouse.go +++ b/plugin/clickhouse/src/clickhouse.go @@ -10,6 +10,7 @@ import ( "strconv" "runtime/debug" "strings" + "time" ) @@ -57,6 +58,17 @@ func (MyConn *MyConn) CheckUri(uri string) error{ return fmt.Errorf("connect") } + var schemaList []string + func(){ + defer func() { + return + }() + schemaList = c.conn.GetSchemaList() + }() + if len(schemaList) == 0{ + c.Close() + return fmt.Errorf("schema count is 0 (not in system)") + } return nil } @@ -453,11 +465,10 @@ func ckDataTypeTransfer(data interface{},fieldName string,toDataType string) (v if data == nil{ v = int16(0) }else{ - s := fmt.Sprint(data) - if s == "0000-00-00"{ + if data.(string) == "0000-00-00"{ v = int16(0) }else{ - v = s + v = data } } break @@ -465,11 +476,13 @@ func ckDataTypeTransfer(data interface{},fieldName string,toDataType string) (v if data == nil{ v = int32(0) }else{ - s := fmt.Sprint(data) - if s == "0000-00-00 00:00:00"{ + if data.(string) == "0000-00-00 00:00:00"{ v = int32(0) }else{ - v = s + //log.Println("DateTime:",time.Now().Format("2006-01-02 15:04:05")) + loc, _ := time.LoadLocation("Local") //重要:获取时区 + theTime, _ := time.ParseInLocation("2006-01-02 15:04:05", data.(string), loc) //使用模板在对应时区转化为time.time类型 + v = theTime.Unix() } } break diff --git a/plugin/clickhouse/src/clickhouse_test.go b/plugin/clickhouse/src/clickhouse_test.go index e232b0b5..87b4cf9f 100644 --- a/plugin/clickhouse/src/clickhouse_test.go +++ b/plugin/clickhouse/src/clickhouse_test.go @@ -106,7 +106,9 @@ func getPluginConn() pluginDriver.ConnFun { func TestCommit(t *testing.T){ conn := getPluginConn() - conn.Insert(pluginTest.GetTestInsertData()) + insertdata := pluginTest.GetTestInsertData() + log.Println("testtimestamp",insertdata.Rows[0]["testtimestamp"]) + conn.Insert(insertdata) //conn.Del(pluginTest.GetTestDeleteData()) //conn.Update(pluginTest.GetTestUpdateData()) _,err2 := conn.Commit() @@ -140,5 +142,4 @@ func TestReConnCommit(t *testing.T){ } } log.Println("success") - } \ No newline at end of file diff --git a/plugin/clickhouse/www/clickhouse.js b/plugin/clickhouse/www/clickhouse.js index 55ffe6dc..46c4aadc 100644 --- a/plugin/clickhouse/www/clickhouse.js +++ b/plugin/clickhouse/www/clickhouse.js @@ -223,7 +223,7 @@ function GetCkTableDesc(schemaName,tableName) { var fieldsMap = {}; $.each($("#TableFieldsContair input"),function(){ - fieldsMap[$(this).val()] = getTableFieldType($(this).val()); + fieldsMap[$(this).val()] = getTableFieldType($(this).val().toLowerCase()); }); var html = ""; @@ -231,7 +231,7 @@ function GetCkTableDesc(schemaName,tableName) { var toField = ""; var isPri = false; - if(fieldsMap.hasOwnProperty(d[i].Name)){ + if(fieldsMap.hasOwnProperty(d[i].Name.toLowerCase())){ toField = d[i].Name; if(fieldsMap[d[i].Name].COLUMN_KEY == "PRI"){ isPri = true;