diff --git a/ch/db.go b/ch/db.go index b1bed78..f1f3eef 100644 --- a/ch/db.go +++ b/ch/db.go @@ -325,6 +325,7 @@ func (db *DB) _query(ctx context.Context, query string) (*blockIter, error) { db.writeQuery(ctx, cn, wr, query) db.writeBlock(ctx, wr, nil) }); err != nil { + db.releaseConn(cn, err) return nil, err } diff --git a/ch/query_select.go b/ch/query_select.go index d01738e..9364067 100644 --- a/ch/query_select.go +++ b/ch/query_select.go @@ -12,11 +12,6 @@ import ( "github.com/uptrace/go-clickhouse/ch/internal" ) -type union struct { - expr string - query *SelectQuery -} - type SelectQuery struct { baseQuery @@ -31,8 +26,12 @@ type SelectQuery struct { limit int offset int final bool + union []union +} - union []union +type union struct { + expr string + query *SelectQuery } var _ Query = (*SelectQuery)(nil) @@ -162,7 +161,7 @@ func (q *SelectQuery) ExcludeColumn(columns ...string) *SelectQuery { return q } -///------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ func (q *SelectQuery) Union(other *SelectQuery) *SelectQuery { return q.addUnion(" UNION ", other) diff --git a/ch/testdata/snapshots/TestQuery-19 b/ch/testdata/snapshots/TestQuery-19 index ca7a15c..ab1d053 100644 --- a/ch/testdata/snapshots/TestQuery-19 +++ b/ch/testdata/snapshots/TestQuery-19 @@ -1 +1 @@ -CREATE TABLE IF NOT EXISTS "my-table_dist" AS "my-table" ON CLUSTER "my-cluster" Engine = Distributed("my-cluster", currentDatabase(), "my-table", rand()) +CREATE TABLE IF NOT EXISTS "my-table_dist" ON CLUSTER "my-cluster" AS "my-table" Engine = Distributed("my-cluster", currentDatabase(), "my-table", rand())