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

[Bug] Null ID when referencing another fixture #202

Open
tylergets opened this issue Oct 27, 2022 · 1 comment
Open

[Bug] Null ID when referencing another fixture #202

tylergets opened this issue Oct 27, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@tylergets
Copy link

tylergets commented Oct 27, 2022

Hey there, I am having issues with the latest version of this library.

When I try and create a new instance of a child model, it is not receiving the ID of the referenced fixture. This results in the entity failing to save because of constraints.

For example:

error: Error: null value in column "locationId" violates not-null constraint

Here are my fixtures

entity: Location
items:
  location1:
    name: '{{company.name}}'
    tenant: 'd1a5fcf3-08f6-4035-a766-6c7c9733c39a'
    flags: '[]'

and

entity: Role
items:
  role1:
    name: '{{company.name}}'
    location: '@location1'

In this scenario, location is defined as a ManyToOne lazy relationship on Role. Tenat is also a ManyToOne which I hardcoded and works as expected.

Postgres returns this error

 messageDetail: 'Failing row contains (d353769e-e96d-447d-8773-0637028b6f86, Romaguera, Will and Hettinger, romaguera-will-and-hettinger, f, f, f, f, {}, null, null, t, #689F38, null, null, null, f, blank, $ID$).',

I am continuing to look further, however wanted to see if anyone else has ran into this.

Software Version(s)
typeorm-fixtures 3.0.1
@tylergets tylergets added the bug Something isn't working label Oct 27, 2022
@tylergets
Copy link
Author

Further testing reveals that this is probably related to lazy relationships, PR #198 fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants