Skip to content

Commit

Permalink
Revert "connection: interpolate json.RawMessage as string (go-sql-dri…
Browse files Browse the repository at this point in the history
…ver#1058)"

This reverts commit c4f1976.
  • Loading branch information
bitcoinbarron2 committed Feb 18, 2020
1 parent a266ff9 commit 39baf7c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 38 deletions.
1 change: 0 additions & 1 deletion AUTHORS
Expand Up @@ -13,7 +13,6 @@

Aaron Hopkins <go-sql-driver at die.net>
Achille Roussel <achille.roussel at gmail.com>
Alex Snast <alexsn at fb.com>
Alexey Palazhchenko <alexey.palazhchenko at gmail.com>
Andrew Reid <andrew.reid at tixtrack.com>
Arne Hormann <arnehormann at gmail.com>
Expand Down
9 changes: 0 additions & 9 deletions connection.go
Expand Up @@ -12,7 +12,6 @@ import (
"context"
"database/sql"
"database/sql/driver"
"encoding/json"
"io"
"net"
"strconv"
Expand Down Expand Up @@ -272,14 +271,6 @@ func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (strin
}
buf = append(buf, '\'')
}
case json.RawMessage:
buf = append(buf, '\'')
if mc.status&statusNoBackslashEscapes == 0 {
buf = escapeBytesBackslash(buf, v)
} else {
buf = escapeBytesQuotes(buf, v)
}
buf = append(buf, '\'')
case []byte:
if v == nil {
buf = append(buf, "NULL"...)
Expand Down
28 changes: 0 additions & 28 deletions connection_test.go
Expand Up @@ -11,7 +11,6 @@ package mysql
import (
"context"
"database/sql/driver"
"encoding/json"
"errors"
"net"
"testing"
Expand All @@ -37,33 +36,6 @@ func TestInterpolateParams(t *testing.T) {
}
}

func TestInterpolateParamsJSONRawMessage(t *testing.T) {
mc := &mysqlConn{
buf: newBuffer(nil),
maxAllowedPacket: maxPacketSize,
cfg: &Config{
InterpolateParams: true,
},
}

buf, err := json.Marshal(struct {
Value int `json:"value"`
}{Value: 42})
if err != nil {
t.Errorf("Expected err=nil, got %#v", err)
return
}
q, err := mc.interpolateParams("SELECT ?", []driver.Value{json.RawMessage(buf)})
if err != nil {
t.Errorf("Expected err=nil, got %#v", err)
return
}
expected := `SELECT '{\"value\":42}'`
if q != expected {
t.Errorf("Expected: %q\nGot: %q", expected, q)
}
}

func TestInterpolateParamsTooManyPlaceholders(t *testing.T) {
mc := &mysqlConn{
buf: newBuffer(nil),
Expand Down

0 comments on commit 39baf7c

Please sign in to comment.