groupBy fix + typeMapper fix (#15433)
groupBy fix: when a group's dimension value is NULL, we need to adapt the raw sql (stage: NULL -> stage IS NULL) typeMapper fix: a graphql type should be made non-nullable if was indicated so + does not have a default value. our check on not having a default value was limited to having a null defaultValue instead of having a null or undefined defaultValue. This is a breaking change, but all the queries that were providing a null value for these args were not functioning anyway, and luckily in the FE we declared all queries adding a `!` already.
This commit is contained in:
+6
-2
@@ -1,8 +1,8 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
|
||||
import { isDefined } from 'class-validator';
|
||||
import isEmpty from 'lodash.isempty';
|
||||
import { ObjectRecord } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { type ObjectLiteral } from 'typeorm';
|
||||
|
||||
import { ObjectRecordOrderBy } from 'src/engine/api/graphql/workspace-query-builder/interfaces/object-record.interface';
|
||||
@@ -221,8 +221,12 @@ export class GroupByWithRecordsService {
|
||||
const conditions = groupByDefinitions
|
||||
.map((def, defIndex) => {
|
||||
const paramName = `groupValue_${groupIndex}_${defIndex}`;
|
||||
const paramValue = group[def.alias];
|
||||
|
||||
queryBuilder.setParameter(paramName, group[def.alias]);
|
||||
if (!isDefined(paramValue)) {
|
||||
return `${def.expression} IS NULL`;
|
||||
}
|
||||
queryBuilder.setParameter(paramName, paramValue);
|
||||
|
||||
return `${def.expression} = :${paramName}`;
|
||||
})
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@ import {
|
||||
} from 'graphql';
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { FieldMetadataDefaultValue } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata-default-value.interface';
|
||||
import {
|
||||
@@ -204,7 +205,7 @@ export class TypeMapperService {
|
||||
);
|
||||
}
|
||||
|
||||
if (options.nullable === false && options.defaultValue === null) {
|
||||
if (options.nullable === false && !isDefined(options.defaultValue)) {
|
||||
graphqlType = new GraphQLNonNull(graphqlType) as unknown as T;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user