Skip to content

Commit

Permalink
Remove check unique position (twentyhq#5760)
Browse files Browse the repository at this point in the history
Currently position can be the same for records displayed in a board
view.
Removing unicity check until we find a new startegy.
  • Loading branch information
thomtrp authored Jun 6, 2024
1 parent c1371b4 commit a91db2f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,18 @@ describe('RecordPositionFactory', () => {
it('should return the value when value is a number', async () => {
const value = 1;

workspaceDataSourceService.executeRawQuery.mockResolvedValue([]);

const result = await factory.create(value, objectMetadata, workspaceId);

expect(result).toEqual(value);
});
it('should throw an error when position is not unique', async () => {
const value = 1;

await expect(
factory.create(value, objectMetadata, workspaceId),
).rejects.toThrow('Position is not unique');
});
it('should return the existing position -1 when value is first', async () => {
const value = 'first';
const result = await factory.create(value, objectMetadata, workspaceId);

expect(result).toEqual(0);
});

it('should return the existing position + 1 when value is last', async () => {
const value = 'last';
const result = await factory.create(value, objectMetadata, workspaceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@ export class RecordPositionFactory {
this.workspaceDataSourceService.getSchemaName(workspaceId);

if (typeof value === 'number') {
const recordWithSamePosition = await this.findRecordPosition(
{
recordPositionQueryType: RecordPositionQueryType.FIND_BY_POSITION,
positionValue: value,
},
objectMetadata,
dataSourceSchema,
workspaceId,
);

if (recordWithSamePosition) {
throw new Error('Position is not unique');
}

return value;
}

Expand Down

0 comments on commit a91db2f

Please sign in to comment.