Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeRepository findDescendantsTree and findDescendants are not same data #9407

Open
wszgrcy opened this issue Sep 25, 2022 · 0 comments
Open

Comments

@wszgrcy
Copy link

wszgrcy commented Sep 25, 2022

Issue Description

  • I find TreeRepository findDescendants method will return error data
  • I see database find file_system_node_entity_closure table has error map
  • but findDescendantsTree get right data( not compare data structure only data sum)

Expected Behavior

  • findDescendants get self and all Descendants

Actual Behavior

  • findDescendants get some unexpected node(I don't know why have this node ....)
// include the output in code tags like these!

Steps to Reproduce

  1. sorry I can't Reproduce, only can offer data to dispaly
  2. database link(https://gist.github.com/wszgrcy/64ed33176e46f738066f0a1ce0d9e036)
    3 entity define
import {
  Column,
  Entity,
  JoinColumn,
  ManyToMany,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
  Tree,
  TreeChildren,
  TreeParent,
} from 'typeorm';
import { FileSystemEntity } from './file-system.entity';
import { FileSystemNodeContentEntity } from './file-system-node-content.entity';
import { FileSystemNodeBase, FileType } from '../interface';
import { FileSystemGroupNodeEntity } from '.';
@Entity()
@Tree('closure-table')
export class FileSystemNodeEntity extends FileSystemNodeBase {
  @PrimaryGeneratedColumn('uuid')
  override id!: string;
  @TreeChildren({ cascade: ['insert', 'update'] })
  override children!: FileSystemNodeEntity[];

  @TreeParent()
  override parent!: FileSystemNodeEntity;

  @Column()
  override icon!: string;
  @Column()
  override defaultIcon!: boolean;
  @Column()
  override name!: string;

  @Column('simple-enum')
  override type!: FileType;

  @ManyToOne(() => FileSystemNodeContentEntity)
  @JoinColumn({ name: 'fileSystemNodeContentId' })
  fileSystemNodeContent?: FileSystemNodeContentEntity | null;

  @Column({ name: 'fileSystemNodeContentId', nullable: true })
  override fileSystemNodeContentId?: string | null;

  @ManyToOne(() => FileSystemEntity, { onDelete: 'CASCADE' })
  fileSystem!: FileSystemEntity;

  @ManyToMany(() => FileSystemEntity, (type) => type.fileSystemNodeList, {})
  fileSystemList!: FileSystemEntity[];

  @OneToMany(
    () => FileSystemGroupNodeEntity,
    (type) => type.fileSystemNodeEntity,
    {},
  )
  fileSystemGroupList?: FileSystemGroupNodeEntity[];

  @ManyToOne(() => FileSystemNodeEntity, (type) => type.id, {
    deferrable: 'INITIALLY DEFERRED',
    onDelete: 'SET NULL',
    cascade: true,
  })
  @JoinColumn({ name: 'prevId' })
  prev?: FileSystemNodeEntity | null;
  @Column({ default: null, nullable: true })
  prevId?: string | null;
  @ManyToOne(() => FileSystemNodeEntity, (type) => type.id, {
    deferrable: 'INITIALLY DEFERRED',
    onDelete: 'SET NULL',
    cascade: true,
  })
  @JoinColumn({ name: 'nextId' })
  next!: FileSystemNodeEntity | null;
  @Column({ default: null, nullable: true })
  nextId?: string | null;

  @Column({ type: 'simple-array', default: null })
  override list?: string[];
}

image
image

  • file_system_node_entity show no children but file_system_node_entity_closure find 4 node(include self)

My Environment

Dependency Version
Operating System win 10 19044.1165
electron 16.0.8
Typescript version ^4.7.4
TypeORM version 0.3.7

Additional Context

Relevant Database Driver(s)

DB Type Reproducible
aurora-mysql no
aurora-postgres no
better-sqlite3 no
cockroachdb no
cordova no
expo no
mongodb no
mysql no
nativescript no
oracle no
postgres no
react-native no
sap no
spanner no
sqlite yes
sqlite-abstract no
sqljs no
sqlserver no

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✅ Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant