Skip to content

Bug: OR in joined tables are not working #1107

@dariozachow

Description

@dariozachow

I have to Entities joined OneToOne:

Base.entity.ts:

@Entity({ name: 'base' })
export class Base {
  @OneToOne(() => Details, (details) => details.base, {
    onDelete: 'CASCADE'
  })
  details: Relation<Details> | null;

Detail.entity.ts

@Entity({ name: 'detail' })
export class Details {
  @Column({ nullable: false, name: 'important_id' })
  @Index()
  importantId: string

  @Column({ nullable: false, name: 'some_other_id' })
  @Index()
  someOtherId: string;

  @OneToOne(() => Base, (base) => base.details, {
    onDelete: 'CASCADE',
    cascade: true,
    eager: true
  })
  @JoinColumn({ name: 'base_id' })
  base: Relation<Base>;
}

Now I try to have a paginate Query like this:

await this.baseRepo.paginate(paginateQuery, {
    relations: { details: true },
    relativePath: false,
    maxLimit: 1000,
    origin: process.env.API_HOST,
    defaultLimit: 100,
    defaultSortBy: [['created', 'DESC']]
          where: {
            details: [{ importantId: inputId) },  {someOtherId: string}]
          }
        });

Now when trying to run this pagination query I get the following error:

TypeORMError: Relation with property path 0 in entity was not found.

Stack Trace:
at JoinAttribute.getValue (/Documents/repos/grs/src/query-builder/JoinAttribute.ts:187:23)
at JoinAttribute.get relation [as relation] (
/Documents/repos/grs/src/query-builder/JoinAttribute.ts:191:53)
at JoinAttribute.get metadata [as metadata] (/Documents/repos/grs/src/query-builder/JoinAttribute.ts:203:18)
at SelectQueryBuilder.join (
/Documents/repos/grs/src/query-builder/SelectQueryBuilder.ts:2100:53)
at SelectQueryBuilder.leftJoin (~/Documents/repos/grs/src/query-builder/SelectQueryBuilder.ts:468:14)
at ~/Documents/repos/grs/node_modules/nestjs-paginate/src/paginate.ts:185:38
at Array.forEach ()
at /Documents/repos/grs/node_modules/nestjs-paginate/src/paginate.ts:167:30
at Array.flatMap ()
at flattenWhereAndTransform (
/Documents/repos/grs/node_modules/nestjs-paginate/src/paginate.ts:128:32)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions