Skip to content

Commit

Permalink
fix(core): Truncate db aliases if necessary
Browse files Browse the repository at this point in the history
Fixes #2899
  • Loading branch information
jnugh committed Jul 18, 2024
1 parent c6f5d9d commit 258afd1
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EntityMetadata, FindOneOptions, SelectQueryBuilder } from 'typeorm';
import { EntityTarget } from 'typeorm/common/EntityTarget';
import { FindOptionsRelationByString, FindOptionsRelations } from 'typeorm/find-options/FindOptionsRelations';
import { DriverUtils } from 'typeorm/driver/DriverUtils';

import { findOptionsObjectToArray } from '../../../connection/find-options-object-to-array';
import { VendureEntity } from '../../../entity';
Expand Down Expand Up @@ -108,7 +108,12 @@ export function joinTreeRelationsDynamically<T extends VendureEntity>(
if (relationMetadata.isEager) {
joinConnector = '__';
}
const nextAlias = `${currentAlias}${joinConnector}${part.replace(/\./g, '_')}`;
const nextAlias = DriverUtils.buildAlias(
qb.connection.driver,
{ shorten: false },
currentAlias,
part.replace(/\./g, '_'),
);
const nextPath = parts.join('.');
const fullPath = [...(parentPath || []), part].join('.');
if (!qb.expressionMap.joinAttributes.some(ja => ja.alias.name === nextAlias)) {
Expand Down

0 comments on commit 258afd1

Please sign in to comment.