vendure-ecommerce/vendure

EntityHydrator does not shorten jointable alias names anymore

MKmedicalvalues opened this issue · 0 comments

Describe the bug
While upgrading our vendure project to vendure v2.2, we ran into a typeorm QueryFailedError that suggested there were tablenames in our queries that were specified more than once.

After some debugging i tracked the issue down to the following:

This PR changed the EntityHydrator to use typeorms SelectQueryBuilder instead of the Repository to hydrate entities. The SelectQueryBuilder does not shorten alias names of joined relations, like the Repository does. When hydrating entities with very deeply nested relations (relation string resulting in a jointablename > 63 characters) now leads to alias names being cut off after 63 characters because of the alias string limitation of 63 characters in typeorms postgres driver. This leads to the errors we encountered in our project.

To Reproduce
Steps to reproduce the behavior:

  1. Try using the EntityHydrator with a very long relations string (> 63 characters) and you should run into said typeorm QueryFailedError.

Expected behavior
The EntityHydrator should be usable, regardless of the size of relation strings it is given, or at least, if the behavior is not changeable, check for length and throw an error indicating relation strings that are too long, which would obviously limit the buildable datamodels in vendure drastically, if you still want to use the EntityHydrator regarding performance.

Environment (please complete the following information):

  • @vendure/core version: v2.2.5
  • Nodejs version: v20.13.1
  • Database (mysql/postgres etc): postgres