#Query on the related items one-to-many consistently failed

15 messages · Page 1 of 1 (latest)

scenic solstice
#

I've one-to-many relations, but while querying on the returned response on the related items, it failed and threw an error as below.

the database is Postgres.

The error is:
[Nest] 23084 - 09/11/2023, 11:02:24 PM ERROR [ExceptionsHandler] Cannot query across one-to-many for property reservations
Error: Cannot query across one-to-many for property reservations

stoic swift
#

What are the codes of the entities used and the query performed?

scenic solstice
#

It's so simple like this

#

I need to mention something, while logging the result of the queue I found the reservations already attached, but also it threw the error at the end.

#

@stoic swift, do you have any idea?!

stoic swift
#

What are the codes for the Reservation and queue entities, with the decorators @manytoone and @onetomany?

scenic solstice
#

This is from the Queue entity

#

This is from the Reservation entity

#

@stoic swift

stoic swift
scenic solstice
#

Yes, it's weird for me!

I've checked everywhere and see similar issues related to the same topic on GitHub.

stoic swift
#

Would confirm in the database if the queueId property (queue id) exists in the Reservation table.

Another possibility would be to try with QueryBuilder, similar to

const users = await this.queueRepo
     .createQueryBuilder("queue")
     .leftJoinAndSelect("queue.reservations", "reservation")
     .where(`queue.id = :id`, { id: queueId })
     .getOne()
scenic solstice
#

The ids already there, and the data as i told you before, its in logged in terminal

scenic solstice
#

@stoic swift It's fixed using a DTO to access the related items instead of accessing the entity type itself.

#

Thank you @stoic swift 🙏