Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mysql): bump github.com/go-sql-driver/mysql from 1.7.1 to 1.8.1 #11

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ jobs:
check-latest: true
- run: go version
- run: go mod download
- name: disable ipv6
run: |
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
- name: Run tests
run: |
FORCE_RUN_INTEGRATION_TESTS=true make test exclude="${{ matrix.exclude }}" package=${{ matrix.package }}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/databricks/databricks-sql-go v1.5.5
github.com/dlclark/regexp2 v1.11.0
github.com/gliderlabs/ssh v0.3.7
github.com/go-sql-driver/mysql v1.7.1
github.com/go-sql-driver/mysql v1.8.1
github.com/google/uuid v1.6.0
github.com/lib/pq v1.10.9
github.com/ory/dockertest/v3 v3.10.0
Expand All @@ -40,6 +40,7 @@ require (
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.7 // indirect
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ cloud.google.com/go/storage v1.40.0 h1:VEpDQV5CJxFmJ6ueWNsKxcr1QAYOXEgxDa+sBbJah
cloud.google.com/go/storage v1.40.0/go.mod h1:Rrj7/hKlG87BLqDJYtwR0fbPld8uJPbQ2ucUMY7Ir0g=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
github.com/99designs/keyring v1.2.2 h1:pZd3neh/EmUzWONb35LxQfvuY7kiSXAq3HQd97+XBn0=
Expand Down Expand Up @@ -161,8 +163,8 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
Expand Down
34 changes: 33 additions & 1 deletion sqlconnect/internal/mysql/legacy_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
Expand All @@ -13,8 +14,9 @@
return nil
}
databaseTypeName = strings.Replace(databaseTypeName, "UNSIGNED ", "", 1)

switch databaseTypeName {
case "CHAR", "VARCHAR", "BLOB", "TEXT", "TINYBLOB", "TINYTEXT", "MEDIUMBLOB", "MEDIUMTEXT", "LONGBLOB", "LONGTEXT", "ENUM":
case "CHAR", "VARCHAR", "BLOB", "TEXT", "TINYBLOB", "TINYTEXT", "MEDIUMBLOB", "MEDIUMTEXT", "LONGBLOB", "LONGTEXT", "ENUM", "SET":
switch v := value.(type) {
case []uint8:
return string(v)
Expand All @@ -23,6 +25,8 @@
}
case "DATE", "DATETIME", "TIMESTAMP", "TIME", "YEAR":
switch v := value.(type) {
case int, int32, int64, uint32, uint64:
return fmt.Sprintf("%d", v)
case []uint8:
return string(v)
default:
Expand All @@ -31,6 +35,18 @@

case "FLOAT", "DOUBLE", "DECIMAL":
switch v := value.(type) {
case int, int32, int64, uint32, uint64:
n, err := strconv.ParseFloat(fmt.Sprintf("%d", v), 64)
if err != nil {
panic(err)

Check warning on line 41 in sqlconnect/internal/mysql/legacy_mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/legacy_mappings.go#L38-L41

Added lines #L38 - L41 were not covered by tests
}
return n

Check warning on line 43 in sqlconnect/internal/mysql/legacy_mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/legacy_mappings.go#L43

Added line #L43 was not covered by tests
case float32, float64:
n, err := strconv.ParseFloat(fmt.Sprintf("%f", v), 64)
if err != nil {
panic(err)

Check warning on line 47 in sqlconnect/internal/mysql/legacy_mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/legacy_mappings.go#L47

Added line #L47 was not covered by tests
}
return n
case []uint8:
n, err := strconv.ParseFloat(string(v), 64)
if err != nil {
Expand All @@ -46,6 +62,12 @@
}
case "INT", "TINYINT", "SMALLINt", "MEDIUMINT", "BIGINT", "UNSIGNED BIGINT":
switch v := value.(type) {
case int, int32, int64, uint32, uint64:
n, err := strconv.ParseInt(fmt.Sprintf("%d", v), 10, 64)
if err != nil {
panic(err)

Check warning on line 68 in sqlconnect/internal/mysql/legacy_mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/legacy_mappings.go#L68

Added line #L68 was not covered by tests
}
return n
case []uint8:
n, err := strconv.ParseInt(string(v), 10, 64)
if err != nil {
Expand All @@ -59,6 +81,16 @@
}
return n
}
case "SMALLINT":
switch v := value.(type) {
case int, int32, int64, uint32, uint64:
// converting to []byte to be backwards compatible
return []byte(fmt.Sprintf("%d", v))
case float32, float64:

Check warning on line 89 in sqlconnect/internal/mysql/legacy_mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/legacy_mappings.go#L89

Added line #L89 was not covered by tests
// converting to []byte to be backwards compatible
return []byte(fmt.Sprintf("%f", v))

Check warning on line 91 in sqlconnect/internal/mysql/legacy_mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/legacy_mappings.go#L91

Added line #L91 was not covered by tests
}

}

return value
Expand Down
13 changes: 13 additions & 0 deletions sqlconnect/internal/mysql/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import (
"encoding/binary"
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -70,6 +71,12 @@
stringValue = v.String()
case string:
stringValue = v
case int, int32, int64, uint32, uint64:
stringValue = fmt.Sprintf("%d", v)
case float32, float64:
stringValue = fmt.Sprintf("%f", v)
default:
return value

Check warning on line 79 in sqlconnect/internal/mysql/mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/mappings.go#L78-L79

Added lines #L78 - L79 were not covered by tests
}

switch databaseTypeName {
Expand Down Expand Up @@ -100,12 +107,18 @@
case "JSON":
return json.RawMessage(stringValue)
case "FLOAT", "DOUBLE", "DECIMAL":
if stringValue == "" {
return nil

Check warning on line 111 in sqlconnect/internal/mysql/mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/mappings.go#L111

Added line #L111 was not covered by tests
}
n, err := strconv.ParseFloat(stringValue, 64)
if err != nil {
panic(err)
}
return n
case "INT", "TINYINT", "SMALLINT", "MEDIUMINT", "BIGINT":
if stringValue == "" {
return nil

Check warning on line 120 in sqlconnect/internal/mysql/mappings.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/mysql/mappings.go#L120

Added line #L120 was not covered by tests
}
n, err := strconv.ParseInt(stringValue, 10, 64)
if err != nil {
panic(err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"_tinytext": "TEXT",
"_mediumtext": "TEXT",
"_longtext": "TEXT",
"_enum": "CHAR",
"_set": "CHAR",
"_enum": "ENUM",
"_set": "SET",
"_date": "DATE",
"_datetime": "DATETIME",
"_timestamp": "TIMESTAMP",
Expand Down
21 changes: 21 additions & 0 deletions sqlconnect/internal/sshtunnel/tcp_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"fmt"
"net"
"strconv"
"time"

"github.com/rudderlabs/sql-tunnels/tunnel"
)
Expand All @@ -24,10 +25,30 @@
RemoteHost: remoteHost,
RemotePort: remotePort,
}

t, err := tunnel.ListenAndForward(&tunnelConfig)
if err != nil {
return nil, fmt.Errorf("creating ssh tunnel: %w", err)
}

// Wait for the tunnel to be ready (go routine)
var (
established bool
retries int
)
for !established && retries < 10 {
con, err := net.Dial("tcp", t.Addr())
if con != nil {
_ = con.Close()
}
if err != nil {
retries++
time.Sleep(10 * time.Millisecond)
continue

Check warning on line 47 in sqlconnect/internal/sshtunnel/tcp_tunnel.go

View check run for this annotation

Codecov / codecov/patch

sqlconnect/internal/sshtunnel/tcp_tunnel.go#L45-L47

Added lines #L45 - L47 were not covered by tests
}
established = true
}

return &tcpTunnel{t}, nil
}

Expand Down