Skip to content

Commit

Permalink
Merge e03f200 into e270604
Browse files Browse the repository at this point in the history
  • Loading branch information
im-kulikov committed Feb 24, 2018
2 parents e270604 + e03f200 commit 32c4522
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package clickhouse

import (
"database/sql"
"database/sql/driver"
"os"
"reflect"
"sync"
"time"

"database/sql/driver"
"github.com/stretchr/testify/suite"
)

Expand Down Expand Up @@ -84,7 +84,7 @@ func (d *dbInit) Do(conn *sql.DB) error {
}

func scanValues(rows *sql.Rows, template []interface{}) (interface{}, error) {
result := [][]interface{}{}
var result [][]interface{}
types := make([]reflect.Type, len(template))
for i, v := range template {
types[i] = reflect.TypeOf(v)
Expand Down
3 changes: 1 addition & 2 deletions config_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package clickhouse

import (
"time"

"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down
5 changes: 2 additions & 3 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package clickhouse
import (
"database/sql"
"database/sql/driver"

"net/http"
"testing"
"time"

"github.com/stretchr/testify/suite"
"net/http"
"time"
)

var (
Expand Down
10 changes: 5 additions & 5 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ func (d *textDecoder) Decode(t string, value []byte) (driver.Value, error) {
v := string(value)
switch t {
case "Date":
return time.ParseInLocation(dateFormat, unqoute(v), d.location)
return time.ParseInLocation(dateFormat, unquote(v), d.location)
case "DateTime":
return time.ParseInLocation(timeFormat, unqoute(v), d.location)
return time.ParseInLocation(timeFormat, unquote(v), d.location)
case "UInt8":
vv, err := strconv.ParseUint(v, 10, 8)
return uint8(vv), err
Expand Down Expand Up @@ -128,10 +128,10 @@ func (d *textDecoder) Decode(t string, value []byte) (driver.Value, error) {
case "Float64":
return strconv.ParseFloat(v, 64)
case "String":
return unescape(unqoute(v)), nil
return unescape(unquote(v)), nil
}
if strings.HasPrefix(t, "FixedString") {
return unescape(unqoute(v)), nil
return unescape(unquote(v)), nil
}
if strings.HasPrefix(t, "Array") {
if len(v) > 0 && v[0] == '[' && v[len(value)-1] == ']' {
Expand All @@ -150,7 +150,7 @@ func (d *textDecoder) Decode(t string, value []byte) (driver.Value, error) {
return nil, ErrMalformed
}
if strings.HasPrefix(t, "Enum") {
return unqoute(v), nil
return unquote(v), nil
}
return value, nil
}
3 changes: 1 addition & 2 deletions encoder_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package clickhouse

import (
"time"

"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func quote(s string) string {
return "'" + s + "'"
}

func unqoute(s string) string {
func unquote(s string) string {
if len(s) > 0 && s[0] == '\'' && s[len(s)-1] == '\'' {
return s[1 : len(s)-1]
}
Expand Down
3 changes: 1 addition & 2 deletions helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ package clickhouse

import (
"reflect"
"time"

"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down
1 change: 0 additions & 1 deletion interpolate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clickhouse

import (
"database/sql/driver"

"testing"

"github.com/stretchr/testify/assert"
Expand Down
3 changes: 1 addition & 2 deletions rows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"database/sql/driver"
"io"
"reflect"
"time"

"testing"
"time"

"github.com/stretchr/testify/assert"
)
Expand Down
1 change: 0 additions & 1 deletion stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package clickhouse

import (
"database/sql/driver"

"testing"

"github.com/stretchr/testify/suite"
Expand Down
5 changes: 2 additions & 3 deletions types_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package clickhouse

import (
"time"

"database/sql/driver"
"testing"
"time"

"database/sql/driver"
"github.com/stretchr/testify/assert"
)

Expand Down

0 comments on commit 32c4522

Please sign in to comment.