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

Config.withDeleted is not working #973

Open
egg- opened this issue Sep 10, 2024 · 2 comments
Open

Config.withDeleted is not working #973

egg- opened this issue Sep 10, 2024 · 2 comments

Comments

@egg-
Copy link

egg- commented Sep 10, 2024

Hello,

I tried to retrieve soft-deleted data by setting the withDeleted: true value to true, but the desired result did not come out.

@ppetzold
Copy link
Owner

have you reviewed the generated SQL query?

@egg-
Copy link
Author

egg- commented Sep 10, 2024

sure, i have reviewed the generated SQL query.
PaginateConfig.withDeleted was set to true, and this is the generated sql.

query : 
SELECT 
  COUNT(DISTINCT `__root`.`id`) AS `cnt` 
FROM 
  `notification` `__root` 
  LEFT JOIN `user` `__root_createdBy_rel` ON `__root_createdBy_rel`.`id` = `__root`.`createdById` 
  AND (
    `__root_createdBy_rel`.`deletedAt` IS NULL
  ) 
  LEFT JOIN `file` `__root_createdBy_rel_profileImage_rel` ON `__root_createdBy_rel_profileImage_rel`.`id` = `__root_createdBy_rel`.`profileImageId` 
  AND (
    `__root_createdBy_rel_profileImage_rel`.`deletedAt` IS NULL
  ) 
  LEFT JOIN `project` `__root_project_rel` ON `__root_project_rel`.`id` = `__root`.`projectId` 
  AND (
    `__root_project_rel`.`deletedAt` IS NULL
  ) 
  LEFT JOIN `stage` `__root_stage_rel` ON `__root_stage_rel`.`id` = `__root`.`stageId` 
  AND (
    `__root_stage_rel`.`deletedAt` IS NULL
  ) 
  LEFT JOIN `block` `__root_block_rel` ON `__root_block_rel`.`id` = `__root`.`blockId` 
  AND (
    `__root_block_rel`.`deletedAt` IS NULL
  ) 
  LEFT JOIN `user` `__root_user_rel` ON `__root_user_rel`.`id` = `__root`.`userId` 
  AND (
    `__root_user_rel`.`deletedAt` IS NULL
  ) 
WHERE 
  (`__root_user_rel`.`id` = ?)

And I moved the call point of queryBuilder and also share the result. I will make a pull request, please check.

query : 
SELECT 
  COUNT(DISTINCT `__root`.`id`) AS `cnt` 
FROM 
  `notification` `__root` 
  LEFT JOIN `user` `__root_createdBy_rel` ON `__root_createdBy_rel`.`id` = `__root`.`createdById` 
  LEFT JOIN `file` `__root_createdBy_rel_profileImage_rel` ON `__root_createdBy_rel_profileImage_rel`.`id` = `__root_createdBy_rel`.`profileImageId` 
  LEFT JOIN `project` `__root_project_rel` ON `__root_project_rel`.`id` = `__root`.`projectId` 
  LEFT JOIN `stage` `__root_stage_rel` ON `__root_stage_rel`.`id` = `__root`.`stageId` 
  LEFT JOIN `block` `__root_block_rel` ON `__root_block_rel`.`id` = `__root`.`blockId` 
  LEFT JOIN `user` `__root_user_rel` ON `__root_user_rel`.`id` = `__root`.`userId` 
WHERE 
  (`__root_user_rel`.`id` = ?)

egg- added a commit to egg-/nestjs-paginate that referenced this issue Sep 10, 2024
egg- added a commit to egg-/nestjs-paginate that referenced this issue Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants