-
Notifications
You must be signed in to change notification settings - Fork 36
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
Relationship labels #50
Conversation
.go-version
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be helpful for users of goenv
config/relationship_label.go
Outdated
}, nil | ||
} | ||
|
||
var labelRegex = regexp.MustCompile(`([\w\._-]+)[\s]+([\w\._-]+)[\s]+:[\s]+([\w._-]+)`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add comments here for the details of the regex
diagram/diagram.go
Outdated
@@ -59,12 +59,13 @@ func (d diagram) Create(result *database.Result) error { | |||
} | |||
|
|||
var constraints []ErdConstraintData | |||
relationshipLabelMap := BuildRelationshipLabelMap(d.config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building the map is O(n)
and we then get (essentially) O(1)
lookup times when finding a constraint later vs doing a O(n)
linear search each time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work - thanks for the contribution 👍🏼
* Support multiple key constraints on a single attribute (#51) * Add unique constraint to key column (#43) * Relationship labels (#50) * Adds relationship label types and parser * Lookup label based on pk and fk names; overrides omitting the label and the constraint label * First full working version * Use a map for faster lookup * Fix example labels * Adds comments for label regex * Adds basic tests for relationship label map * Support multiple key constraints on a single attribute (#51) (#52) * Add unique constraint to key column (#43) --------- Co-authored-by: Dan Goslen <dwgoslen@gmail.com>
Implements #48, though, without supporting the flag in the command line. That seemed like it would be too tedious for a user anyway
I'm considering using a YAML map instead of an array, though it would require using a complex key. I'm open to whichever you prefer
I also plan to refactor the
RelationshipLabels
to become a map for better runtime lookup.