Skip to content

Commit

Permalink
Have ProcessTable tell if it's EAV
Browse files Browse the repository at this point in the history
  • Loading branch information
mpchadwick committed Apr 6, 2019
1 parent 27693ba commit bdc7c6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions src/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,20 @@ func NewConfig(requested string) (*Config, error) {
}


func (c Config) ProcessTable(t string) bool {
func (c Config) ProcessTable(t string) string {
for _, table := range c.Tables {
if (table.Name == t) {
return true
return "table"
}
}

return false
for _, e := range c.Eav {
if (e.Name == t) {
return "eav"
}
}

return ""
}

func (c Config) ProcessColumn(t string, col string) (bool, string) {
Expand Down
10 changes: 6 additions & 4 deletions src/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ func TestNewConfig(t *testing.T) {
func TestProcessTable(t *testing.T) {
c, _ := NewConfig("magento2")

if !c.ProcessTable("admin_user") {
t.Error("Got false want true")
r1 := c.ProcessTable("admin_user")
if r1 != "table" {
t.Errorf("Got %s wanted table", r1)
}

if c.ProcessTable("catalog_product") {
t.Error("Got true want false")
r2 := c.ProcessTable("catalog_product")
if r2 != "" {
t.Errorf("Got %s wanted empty string", r2)
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func (p LineProcessor) ProcessLine(s string) string {

table := stmt.Table.Name.String()

if !p.Config.ProcessTable(table) {
processor := p.Config.ProcessTable(table)

if processor == "" {
return s
}

Expand Down

0 comments on commit bdc7c6c

Please sign in to comment.