From 4c9bab26d2edff16ce31be647a6e551cf5418695 Mon Sep 17 00:00:00 2001 From: Artem Klyukvin Date: Tue, 24 Jul 2018 12:12:02 +0300 Subject: [PATCH 1/2] Revert "Merge pull request #22 from azaikin/query-url" This reverts commit 1d0076b2e74b0057628a7bb22a0113fb0cabfc05, reversing changes made to 7cb83a2242fff54a3629866bdab9479eef95cd76. --- conn.go | 16 ++++++---------- conn_test.go | 2 +- errors.go | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/conn.go b/conn.go index 9870127..e1d3478 100644 --- a/conn.go +++ b/conn.go @@ -213,25 +213,21 @@ func (c *conn) doRequest(ctx context.Context, req *http.Request) ([]byte, error) func (c *conn) buildRequest(query string, params []driver.Value, readonly bool) (*http.Request, error) { var ( - req *http.Request - err error + method string + err error ) if params != nil { if query, err = interpolateParams(query, params); err != nil { return nil, err } } - c.log("query: ", query) if readonly { - u := *c.url - q := u.Query() - q.Set("query", query) - u.RawQuery = q.Encode() - req, err = http.NewRequest(http.MethodGet, u.String(), nil) + method = http.MethodGet } else { - req, err = http.NewRequest(http.MethodPost, c.url.String(), strings.NewReader(query)) + method = http.MethodPost } - + c.log("query: ", query) + req, err := http.NewRequest(method, c.url.String(), strings.NewReader(query)) // http.Transport ignores url.User argument, handle it here if err == nil && c.user != nil { p, _ := c.user.Password() diff --git a/conn_test.go b/conn_test.go index 6e39ef8..f275a63 100644 --- a/conn_test.go +++ b/conn_test.go @@ -159,7 +159,7 @@ func (s *connSuite) TestBuildRequestReadonlyWithAuth() { s.Equal("user", user) s.Equal("password", password) s.Equal(http.MethodGet, req.Method) - s.Equal(cn.url.String()+"&query=SELECT+1", req.URL.String()) + s.Equal(cn.url.String(), req.URL.String()) s.Nil(req.URL.User) } } diff --git a/errors.go b/errors.go index 4399478..d65708f 100644 --- a/errors.go +++ b/errors.go @@ -16,7 +16,7 @@ var ( ErrNoRowsAffected = errors.New("no RowsAffected available") ) -var errorRe = regexp.MustCompile(`(?s)Code: (\d+),.+DB::Exception: (.+),.*`) +var errorRe = regexp.MustCompile(`Code: (\d+),.+DB::Exception: (.+),.*`) // Error contains parsed information about server error type Error struct { From 3ab0ae5b0589c2db70637092263a1836f1a2e921 Mon Sep 17 00:00:00 2001 From: Artem Klyukvin Date: Tue, 24 Jul 2018 12:34:18 +0300 Subject: [PATCH 2/2] add space to the start of the error regexp --- errors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/errors.go b/errors.go index d65708f..4399478 100644 --- a/errors.go +++ b/errors.go @@ -16,7 +16,7 @@ var ( ErrNoRowsAffected = errors.New("no RowsAffected available") ) -var errorRe = regexp.MustCompile(`Code: (\d+),.+DB::Exception: (.+),.*`) +var errorRe = regexp.MustCompile(`(?s)Code: (\d+),.+DB::Exception: (.+),.*`) // Error contains parsed information about server error type Error struct {