Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address lint errors #595

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines -98 to +99
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I chose this option over unmarshalling as a bson.M map to maintain the order preservation.

However by using result.Map() the order was already undone, and before this change the key-value pairs were iterated over in hash table order.

If this is now resulting in unexpected ordering changes, we could change the above to use var result bson.M instead and use for key, value := range result { for this loop.

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