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

Custom foreign key name #3326

Merged
merged 2 commits into from
Jul 15, 2019
Merged

Custom foreign key name #3326

merged 2 commits into from
Jul 15, 2019

Conversation

nabdelgadir
Copy link
Contributor

Closes #2169.

  • Added constraint to make sure the foreign key in keyTo actually exists in the target model
  • Added tests to see if custom names (not the standard {ModelName}Id work e.g. with underscores or a completely different name) for the foreign key also work.

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

@nabdelgadir nabdelgadir self-assigned this Jul 9, 2019
@nabdelgadir nabdelgadir requested a review from b-admike July 9, 2019 18:36
@@ -29,7 +29,7 @@ export class AddressRepository extends DefaultCrudRepository<
customerRepositoryGetter: Getter<CustomerRepository>,
) {
super(Address, db);
this.customer = this._createBelongsToAccessorFor(
this.customer = this.createBelongsToAccessorFor(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because of this change, there's no longer coverage for _createBelongsToAccesorFor: https://coveralls.io/builds/24455533/source?filename=packages/repository/src/repositories/legacy-juggler-bridge.ts#L259. Should I revert it?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's deprecated, so not sure what the best course of action should be. For now, we could duplicate the tests for coverage of both until we remove it. @bajtos thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I reverted it so the function is still covered, but I can open another PR if we want to change it to the non-deprecated version.

Copy link
Contributor

@b-admike b-admike left a comment

Choose a reason for hiding this comment

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

Nice 💯 . Please get one more approval before landing.

@nabdelgadir nabdelgadir added the Relations Model relations (has many, etc.) label Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Relations Model relations (has many, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using custom (underscored) keys for Relations : "Cannot read property 'target' of undefined"
3 participants