fix: message cleaner find operator (#6080)
This PR fix an issue with the `IsNull()` find operator applied on one-to-many relation, this one is not supported by TypeORM. We can instead filter by an empty array to retrieve object with empty relations.
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
import { EntityManager, IsNull } from 'typeorm';
|
import { EntityManager } from 'typeorm';
|
||||||
|
|
||||||
import { InjectWorkspaceRepository } from 'src/engine/twenty-orm/decorators/inject-workspace-repository.decorator';
|
import { InjectWorkspaceRepository } from 'src/engine/twenty-orm/decorators/inject-workspace-repository.decorator';
|
||||||
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
import { WorkspaceRepository } from 'src/engine/twenty-orm/repository/workspace.repository';
|
||||||
@ -30,10 +30,11 @@ export class MessagingMessageCleanerService {
|
|||||||
const nonAssociatedMessages = await this.messageRepository.find(
|
const nonAssociatedMessages = await this.messageRepository.find(
|
||||||
{
|
{
|
||||||
where: {
|
where: {
|
||||||
messageChannelMessageAssociations: IsNull(),
|
messageChannelMessageAssociations: [],
|
||||||
},
|
},
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
relations: ['messageChannelMessageAssociations'],
|
||||||
},
|
},
|
||||||
transactionManager,
|
transactionManager,
|
||||||
);
|
);
|
||||||
@ -61,7 +62,7 @@ export class MessagingMessageCleanerService {
|
|||||||
const orphanThreads = await this.messageThreadRepository.find(
|
const orphanThreads = await this.messageThreadRepository.find(
|
||||||
{
|
{
|
||||||
where: {
|
where: {
|
||||||
messages: IsNull(),
|
messages: [],
|
||||||
},
|
},
|
||||||
take: limit,
|
take: limit,
|
||||||
skip: offset,
|
skip: offset,
|
||||||
|
|||||||
Reference in New Issue
Block a user