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

Allow nullable JSONB #639

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
}