Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixMalfait committed Jun 20, 2024
1 parent f2dfa9b commit ea8a703
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const useCreateManyRecords = <
) => {
const sanitizedCreateManyRecordsInput = recordsToCreate.map(
(recordToCreate) => {
const idForCreation = recordToCreate?.id ?? v4();
const idForCreation = recordToCreate?.id ?? (upsert ? null : v4());

return {
...sanitizeRecordInput({
Expand All @@ -68,8 +68,12 @@ export const useCreateManyRecords = <
const recordsCreatedInCache = [];

for (const recordToCreate of sanitizedCreateManyRecordsInput) {
if (recordToCreate.id === null) {
continue;
}

const recordCreatedInCache = createOneRecordInCache({
...recordToCreate,
...(recordToCreate as { id: string }),
__typename: getObjectTypename(objectMetadataItem.nameSingular),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ArgsAliasFactory } from 'src/engine/api/graphql/workspace-query-builder
import { FieldsStringFactory } from 'src/engine/api/graphql/workspace-query-builder/factories/fields-string.factory';
import { FindDuplicatesQueryFactory } from 'src/engine/api/graphql/workspace-query-builder/factories/find-duplicates-query.factory';
import { workspaceQueryBuilderOptionsMock } from 'src/engine/api/graphql/workspace-query-builder/__mocks__/workspace-query-builder-options.mock';
import { DuplicateService } from 'src/engine/core-modules/duplicate/duplicate.service';

describe('FindDuplicatesQueryFactory', () => {
let service: FindDuplicatesQueryFactory;
Expand All @@ -32,6 +33,15 @@ describe('FindDuplicatesQueryFactory', () => {
// Mock implementation of ArgsAliasFactory methods if needed
},
},
{
provide: DuplicateService,
useValue: {
buildDuplicateCondition: jest.fn().mockReturnValue({
field: 'field',
value: 'value',
}),
},
},
],
}).compile();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class UpdateOneQueryFactory {

const argsData = {
...computedArgs.data,
id: undefined, // do nott allow updating the main id
updatedAt: new Date().toISOString(),
};

Expand Down

0 comments on commit ea8a703

Please sign in to comment.