Skip to content

ER_BAD_FIELD_ERROR: Unknown column 'treeEntity.parentId' in 'where clause #2361

@newcomein

Description

@newcomein

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"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions