We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The problem is: Could not save entity. I'm using TypeORM with Postgres.
create-article.seed.ts:
... export class CreateOpenTournament implements Seeder { public async run(factory: Factory): Promise<void> { await factory(Article)().create(); } }
article.factory.ts:
... define(Article, (faker: typeof Faker) => { const article = new Article(); article.id = faker.random.uuid(); article.publicedDate = new Date('2012-10-07 12:00'); article.numberOfViews = 20; article.type = ArticleType.BLOG; article.status = factory(Status)() as any; article.content = factory(ArticleContent)() as any; article.contributors = [factory(ArticleMapping)() as any]; article.category = factory(Category)() as any; article.tags = [factory(TagMapping)() as any]; // <-- Error here article.ratings = null; return article; });
tagMapping.factory.ts:
... define(TagMapping, (faker: typeof Faker) => { const tagMapping = new TagMapping(); tagMapping.id = faker.random.uuid(); tagMapping.isMain = false; //boolean; <-- here is false but in compile null tagMapping.tag = factory(Tag)() as any; return tagMapping; });
article.entity.ts:
... @Entity() export class Article extends DefaultEntity { ... @ApiProperty({ type: [TagMapping], description: 'The Tags belong to this article.' }) @ManyToMany(() => TagMapping, { cascade: true, eager: true }) @JoinTable() tags: TagMapping[]; ... }
This is what I get when running the seeder:
... ❌ Could not save entity QueryFailedError: null value in column "isMain" violates not-null constraint ... code: '23502', detail: 'Failing row contains (93f39f1d-64b6-41b7-b127-ce9e6f1dcebc, 2021-02-15 11:29:35.901828+01, 2021-02-15 11:29:35.901828+01, null, null, null).', ... query: 'INSERT INTO "tag_mapping"("id", "createDate", "updateDate", "deleteDate", "isMain", "tagId") VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT) RETURNING "id", "createDate", "updateDate", "deleteDate"', parameters: [] } × Could not run the seed CreateOpenTournament! Error: Could not save entity ... npm ERR! code 1 ...
Sorry for my bad English.
The text was updated successfully, but these errors were encountered:
Hi! Sorry for late response.
I have to check this deeply, not sure how is the behaviour when working on arrays on factories.
Sorry, something went wrong.
jorgebodega
No branches or pull requests
The problem is:
Could not save entity.
I'm using TypeORM with Postgres.
SEED file:
create-article.seed.ts:
FACTORY file:
article.factory.ts:
tagMapping.factory.ts:
Entity file:
article.entity.ts:
This is what I get when running the seeder:
Sorry for my bad English.
The text was updated successfully, but these errors were encountered: