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

test(repository): fix setup of relations with custom FK names #3418

Merged
merged 1 commit into from
Jul 23, 2019

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Jul 23, 2019

Because the code infering relation name from FK name supports camelCase only, it's important to explicitly provide the relation name when calling @belongsTo decorator.

This is a follow-up for #3326, fixing a problem discovered while working on #3387

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 👈

Because the code infering relation name from FK name supports camelCase
only, it's important to explicitly provide the relation name when
calling `@belongsTo` decorator.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
@bajtos bajtos added refactor Relations Model relations (has many, etc.) labels Jul 23, 2019
@bajtos bajtos added this to the July 2019 milestone milestone Jul 23, 2019
@bajtos bajtos requested a review from nabdelgadir July 23, 2019 06:44
@bajtos bajtos requested a review from raymondfeng as a code owner July 23, 2019 06:44
@bajtos bajtos self-assigned this Jul 23, 2019
@bajtos
Copy link
Member Author

bajtos commented Jul 23, 2019

Without this fix, the test it can find shipment of order with a custom foreign key name fails with the following error in my spike branch:

 1) BelongsTo relation
       can find shipment of order with a custom foreign key name:
     Error: Navigational properties are not allowed in model data 
            (model "Order" property "shipment_id")
      at OrderRepository.fromEntity (src/repositories/legacy-juggler-bridge.ts:546:17)
      at OrderRepository.create (src/repositories/legacy-juggler-bridge.ts:358:14)
      at Context.<anonymous> (src/__tests__/acceptance/belongs-to.relation.acceptance.ts:52:35)
      at processTicksAndRejections (internal/process/task_queues.js:85:5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Relations Model relations (has many, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants