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

Relationship labels #50

Merged
merged 7 commits into from
Nov 1, 2023
Merged

Conversation

dangoslen
Copy link
Contributor

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.

.go-version Outdated
Copy link
Contributor Author

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

}, nil
}

var labelRegex = regexp.MustCompile(`([\w\._-]+)[\s]+([\w\._-]+)[\s]+:[\s]+([\w._-]+)`)
Copy link
Contributor Author

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

@dangoslen dangoslen marked this pull request as ready for review September 30, 2023 22:45
@@ -59,12 +59,13 @@ func (d diagram) Create(result *database.Result) error {
}

var constraints []ErdConstraintData
relationshipLabelMap := BuildRelationshipLabelMap(d.config)
Copy link
Contributor Author

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

Copy link
Owner

@KarnerTh KarnerTh left a 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 👍🏼

@KarnerTh KarnerTh merged commit d96ab90 into KarnerTh:master Nov 1, 2023
KarnerTh pushed a commit that referenced this pull request Nov 18, 2023
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants