-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
listQueryBuilder.build() throw "Not unique table/alias:
error while upgrade to vendure 2.2.0-next.6
#2738
Comments
https://github.com/tianyingchun/vendure-issue checkout banch
SELECT
`Menu`.`createdAt` AS `Menu_createdAt`,
`Menu`.`updatedAt` AS `Menu_updatedAt`,
`Menu`.`code` AS `Menu_code`,
`Menu`.`parentId` AS `Menu_parentId`,
`Menu`.`id` AS `Menu_id`,
`Menu`.`createdAt` AS `Menu_createdAt`,
`Menu`.`updatedAt` AS `Menu_updatedAt`,
`Menu`.`code` AS `Menu_code`,
`Menu`.`parentId` AS `Menu_parentId`,
`Menu`.`id` AS `Menu_id`
FROM
`menu` `Menu`
INNER JOIN `menu` `Menu` ON `Menu`.`parentId` = `Menu`.`id`
WHERE
`Menu`.`id` IN (1,2,3) |
@monrostar is this the issue you ran into when updating TypeORM? |
Yes, it may be necessary to add a check not only for Tree but also if the relation decorator points to the same table.
|
@michaelbromley I can do this fix today |
A fix will be ready today. I found a cause |
also need to considered |
please see my latest updated repo https://github.com/tianyingchun/next-issue/tree/vendure_issue_2738
|
because @Entity('menu')
export class Menu extends VendureEntity implements Translatable {
constructor(input?: DeepPartial<Menu>) {
super(input);
}
name: LocaleString;
@Column({ unique: true })
code: string;
@ManyToOne(() => Menu, (type) => type.parent)
parent: Menu | null;
@Column('int', { nullable: true })
parentId: ID | null;
@OneToMany(() => MenuTranslation, (translation) => translation.base, {
eager: true,
})
translations: Array<Translation<Menu>>;
} @Entity('menu_translation')
export class MenuTranslation
extends VendureEntity
implements Translation<Menu>
{
constructor(input?: DeepPartial<Translation<Menu>>) {
super(input);
}
@Column('varchar')
name: string;
@Column('varchar')
languageCode: LanguageCode;
@ManyToOne(() => Menu, (base) => base.translations, {
onDelete: 'CASCADE',
})
base: Relation<Menu>;
} findAll(
ctx: RequestContext,
options?: ListQueryOptions<Menu>
): Promise<PaginatedList<Menu>> {
return this.listQueryBuilder
.build(Menu, options, { relations: ['parent'], ctx })
.getManyAndCount()
.then(([menuItems, totalItems]) => {
const items = menuItems.map((processOption) =>
this.translator.translate(processOption, ctx, ['parent'])
);
return {
items,
totalItems,
};
});
} |
it works with |
Describe the bug
While upgrade to vendure
2.2.0-next.6
, typeorm 0typeorm@0.3.20it wll throw
"Not unique table/alias:
if we haverelation:['parent']
, andparent
reference this entity selfTo Reproduce
Steps to reproduce the behavior:
it will throw error
Expected behavior
A clear and concise description of what you expected to happen.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: