ppetzold/nestjs-paginate

ERROR [ExceptionsHandler] Duplicate column name

Opened this issue · 3 comments

huytt commented

PropertyEntity:

  @PrimaryGeneratedColumn({ type: 'int', unsigned: true })
  id: number;

  @Column({ name: 'district_id', type: 'int' })
  districtId: number;

  @ManyToOne(() => DistrictEntity, (district) => district.properties, {
    eager: true,
  })
  @JoinColumn({ name: 'district_id' })
  district: DistrictEntity;

DistrictEntity:

  @PrimaryGeneratedColumn()
  id: number;

  @Column({ nullable: true })
  district_name: string;

Paginate with eager load:

    const config: PaginateConfig<PropertyEntity> = {
      loadEagerRelations: true,
      relations: ['district'],
      sortableColumns: ['id'],
    };

    return paginate<PropertyEntity>(query, this.propertyRepository, config);

This throws the exception: QueryFailedError: Duplicate column name '__root_district_id'

Helveg commented

Which version are you using?

I have the same error. In my case the version I'm using is: 4.14.0

Helveg commented

The current major version of nestjs-paginate is 8.3.0, somewhere around 6 or 7 duplicate columns were fixed. Could you try upgrading to preferably version 8, and see if this resolves it?