Backfill position when not input (#5696)

- refactor record position factory and record position query factory
- override position if not present during createMany

To avoid overriding the same positions for all data in createMany, the
logic is:
- if inserted last, use last position + arg index + 1
- if inserted first, use first position - arg index - 1
This commit is contained in:
Thomas Trompette
2024-06-03 15:18:01 +02:00
committed by GitHub
parent a6b8beed68
commit 2886664b62
7 changed files with 298 additions and 122 deletions

View File

@ -31,16 +31,19 @@ export class RecordPositionBackfillService {
const dataSourceSchema =
this.workspaceDataSourceService.getSchemaName(workspaceId);
const query = await this.recordPositionQueryFactory.create(
RecordPositionQueryType.UPDATE,
position,
const [query, params] = await this.recordPositionQueryFactory.create(
{
recordPositionQueryType: RecordPositionQueryType.UPDATE_POSITION,
recordId,
positionValue: position,
},
objectMetadata as ObjectMetadataInterface,
dataSourceSchema,
);
this.workspaceDataSourceService.executeRawQuery(
query,
[position, recordId],
params,
workspaceId,
undefined,
);