Skip to content

Conversation

@wp99cp
Copy link
Member

@wp99cp wp99cp commented Jan 21, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 21, 2026 07:52

This comment was marked as outdated.

@wp99cp wp99cp linked an issue Jan 21, 2026 that may be closed by this pull request
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 511 to +515
// all categories will be deleted due to 'onDelete: CASCADE'.
const deleteResult = await transactionalEntityManager.delete(
ProjectEntity,
{ uuid },
);
const deleteResult =
await transactionalEntityManager.softDelete(ProjectEntity, {
uuid,
});
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

softDelete(ProjectEntity, { uuid }) does not trigger DB-level ON DELETE CASCADE, so categories will not be deleted. The inline comment stating they will be deleted due to cascade is now incorrect and may hide orphaned categories; either remove/update the comment, or explicitly delete/soft-delete related categories if that behavior is required.

Copilot uses AI. Check for mistakes.
Comment on lines +112 to +120
// 4. Verify it still exists in DB but is deleted
const projectRepo = database.getRepository(ProjectEntity);
const dbProject = await projectRepo.findOne({
where: { uuid },
withDeleted: true,
});
expect(dbProject).toBeDefined();
expect(dbProject?.deletedAt).not.toBeNull();

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is likely to fail because BaseEntity.deletedAt is defined with @DeleteDateColumn({ select: false }), so findOne({ withDeleted: true }) will typically not select deletedAt (it will be undefined even when soft-deleted). Consider verifying soft-delete via exists()/default queries, or use a query builder with addSelect('project.deletedAt') when withDeleted() is enabled.

Suggested change
// 4. Verify it still exists in DB but is deleted
const projectRepo = database.getRepository(ProjectEntity);
const dbProject = await projectRepo.findOne({
where: { uuid },
withDeleted: true,
});
expect(dbProject).toBeDefined();
expect(dbProject?.deletedAt).not.toBeNull();
// 4. Verify it still exists in DB but is soft-deleted (not returned by default queries)
const projectRepo = database.getRepository(ProjectEntity);
const dbProjectWithDeleted = await projectRepo.findOne({
where: { uuid },
withDeleted: true,
});
expect(dbProjectWithDeleted).toBeDefined();
const dbProjectWithoutDeleted = await projectRepo.findOne({
where: { uuid },
});
expect(dbProjectWithoutDeleted).toBeNull();

Copilot uses AI. Check for mistakes.
Comment on lines +182 to +185
const dbMission = await missionRepo.findOne({
where: { uuid: missionUuid },
withDeleted: true,
});
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the project test: deletedAt is marked select: false on BaseEntity, so findOne({ withDeleted: true }) may return deletedAt as undefined. Use a query builder with addSelect to read deletedAt, or assert soft-delete behavior using exists()/default find operations instead.

Suggested change
const dbMission = await missionRepo.findOne({
where: { uuid: missionUuid },
withDeleted: true,
});
const dbMission = await missionRepo
.createQueryBuilder('mission')
.addSelect('mission.deletedAt')
.withDeleted()
.where('mission.uuid = :uuid', { uuid: missionUuid })
.getOne();

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

Soft Delete + Unique Constraint Conflict

2 participants