typeorm: ER_BAD_FIELD_ERROR: Unknown column 'treeEntity.parentId' in 'where clause
Issue type:
[ x ] question [ ] bug report [ ] feature request [ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
TypeORM version:
[x ] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
url: documentation http://typeorm.io/#/tree-entities/working-with-tree-entities
code:
async videoCategoryList(): Promise<any> {
const manager = getManager();
const a1 = new Category();
a1.name = "a1";
await manager.save(a1);
return await manager.getTreeRepository(Category).findRoots();
}
@Entity()
@Tree('closure-table')
export class Category {
@PrimaryGeneratedColumn('uuid', { comment: '唯一id' })
video_category_id: string;
@Column({ comment: '菜单名' })
name: string;
@Column({ type: 'enum', enum: ['0', '1'], comment: '视频分类,未定义的分类' })
type: string;
@TreeChildren()
children: Category[];
@TreeParent()
parent: Category;
}
Error:
{
"message": "ER_BAD_FIELD_ERROR: Unknown column 'treeEntity.parentId' in 'where clause'",
"code": "ER_BAD_FIELD_ERROR",
"errno": 1054,
"sqlMessage": "Unknown column 'treeEntity.parentId' in 'where clause'",
"sqlState": "42S22",
"index": 0,
"sql": "SELECT `treeEntity`.`video_category_id` AS `treeEntity_video_category_id`, `treeEntity`.`name` AS `treeEntity_name`, `treeEntity`.`type` AS `treeEntity_type`, `treeEntity`.`parentVideoCategoryId` AS `treeEntity_parentVideoCategoryId` FROM `category` `treeEntity` WHERE `treeEntity`.`parentId` IS NULL",
"name": "QueryFailedError",
"query": "SELECT `treeEntity`.`video_category_id` AS `treeEntity_video_category_id`, `treeEntity`.`name` AS `treeEntity_name`, `treeEntity`.`type` AS `treeEntity_type`, `treeEntity`.`parentVideoCategoryId` AS `treeEntity_parentVideoCategoryId` FROM `category` `treeEntity` WHERE `treeEntity`.`parentId` IS NULL"
}
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 25 (6 by maintainers)
Commits related to this issue
- Test: add failing test for #2361 Create failing test for #2361 when id name in parent id different than id — committed to ruciu/typeorm by ruciu 5 years ago
- Test: add custom migrations to test Updated test for #2361 with custom migrations — committed to ruciu/typeorm by ruciu 5 years ago
- Fix: added option to use join column in parent Fixes #2361. To be reviewed — committed to ruciu/typeorm by ruciu 5 years ago
Any updates on this?
mature like milfs? 😆
@artem-hryb thanks for the confirmation, contributions are welcomed btw, we need to fix it if its a bug.
any updates on that?
@pleerock any thoughts on it?
@artem-hryb Thank you for your help . But I chose other more mature ORM Sequelize
any updates on that? I have simillar issue,
@LogansUA add code below to your naming-strategy.ts
@pleerock I created failing test for this issue, and I can also try to fix this issue. Do you have any decorator you would prefer to modify in order to add this custom id name?
Since there are multiple reports I’ll mark it as a bug but we still need some tests before we fix it.