Skip to content

Commit

Permalink
Aggregate queries - Fix empty / not empty operations on composite fie…
Browse files Browse the repository at this point in the history
…lds and array fields (#9644)

as per title

closes #9353
  • Loading branch information
ijreilly authored Jan 15, 2025
1 parent b5c5bee commit 585212b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { SelectQueryBuilder } from 'typeorm';

import { AGGREGATE_OPERATIONS } from 'src/engine/api/graphql/graphql-query-runner/constants/aggregate-operations.constant';
import { AggregationField } from 'src/engine/api/graphql/workspace-schema-builder/utils/get-available-aggregations-from-object-fields.util';
import { FIELD_METADATA_TYPES_TO_TEXT_COLUMN_TYPE } from 'src/engine/metadata-modules/workspace-migration/constants/fieldMetadataTypesToTextColumnType';
import { formatColumnNamesFromCompositeFieldAndSubfields } from 'src/engine/twenty-orm/utils/format-column-names-from-composite-field-and-subfield.util';
import { isDefined } from 'src/utils/is-defined';

Expand Down Expand Up @@ -50,14 +49,9 @@ export class ProcessAggregateHelper {

const concatenatedColumns = columnNames
.map((col) => `"${col}"`)
.join(", ' ', ");
.join(',');

const columnExpression =
FIELD_METADATA_TYPES_TO_TEXT_COLUMN_TYPE.includes(
aggregatedField.fromFieldType,
)
? `NULLIF(CONCAT(${concatenatedColumns}), '')`
: `CONCAT(${concatenatedColumns})`;
const columnExpression = `NULLIF(CONCAT(${concatenatedColumns}), '')`;

switch (aggregatedField.aggregateOperation) {
case AGGREGATE_OPERATIONS.countEmpty:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getSubfieldsForAggregateOperation = (
case FieldMetadataType.LINKS:
return ['primaryLinkUrl'];
case FieldMetadataType.ACTOR:
return ['workspaceMemberId'];
return ['workspaceMemberId', 'source'];
case FieldMetadataType.EMAILS:
return ['primaryEmail'];
case FieldMetadataType.PHONES:
Expand Down

0 comments on commit 585212b

Please sign in to comment.