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
When trying to get a record from table, it returns null if it has a relation to another table.
Expected behavior is to return record with corresponding id.
I have a table "ingredient" with a column "deletedAt" and a column "authorId" which refers to "user" table.
I am using findOne method to get a record from this table with its id :
const ingredient = await this.getRepository(Ingredient).find({ where: { id }, withDeleted: true, });
When the record has both a date of deletion and a relation to user, it returns null. But when I remove one of the two, it returns the correct record.
Here is the definition of ingredient entity :
@ManyToOne(() => User, { nullable: true, eager: true, onDelete: 'SET NULL' }) @Field(() => User, { nullable: true }) @IsOptional() @IsObject() @Type(() => User) author?: User; @DeleteDateColumn({ nullable: true, type: 'timestamptz' }) @Field(() => Date, { nullable: true }) @IsOptional() @IsDate() deletedAt?: Date;
No response
No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered:
I can't reproduce the bug. Can you check if this is the expected behaviour?
const user = await dataSource.getRepository(User).save({id: 1}); await dataSource.getRepository(Ingredient).save({ id: 1, author: user, deletedAt: new Date() }); const foundIngredient = await dataSource.getRepository(Ingredient).findOne({withDeleted: true, where: {id: 1}}); expect(foundIngredient?.author).to.be.eql(user);
Sorry, something went wrong.
No branches or pull requests
Issue description
When trying to get a record from table, it returns null if it has a relation to another table.
Expected Behavior
Expected behavior is to return record with corresponding id.
Actual Behavior
I have a table "ingredient" with a column "deletedAt" and a column "authorId" which refers to "user" table.
I am using findOne method to get a record from this table with its id :
When the record has both a date of deletion and a relation to user, it returns null.
But when I remove one of the two, it returns the correct record.
Steps to reproduce
Here is the definition of ingredient entity :
My Environment
Additional Context
No response
Relevant Database Driver(s)
Are you willing to resolve this issue by submitting a Pull Request?
No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
The text was updated successfully, but these errors were encountered: