RobinCK / typeorm-fixtures

:pill: Fixtures loader for typeorm ๐Ÿ‡บ๐Ÿ‡ฆ
https://robinck.github.io/typeorm-fixtures/
MIT License
566 stars 45 forks source link

[Bug] Cannot load fixture #155

Closed rogeraraujo90 closed 4 years ago

rogeraraujo90 commented 4 years ago

Your Environment

| Software | Version(s) | | typeorm-fixtures-cli | 1.8.0 | | Node | 14.5.0 | Yarn | 1.22.4 | Operating System | MacOs 10.15.7

I have the following relation:

@ManyToOne(() => Source)
@JoinColumn({ name: "sourceId" })
source: Source;

@ManyToOne(() => Team)
@JoinColumn({ name: "teamId" })
team: Team;

@ManyToOne(() => Comment) @JoinColumn({ name: "parentId" }) parent: Comment | null;



I'm trying load some comments in database but, if all `News` have a `Team` then I get this error:

<img width="1387" alt="Screen Shot 2020-11-12 at 21 11 43" src="https://user-images.githubusercontent.com/6045678/99011808-aced8200-252b-11eb-8a52-2e860c031291.png">

If I leave some `News` without a `Team` then the fixtures are loaded. But the Comments are related just with the `News` without a `Team`.

Using a `console.log` I found that the `parse` method in `ReferenceParser` is been called with the `entities` without any news. So, probably the library is trying load the comments when there is no news created.
RobinCK commented 4 years ago

it's hard to say something without a yaml file

rogeraraujo90 commented 4 years ago

Sorry,

The related yaml files:

With this content, I can't load the fixtures, the error is shown in console. If I remove team from new{6..8} works, and all comments are related with these news (without a team)

RobinCK commented 4 years ago

new{6..8} maybe news{6..8}?

rogeraraujo90 commented 4 years ago

Great! It's working now! Thank you so much! ๐Ÿ˜„