Skip to content

Commit

Permalink
Allow nullable JSONB and resolve MySQL regression (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Blattberg committed Apr 13, 2021
1 parent 46cfd45 commit fbf43b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dialect_mysql.go
Expand Up @@ -157,9 +157,10 @@ func (m *mysql) FizzTranslator() fizz.Translator {

func (m *mysql) DumpSchema(w io.Writer) error {
deets := m.Details()
cmd := exec.Command("mysqldump", "-d", "-h", deets.Host, "-P", deets.Port, "-u", deets.User, fmt.Sprintf("--password=%s", deets.Password), deets.Database)
// Github CI is currently using mysql:5.7 but the mysqldump version doesn't seem to match
cmd := exec.Command("mysqldump", "--column-statistics=0", "-d", "-h", deets.Host, "-P", deets.Port, "-u", deets.User, fmt.Sprintf("--password=%s", deets.Password), deets.Database)
if deets.Port == "socket" {
cmd = exec.Command("mysqldump", "-d", "-S", deets.Host, "-u", deets.User, fmt.Sprintf("--password=%s", deets.Password), deets.Database)
cmd = exec.Command("mysqldump", "--column-statistics=0", "-d", "-S", deets.Host, "-u", deets.User, fmt.Sprintf("--password=%s", deets.Password), deets.Database)
}
return genericDumpSchema(deets, cmd, w)
}
Expand Down
2 changes: 2 additions & 0 deletions slices/map.go
Expand Up @@ -19,6 +19,8 @@ func (m Map) Interface() interface{} {
func (m *Map) Scan(src interface{}) error {
var b []byte
switch t := src.(type) {
case nil:
return nil
case []byte:
b = t
case string:
Expand Down
15 changes: 15 additions & 0 deletions slices/map_test.go
Expand Up @@ -35,3 +35,18 @@ func Test_Map_UnMarshalJSON_uninitialized_map_does_not_panic(t *testing.T) {
r.Len(maps, 1)
})
}

func Test_Map_Scan(t *testing.T) {
r := require.New(t)
in := []byte(`{"a":"b"}`)
m := Map{}
r.NoError(m.Scan(in))
r.Equal("b", m["a"])
}

func Test_Map_Null_Scan(t *testing.T) {
r := require.New(t)
m := Map{}
r.NoError(m.Scan(nil))
r.Equal(Map{}, m)
}

0 comments on commit fbf43b4

Please sign in to comment.