diff --git a/src/create_table.go b/src/create_table.go index 4370f26..f695145 100644 --- a/src/create_table.go +++ b/src/create_table.go @@ -5,8 +5,17 @@ import ( "strings" ) +type Column struct { + Name string + Type string +} + +func NewColumn(n string, t string) *Column { + return &Column{Name: n, Type: t} +} + var nextTable = "" -var currentTable []string +var currentTable = make([]*Column, 0) func findNextTable(s string) { if len(nextTable) > 0 { @@ -17,7 +26,8 @@ func findNextTable(s string) { currentTable = nil createTable := stmt.(*sqlparser.CreateTable) for _, col := range createTable.Columns { - currentTable = append(currentTable, col.Name) + column := NewColumn(col.Name, col.Type) + currentTable = append(currentTable, column) } nextTable = "" } else { diff --git a/src/processor.go b/src/processor.go index 17aea1b..9aca370 100644 --- a/src/processor.go +++ b/src/processor.go @@ -48,7 +48,7 @@ func (p LineProcessor) processInsert(s string) string { rows := insert.Rows.(sqlparser.Values) for _, vt := range rows { for i, e := range vt { - column := currentTable[i] + column := currentTable[i].Name if processor == "table" && p.Mode == "anonymize" { result, dataType = p.Config.ProcessColumn(table, column)