Remove check unique position (#5760)
Currently position can be the same for records displayed in a board view. Removing unicity check until we find a new startegy.
This commit is contained in:
@ -46,25 +46,18 @@ describe('RecordPositionFactory', () => {
|
|||||||
it('should return the value when value is a number', async () => {
|
it('should return the value when value is a number', async () => {
|
||||||
const value = 1;
|
const value = 1;
|
||||||
|
|
||||||
workspaceDataSourceService.executeRawQuery.mockResolvedValue([]);
|
|
||||||
|
|
||||||
const result = await factory.create(value, objectMetadata, workspaceId);
|
const result = await factory.create(value, objectMetadata, workspaceId);
|
||||||
|
|
||||||
expect(result).toEqual(value);
|
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 () => {
|
it('should return the existing position -1 when value is first', async () => {
|
||||||
const value = 'first';
|
const value = 'first';
|
||||||
const result = await factory.create(value, objectMetadata, workspaceId);
|
const result = await factory.create(value, objectMetadata, workspaceId);
|
||||||
|
|
||||||
expect(result).toEqual(0);
|
expect(result).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the existing position + 1 when value is last', async () => {
|
it('should return the existing position + 1 when value is last', async () => {
|
||||||
const value = 'last';
|
const value = 'last';
|
||||||
const result = await factory.create(value, objectMetadata, workspaceId);
|
const result = await factory.create(value, objectMetadata, workspaceId);
|
||||||
|
|||||||
@ -26,20 +26,6 @@ export class RecordPositionFactory {
|
|||||||
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
this.workspaceDataSourceService.getSchemaName(workspaceId);
|
||||||
|
|
||||||
if (typeof value === 'number') {
|
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;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user