Skip to content

Commit

Permalink
Address lint errors
Browse files Browse the repository at this point in the history
- Remove unused config functions (these were moved to `filter.go` in
  1bed38d)
- Use entries of mongodb bson.D result directly instead of using the
  deprecated Map method.
- Don't ignore err results from utility functions.
  • Loading branch information
mjpieters committed Jun 19, 2024
1 parent 20ece3a commit cdee9c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 53 deletions.
52 changes: 0 additions & 52 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,47 +550,6 @@ func (c *Config) mergeDictFromSchema(s *schema.Schema) {
}
}

func excludeTableFromSchema(name string, s *schema.Schema) error {
// Tables
tables := []*schema.Table{}
for _, t := range s.Tables {
if t.Name != name {
tables = append(tables, t)
}
for _, c := range t.Columns {
// ChildRelations
childRelations := []*schema.Relation{}
for _, r := range c.ChildRelations {
if r.Table.Name != name && r.ParentTable.Name != name {
childRelations = append(childRelations, r)
}
}
c.ChildRelations = childRelations

// ParentRelations
parentRelations := []*schema.Relation{}
for _, r := range c.ParentRelations {
if r.Table.Name != name && r.ParentTable.Name != name {
parentRelations = append(parentRelations, r)
}
}
c.ParentRelations = parentRelations
}
}
s.Tables = tables

// Relations
relations := []*schema.Relation{}
for _, r := range s.Relations {
if r.Table.Name != name && r.ParentTable.Name != name {
relations = append(relations, r)
}
}
s.Relations = relations

return nil
}

// MaskedDSN return DSN mask password
func (c *Config) MaskedDSN() (string, error) {
u, err := url.Parse(c.DSN.URL)
Expand Down Expand Up @@ -905,17 +864,6 @@ func detectPKFK(s *schema.Schema) error {
return nil
}

func matchLabels(il []string, l schema.Labels) bool {
for _, ll := range l {
for _, ill := range il {
if wildcard.MatchSimple(ill, ll.Name) {
return true
}
}
}
return false
}

func match(s []string, e string) bool {
_, m := matchLength(s, e)
return m
Expand Down
3 changes: 2 additions & 1 deletion drivers/mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func (d *Mongodb) listFields(collection *mongo.Collection) ([]*schema.Column, er
return columns, err
}
total += 1
for key, value := range result.Map() {
for _, entry := range result {
key, value := entry.Key, entry.Value
var valueType string
switch value.(type) {
case string:
Expand Down
3 changes: 3 additions & 0 deletions drivers/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ WHERE t.table_schema = ?
})
for _, r := range relations {
strColumns, strParentTable, strParentColumns, err := parseFK(r.Def)
if err != nil {
return err
}
for _, c := range strColumns {
column, err := r.Table.FindColumnByName(c)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions drivers/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,9 @@ SELECT name, sql FROM sqlite_master WHERE type = 'trigger' AND tbl_name = ?;
// Relations
for _, r := range relations {
strColumns, strParentTable, strParentColumns, err := parseFK(r.Def)
if err != nil {
return err
}
for _, c := range strColumns {
column, err := r.Table.FindColumnByName(c)
if err != nil {
Expand Down

0 comments on commit cdee9c7

Please sign in to comment.