#Typeorm relations uses a 100% incorrect field to join.

6 messages · Page 1 of 1 (latest)

turbid quest
#

Hi There.

I'm trying to retrieve an entity with two nested relations

    const savedQuoteEntity = await this.savedQuotesRepository.findOne({
      where: {
        id: savedQuoteUuid,
      },
      relations: [
        'savedTdQuotesTrackdays',
        'savedTdQuotesTrackdays.savedTdQuotesTrackdaysAdditionaldrivers',
      ],
    });

However looking at the query which is being created it uses some weird parameter to join savedTdQuotesTrackdays with savedTdQuotesTrackdaysAdditionaldrivers it should be savedTdQuotesTrackdays.id which should be joined with savedTdQuotesTrackdaysAdditionaldrivers.savedTdQuotesTrackDaysId.

 `saved_td_quotes` `SavedTdQuotes`
       LEFT JOIN `saved_td_quotes_trackdays` `SavedTdQuotes__SavedTdQuotes_savedTdQuotesTrackdays` ON `SavedTdQuotes__SavedTdQuotes_savedTdQuotesTrackdays`.`savedTdQuoteId` = `SavedTdQuotes`.`id`
       LEFT JOIN `saved_td_quotes_trackdays_additionaldrivers` `d75387e15fdf45691fcec2fc80f44cbb6f5239d44202ecc2f31546e04737f40` ON `d75387e15fdf45691fcec2fc80f44cbb6f5239d44202ecc2f31546e04737f40`.`saved_td_quotes_trackDays_id` = `SavedTdQuotes__SavedTdQuotes_savedTdQuotesTrackdays`.`id`
#

Typeorm relations uses a wrong where field.weird

#

Typeorm relations uses a 100% incorrect field to join.

#

The error itself says

error: Error: Unknown column 'd75387e15fdf45691fcec2fc80f44cbb6f5239d44202ecc2f31546e04737f40.value' in 'field list'

Which make sense.

turbid quest
#

Problem solved, the column name was too long or typeorm didn't like _. I renamed the column name and it suddenly works,

primal solar
#

I have a lot of questions but I think I'm just going to leave it at I'm glad you found a solution that works for you. 🤙