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

Support composite foreign keys #90

Merged
merged 19 commits into from
May 24, 2020
Merged

Conversation

phanbaominh
Copy link
Contributor

Summary

  • Add support for composite foreign key (import, export, parsing).
  • An example of the new composite foreign keys syntax for dbml:
    products.(id, name) < order_items.(product_id, product_name).
  • Still support the old syntax: products.id < order_items.product_id.

Issue

Lasting Changes (Technical)

  • Change all parser.pegjs files and exporters to support composite foreign key (in ref section).
  • Endpoint normalized form's fieldId is replaced by fieldIds (array).
  • Endpoint's fieldName, field is replace by fieldNames, fields (array).
  • Change Endpoint#equals.
  • Add error handling for when two endpoints have different number of fields in Ref object.
  • Add buildFieldName to export/utils for building a field names string when exporting.
  • Change (mostly in test files that have foreign keys definition) and add (mostly in referential_actions test files) new test cases .

Checklist

Please check directly on the box once each of these are done

  • Documentation (if necessary)
  • Tests (integration test/unit test)
  • Integration Tests Passed
  • Code Review

@phanbaominh phanbaominh requested a review from phuongduyphan May 12, 2020 02:58
Copy link
Collaborator

@phuongduyphan phuongduyphan left a comment

Choose a reason for hiding this comment

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

Please fix eslint errors first @wingombia .

@phanbaominh
Copy link
Contributor Author

phanbaominh commented May 14, 2020

As I see at all the places in this PR, this is always an array of names.
Suggest changing fieldName to fieldNames instead.

Why we have to divide into 2 cases in order to compare fields here? Can compareFields compare fields with length 1?

Why we need to set this.field = field here?

oops, I forgot to push the latest commits where I fixed these.

Edit: I have pushed the lastest commits that fix the problems stated in your comments.

- Change DBML Parser to properly parse inline_refs fieldNames to array.
- Apply ESlint to previously changed files.
- Change fieldNames in JSON test files to array.
@phanbaominh phanbaominh requested a review from phuongduyphan May 14, 2020 05:04
…parsing fieldNames and a few other minor things
@phanbaominh phanbaominh requested a review from phuongduyphan May 19, 2020 04:04
@phuongduyphan phuongduyphan added the PR: New Feature 🚀 A type of pull request used for changelog categories label May 24, 2020
@phuongduyphan phuongduyphan merged commit 74869b2 into master May 24, 2020
@coderabbitai coderabbitai bot mentioned this pull request Apr 25, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: New Feature 🚀 A type of pull request used for changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants