-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the mpath is incorrect when the parent of the tree entity is null (
#9535) * fix: the mpath is incorrect when the parent of the tree entity is null * lint: code format * fix: findTrees not have children * test: add unit test * style: format code * fix: unit test * fix: unit test * fix: unit test
- Loading branch information
1 parent
97fae63
commit 658604d
Showing
4 changed files
with
342 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { TreeParent } from "../../../../src/decorator/tree/TreeParent" | ||
import { TreeChildren } from "../../../../src/decorator/tree/TreeChildren" | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { Tree } from "../../../../src/decorator/tree/Tree" | ||
import { JoinColumn } from "../../../../src/decorator/relations/JoinColumn" | ||
|
||
@Entity({ name: "categories" }) | ||
@Tree("materialized-path") | ||
export class Category { | ||
@PrimaryGeneratedColumn() | ||
id: number | ||
|
||
@Column({ | ||
type: "varchar", | ||
name: "uid", | ||
unique: true, | ||
}) | ||
uid: string | ||
|
||
@Column() | ||
name: string | ||
|
||
@Column({ | ||
type: "varchar", | ||
name: "parentUid", | ||
nullable: true, | ||
}) | ||
parentUid?: string | null | ||
|
||
@TreeParent() | ||
@JoinColumn({ | ||
name: "parentUid", | ||
referencedColumnName: "uid", | ||
}) | ||
parentCategory?: Category | null | ||
|
||
@TreeChildren({ cascade: true }) | ||
childCategories: Category[] | ||
} |
Oops, something went wrong.