Skip to content

Commit

Permalink
Merge pull request #13 from jc3wish/v1.1.x
Browse files Browse the repository at this point in the history
V1.1.x
  • Loading branch information
jc3wish authored May 9, 2019
2 parents 45b7bd9 + c5bb6ca commit f7eedb8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: go

go:
- "1.8"
- "1.9"
- "1.10"
- "1.11"
Expand Down
25 changes: 19 additions & 6 deletions plugin/clickhouse/src/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strconv"
"runtime/debug"
"strings"
"time"
)


Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -453,23 +465,24 @@ 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
case "DateTime":
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
Expand Down
5 changes: 3 additions & 2 deletions plugin/clickhouse/src/clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -140,5 +142,4 @@ func TestReConnCommit(t *testing.T){
}
}
log.Println("success")

}
4 changes: 2 additions & 2 deletions plugin/clickhouse/www/clickhouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ 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 = "";
for(i in d){

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;
Expand Down

0 comments on commit f7eedb8

Please sign in to comment.