TriPSs/nestjs-query

Filter by RelationShip

benjaminfrancois opened this issue · 2 comments

Hello,

I want to use filters on a ManyToOne relationship in my code, but I'm encountering an issue when executing queries in the database. The problem is that the generated queries use the column name "roleId" instead of "role_id," which causes the database query to fail.

Relevant Code:

  @ManyToOne(() => Role, {
    eager: true,
    nullable: true,
    onDelete: 'SET NULL',
  })
  @JoinColumn({ name: 'role_id' })
  role?: Role | null;

  @RelationId((user: User) => user.role)
  @FilterableField(() => ID, { name: 'role_id' })
  roleId?: string;

Thank's ! 😄

TriPSs commented

Hi, could you add a test case to this repo (inside ./examples, you can add it to an existing one if it makes sense to do so) for this case? That will massively help us in solving the issue and keeping it solved :)

Closing, if still an issue please reopen.