Skip to content

find with relations returns soft-deleted entities #6265

@Ollie1700

Description

@Ollie1700

Issue type:

[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

Apologies for opening an issue for this, it seems like I am probably missing something very obvious but essentially the issue is that soft-deleted entities are being returned as part of relations.

Example:

Say we have "User" and "Post" - user has many posts

  1. const userWithPosts = await userRepo.findOne(1, { relations: [ 'posts' ] })
  2. userWithPosts.posts will contain all posts, even ones that have been deleted

Am I missing something obvious here? This functionality works as expected when not using relations (e.g. in the above example, postRepo.find() would only return non-deleted items) but when using relations I am running into this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions