From 81191dfac859e51d9f804141848148510c505c40 Mon Sep 17 00:00:00 2001 From: jc3wish Date: Mon, 6 May 2019 22:06:13 +0800 Subject: [PATCH 1/3] yml --- .travis.yml | 1 - 1 file changed, 1 deletion(-) 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" From 8850abebd0672c3e0de4a7f27d1cbc6108ff98ee Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 9 May 2019 18:28:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?ck=20DateTime=E7=B1=BB=E5=9E=8B=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=95=B0=E6=8D=AE=20=E6=97=B6=E9=97=B4=E4=B8=8D?= =?UTF-8?q?=E5=AF=B9bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/clickhouse/src/clickhouse.go | 25 ++++++++++++++++++------ plugin/clickhouse/src/clickhouse_test.go | 5 +++-- 2 files changed, 22 insertions(+), 8 deletions(-) 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 From 0f253752626f52c5394269265afe9ac15e32d173 Mon Sep 17 00:00:00 2001 From: zero Date: Thu, 9 May 2019 18:35:42 +0800 Subject: [PATCH 3/3] =?UTF-8?q?ck=20=E8=87=AA=E5=8A=A8=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D=E4=B8=8D=E5=8C=BA=E5=88=86=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/clickhouse/www/clickhouse.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;