Skip to content

Commit

Permalink
Merge branch 'main' of github.com:crisismaple/clickhouse-go into tupl…
Browse files Browse the repository at this point in the history
…e_pointer
  • Loading branch information
crisismaple committed May 12, 2023
2 parents 2743c1e + 412b809 commit 152935e
Show file tree
Hide file tree
Showing 141 changed files with 1,892 additions and 758 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ _testmain.go
coverage.txt
.idea/**
dev/*
.run/**
.run/**

vendor
71 changes: 71 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
run:
tests: false
skip-dirs:
- benchmark
- tests
- internal/cmd

linters-settings:
gocritic:
disabled-checks:
- singleCaseSwitch
- commentFormatting

decorder:
dec-order:
- type
- const
- var
- func
disable-dec-order-check: false

revive:
enable-all-rules: true
rules:
- name: cyclomatic
disabled: true
- name: argument-limit
disabled: true
- name: function-length
disabled: true
- name: function-result-limit
disabled: true
- name: line-length-limit
disabled: true
- name: file-header
disabled: true
- name: cognitive-complexity
disabled: true
- name: banned-characters
disabled: true
- name: max-public-structs
disabled: true
- name: add-constant
disabled: true
- name: unhandled-error
disabled: true
- name: deep-exit
disabled: true
- name: nested-structs
disabled: true

gofmt:
rewrite-rules:
- pattern: 'interface{}'
replacement: 'any'
- pattern: 'a[b:len(a)]'
replacement: 'a[b:]'

linters:
disable-all: true
enable:
- asciicheck
- bodyclose
- depguard
- gocritic
- gofmt
- govet
- ineffassign
- importas
- misspell
- staticcheck
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# v2.9.2, 2023-05-08 <!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
### Fixes 🐛
* Pass http.ProxyFromEnvironment configuration to http.Transport by @slvrtrn in https://github.com/ClickHouse/clickhouse-go/pull/987
### Other Changes 🛠
* Use `any` instead of `interface{}` by @candiduslynx in https://github.com/ClickHouse/clickhouse-go/pull/984

## New Contributors
* @candiduslynx made their first contribution in https://github.com/ClickHouse/clickhouse-go/pull/984
* @slvrtrn made their first contribution in https://github.com/ClickHouse/clickhouse-go/pull/987

**Full Changelog**: https://github.com/ClickHouse/clickhouse-go/compare/v2.9.1...v2.9.2

# v2.9.1, 2023-04-24 <!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
### Enhancements 🎉
* Do not return hard error on unparsable version in HTTP proto by @hexchain in https://github.com/ClickHouse/clickhouse-go/pull/975
### Fixes 🐛
* Return ErrBadConn in stdDriver Prepare if connection is broken by @czubocha in https://github.com/ClickHouse/clickhouse-go/pull/977

## New Contributors
* @czubocha made their first contribution in https://github.com/ClickHouse/clickhouse-go/pull/977
* @hexchain made their first contribution in https://github.com/ClickHouse/clickhouse-go/pull/975

**Full Changelog**: https://github.com/ClickHouse/clickhouse-go/compare/v2.9.0...v2.9.1

# v2.9.0, 2023-04-13 <!-- Release notes generated using configuration in .github/release.yml at main -->

## What's Changed
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ test:

lint:
golangci-lint run || :
gocritic check -disable=singleCaseSwitch ./... || :

contributors:
@git log --pretty="%an <%ae>%n%cn <%ce>" | sort -u -t '<' -k 2,2 | LC_ALL=C sort | \
Expand All @@ -27,7 +26,7 @@ staticcheck:
staticcheck ./...

codegen: contributors
@cd lib/column && go run codegen/main.go
@go run lib/column/codegen/main.go
@go-licenser -licensor "ClickHouse, Inc."

.PHONY: contributors
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Support for the ClickHouse protocol advanced features using `Context`:
return d.DialContext(ctx, "tcp", addr)
},
Debug: true,
Debugf: func(format string, v ...interface{}) {
Debugf: func(format string, v ...any) {
fmt.Printf(format, v)
},
Settings: clickhouse.Settings{
Expand Down
22 changes: 11 additions & 11 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
)

func Named(name string, value interface{}) driver.NamedValue {
func Named(name string, value any) driver.NamedValue {
return driver.NamedValue{
Name: name,
Value: value,
Expand All @@ -45,10 +45,10 @@ const (
)

type GroupSet struct {
Value []interface{}
Value []any
}

type ArraySet []interface{}
type ArraySet []any

func DateNamed(name string, value time.Time, scale TimeUnit) driver.NamedDateValue {
return driver.NamedDateValue{
Expand All @@ -61,7 +61,7 @@ func DateNamed(name string, value time.Time, scale TimeUnit) driver.NamedDateVal
var bindNumericRe = regexp.MustCompile(`\$[0-9]+`)
var bindPositionalRe = regexp.MustCompile(`[^\\][?]`)

func bind(tz *time.Location, query string, args ...interface{}) (string, error) {
func bind(tz *time.Location, query string, args ...any) (string, error) {
if len(args) == 0 {
return query, nil
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func bind(tz *time.Location, query string, args ...interface{}) (string, error)
return bindPositional(tz, query, args...)
}

func checkAllNamedArguments(args ...interface{}) (bool, error) {
func checkAllNamedArguments(args ...any) (bool, error) {
var (
haveNamed bool
haveAnonymous bool
Expand All @@ -111,7 +111,7 @@ func checkAllNamedArguments(args ...interface{}) (bool, error) {

var bindPositionCharRe = regexp.MustCompile(`[?]`)

func bindPositional(tz *time.Location, query string, args ...interface{}) (_ string, err error) {
func bindPositional(tz *time.Location, query string, args ...any) (_ string, err error) {
var (
unbind = make(map[int]struct{})
params = make([]string, len(args))
Expand Down Expand Up @@ -146,7 +146,7 @@ func bindPositional(tz *time.Location, query string, args ...interface{}) (_ str
return strings.ReplaceAll(query, "\\?", "?"), nil
}

func bindNumeric(tz *time.Location, query string, args ...interface{}) (_ string, err error) {
func bindNumeric(tz *time.Location, query string, args ...any) (_ string, err error) {
var (
unbind = make(map[string]struct{})
params = make(map[string]string)
Expand Down Expand Up @@ -178,7 +178,7 @@ func bindNumeric(tz *time.Location, query string, args ...interface{}) (_ string

var bindNamedRe = regexp.MustCompile(`@[a-zA-Z0-9\_]+`)

func bindNamed(tz *time.Location, query string, args ...interface{}) (_ string, err error) {
func bindNamed(tz *time.Location, query string, args ...any) (_ string, err error) {
var (
unbind = make(map[string]struct{})
params = make(map[string]string)
Expand Down Expand Up @@ -243,7 +243,7 @@ func formatTime(tz *time.Location, scale TimeUnit, value time.Time) (string, err
return fmt.Sprintf("toDateTime64('%s', %d, '%s')", value.Format(fmt.Sprintf("2006-01-02 15:04:05.%0*d", int(scale*3), 0)), int(scale*3), value.Location().String()), nil
}

func format(tz *time.Location, scale TimeUnit, v interface{}) (string, error) {
func format(tz *time.Location, scale TimeUnit, v any) (string, error) {
quote := func(v string) string {
return "'" + strings.NewReplacer(`\`, `\\`, `'`, `\'`).Replace(v) + "'"
}
Expand Down Expand Up @@ -328,8 +328,8 @@ func join[E any](tz *time.Location, scale TimeUnit, values []E) (string, error)
return strings.Join(items, ", "), nil
}

func rebind(in []std_driver.NamedValue) []interface{} {
args := make([]interface{}, 0, len(in))
func rebind(in []std_driver.NamedValue) []any {
args := make([]any, 0, len(in))
for _, v := range in {
switch {
case len(v.Name) != 0:
Expand Down
Loading

0 comments on commit 152935e

Please sign in to comment.