-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Related to #2361
When we use a custom primary column, the query breaks because it seems findRoots makes an assumption that the primary key = id.
An example if we use cat_id as the primary key, findRoots makes the following SQL query:
SELECT
`treeEntity`.`cat_id` AS `treeEntity_cat_id`,
`treeEntity`.`cat_name` AS `treeEntity_cat_name`,
`treeEntity`.`mpath` AS `treeEntity_mpath`,
`treeEntity`.`catParentCatId` AS `treeEntity_catParentCatId`
FROM
`category` `treeEntity`
WHERE
`treeEntity`.`catParentId` IS NULL 'Instead of the correct query:
SELECT
`treeEntity`.`cat_id` AS `treeEntity_cat_id`,
`treeEntity`.`cat_name` AS `treeEntity_cat_name`,
`treeEntity`.`mpath` AS `treeEntity_mpath`,
`treeEntity`.`catParentCatId` AS `treeEntity_catParentCatId`
FROM
`category` `treeEntity`
WHERE
`treeEntity`.`catParentCatId` IS NULL 'Metadata
Metadata
Assignees
Labels
No labels