Skip to content

Commit

Permalink
Merge pull request #13 from nathanwar/master
Browse files Browse the repository at this point in the history
Update mysql.go to fix case-sensitivity issue with map keys
  • Loading branch information
hgfischer committed Oct 2, 2017
2 parents 8acad34 + 743ed85 commit b046cce
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dumper/mysql.go
Expand Up @@ -95,7 +95,7 @@ func (d *mySQL) GetColumnsForSelect(table string) (columns []string, err error)
return
}
for k, column := range columns {
replacement, ok := d.SelectMap[table][column]
replacement, ok := d.SelectMap[strings.ToLower(table)][strings.ToLower(column)]
if ok {
columns[k] = fmt.Sprintf("%s AS `%s`", replacement, column)
} else {
Expand All @@ -112,7 +112,7 @@ func (d *mySQL) GetSelectQueryFor(table string) (query string, err error) {
return "", err
}
query = fmt.Sprintf("SELECT %s FROM `%s`", strings.Join(cols, ", "), table)
if where, ok := d.WhereMap[table]; ok {
if where, ok := d.WhereMap[strings.ToLower(table)]; ok {
query = fmt.Sprintf("%s WHERE %s", query, where)
}
return
Expand All @@ -121,7 +121,7 @@ func (d *mySQL) GetSelectQueryFor(table string) (query string, err error) {
// Get the number of rows the select will return
func (d *mySQL) GetRowCount(table string) (count uint64, err error) {
query := fmt.Sprintf("SELECT COUNT(*) FROM `%s`", table)
if where, ok := d.WhereMap[table]; ok {
if where, ok := d.WhereMap[strings.ToLower(table)]; ok {
query = fmt.Sprintf("%s WHERE %s", query, where)
}
row := d.DB.QueryRow(query)
Expand Down Expand Up @@ -218,10 +218,10 @@ func (d *mySQL) Dump(w io.Writer) (err error) {
if err != nil {
return
}

for _, table := range tables {
if d.FilterMap[table] != "ignore" {
skipData := d.FilterMap[table] == "nodata"
if d.FilterMap[strings.ToLower(table)] != "ignore" {
skipData := d.FilterMap[strings.ToLower(table)] == "nodata"
if !skipData && d.UseTableLock {
d.LockTableReading(table)
d.FlushTable(table)
Expand Down

0 comments on commit b046cce

Please sign in to comment.