nestjs-paginate
nestjs-paginate copied to clipboard
Cannot find alias for relation at xxx
Hi,
I'm having a problem when I want to add conditions using relations fields.
Here is where I call the paginate function:
paginate(query, this.taskMessagesRepository, { relations: ['message'], where: { message: { deleted: false, }, }, sortableColumns: ['id', 'message.deleted'], });
Here are my entites:
export class Message { ... @Index() @Column({ type: 'boolean', default: false }) deleted: boolean; }
export class TaskMessage { ... @ManyToOne(() => Message, { nullable: false }) message: Message; }
The error is "Cannot find alias for relation at message".
Please note that, when I want to display a particular task message with a message.id where statement, the condition pick the messageId of the TaskMessage table.
I don't know if it comes from the library or not but when I copy the conditions and relations using "TypeOrm.find", it works.
(I used the 2.6.0 version of the library). Thanks !
I am not quite sure. Could be due to the nested where
. I think we don't have a test covering those.
You could either address this with a PR or use an hardcode an EQ filter on your query.
Hi @ppetzold ,
Thanks for your reply. Indeed, I added the filter in the query waiting for a "cleaner" fix. I plan to see where the problem is in the library but haven't had the time yet :) Will see in the next few days
Dennis
Cool. If you wanna have look. Probably this needs some alias transformation:
https://github.com/ppetzold/nestjs-paginate/blob/master/src/paginate.ts#L228
okay, till now its not fixed
this is/was not an issue of this package. it's typeorm related.
https://github.com/typeorm/typeorm/pull/7805
fixed this for one-to-one and many-to-one. one-to-many still unsupported.
https://github.com/ppetzold/nestjs-paginate/commit/e8705e205b65cfed936db4f4b015c4338065aff9
closing