-
-
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)
Steps to reproduce or a small repository showing the problem:
- Create an entity with a custom primary column name
import { Entity, PrimaryGeneratedColumn, Column, Tree, TreeChildren, TreeParent } from "typeorm";
@Entity()
@Tree("closure-table")
export class TestEntity {
@PrimaryGeneratedColumn()
org_id: number;
@Column()
org_name: string;
@TreeChildren()
children: TestEntity[];
@TreeParent()
parent: TestEntity;
}- Test by persisting a parent and a child and then list descendants
async function test() {
// Get tree repository
const repository = getManager().getTreeRepository(TestEntity);
// Create parent node
const parent = repository.create({
org_id: 1234,
org_name: "Parent test",
});
parent.save();
// Create child node
const child = repository.create({
org_name: "Child test"
});
child.parent = parent;
child.save();
// List all descendants
return await repository.findDescendantsTree(
await repository.findOne({ org_id: 1234 })
);
}Expected:
{
"org_id": 1234,
"org_name": "Parent test",
"children": [
{
"org_id": 1235,
"org_name": "Child test",
"children": []
}
]
}Instead:
{
"org_id": 1234,
"org_name": "Parent test",
"children": []
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels