diff --git a/packages/cli/src/databases/repositories/execution.repository.ts b/packages/cli/src/databases/repositories/execution.repository.ts index 6609173fc6ab1b..44e9986f3858de 100644 --- a/packages/cli/src/databases/repositories/execution.repository.ts +++ b/packages/cli/src/databases/repositories/execution.repository.ts @@ -35,7 +35,6 @@ import type { } from '@/Interfaces'; import config from '@/config'; -import { isAdvancedExecutionFiltersEnabled } from '@/executions/executionHelpers'; import type { ExecutionData } from '../entities/ExecutionData'; import { ExecutionEntity } from '../entities/ExecutionEntity'; import { ExecutionMetadata } from '../entities/ExecutionMetadata'; @@ -70,7 +69,7 @@ function parseFiltersToQueryBuilder( if (filters?.finished) { qb.andWhere({ finished: filters.finished }); } - if (filters?.metadata && isAdvancedExecutionFiltersEnabled()) { + if (filters?.metadata) { qb.leftJoin(ExecutionMetadata, 'md', 'md.executionId = execution.id'); for (const md of filters.metadata) { qb.andWhere('md.key = :key AND md.value = :value', md); diff --git a/packages/cli/src/executions/execution.service.ts b/packages/cli/src/executions/execution.service.ts index 917adec7f45fca..b0c4f11e164b09 100644 --- a/packages/cli/src/executions/execution.service.ts +++ b/packages/cli/src/executions/execution.service.ts @@ -40,6 +40,7 @@ import type { ExecutionEntity } from '@/databases/entities/ExecutionEntity'; import { QueuedExecutionRetryError } from '@/errors/queued-execution-retry.error'; import { ConcurrencyControlService } from '@/concurrency/concurrency-control.service'; import { AbortedExecutionRetryError } from '@/errors/aborted-execution-retry.error'; +import { License } from '@/License'; export const schemaGetExecutionsQueryFilter = { $id: '/IGetExecutionsQueryFilter', @@ -90,6 +91,7 @@ export class ExecutionService { private readonly waitTracker: WaitTracker, private readonly workflowRunner: WorkflowRunner, private readonly concurrencyControl: ConcurrencyControlService, + private readonly license: License, ) {} async findOne( @@ -249,6 +251,10 @@ export class ExecutionService { } } + if (requestFilters?.metadata && !this.license.isAdvancedExecutionFiltersEnabled()) { + delete requestFilters.metadata; + } + await this.executionRepository.deleteExecutionsByFilter(requestFilters, sharedWorkflowIds, { deleteBefore, ids, diff --git a/packages/cli/src/executions/executionHelpers.ts b/packages/cli/src/executions/executionHelpers.ts index b0354aa1c6d9cb..21b9cf086554fd 100644 --- a/packages/cli/src/executions/executionHelpers.ts +++ b/packages/cli/src/executions/executionHelpers.ts @@ -1,6 +1,4 @@ -import { Container } from 'typedi'; import type { ExecutionStatus } from 'n8n-workflow'; -import { License } from '@/License'; import type { IExecutionFlattedDb, IExecutionResponse } from '@/Interfaces'; export function getStatusUsingPreviousExecutionStatusMethod( @@ -18,8 +16,3 @@ export function getStatusUsingPreviousExecutionStatusMethod( return 'unknown'; } } - -export function isAdvancedExecutionFiltersEnabled(): boolean { - const license = Container.get(License); - return license.isAdvancedExecutionFiltersEnabled(); -} diff --git a/packages/cli/test/unit/services/execution.service.test.ts b/packages/cli/test/unit/services/execution.service.test.ts index e607fe0b6945f2..fe05c765859123 100644 --- a/packages/cli/test/unit/services/execution.service.test.ts +++ b/packages/cli/test/unit/services/execution.service.test.ts @@ -16,6 +16,8 @@ describe('ExecutionService', () => { mock(), mock(), mock(), + mock(), + mock(), ); it('should error on retrying an aborted execution', async () => {