Skip to content

Commit

Permalink
Begin positioning for column length validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mpchadwick committed Nov 12, 2020
1 parent 4b8f18f commit e7c8a72
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e7c8a72

Please sign in to comment.