Skip to content
New issue

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

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

Already on GitHub? # to your account

Config.withDeleted is not working #973

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

Config.withDeleted is not working #973

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

Comments

@egg-
Copy link
Contributor

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
Contributor 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
egg- added a commit to egg-/nestjs-paginate that referenced this issue Feb 18, 2025
@egg- egg- closed this as completed Feb 18, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants