mirror of
https://github.com/teableio/teable
synced 2024-11-21 23:04:16 +00:00
fix: rename link results in illegal data (#448)
This commit is contained in:
parent
aa7b944a0d
commit
28238a4898
@ -5,8 +5,8 @@ import { registerAs } from '@nestjs/config';
|
||||
|
||||
export const thresholdConfig = registerAs('threshold', () => ({
|
||||
maxCopyCells: Number(process.env.MAX_COPY_CELLS ?? 50_000),
|
||||
maxResetCells: Number(process.env.MAX_RESET_CELLS ?? 10_000),
|
||||
maxPasteCells: Number(process.env.MAX_PASTE_CELLS ?? 10_000),
|
||||
maxResetCells: Number(process.env.MAX_RESET_CELLS ?? 50_000),
|
||||
maxPasteCells: Number(process.env.MAX_PASTE_CELLS ?? 50_000),
|
||||
maxReadRows: Number(process.env.MAX_READ_ROWS ?? 10_000),
|
||||
maxDeleteRows: Number(process.env.MAX_DELETE_ROWS ?? 1_000),
|
||||
maxSyncUpdateCells: Number(process.env.MAX_SYNC_UPDATE_CELLS ?? 10_000),
|
||||
|
@ -269,9 +269,13 @@ export class FieldSupplementService {
|
||||
private async prepareUpdateLinkField(tableId: string, fieldRo: IFieldRo, oldFieldVo: IFieldVo) {
|
||||
const newOptionsRo = fieldRo.options as ILinkFieldOptionsRo;
|
||||
const oldOptions = oldFieldVo.options as ILinkFieldOptions;
|
||||
// isOneWay may be undefined or false, so we should convert it to boolean
|
||||
const oldIsOneWay = Boolean(oldOptions.isOneWay);
|
||||
const newIsOneWay = Boolean(newOptionsRo.isOneWay);
|
||||
if (
|
||||
oldOptions.foreignTableId === newOptionsRo.foreignTableId &&
|
||||
oldOptions.relationship === newOptionsRo.relationship
|
||||
oldOptions.relationship === newOptionsRo.relationship &&
|
||||
oldIsOneWay !== newIsOneWay
|
||||
) {
|
||||
return {
|
||||
...oldFieldVo,
|
||||
|
@ -223,8 +223,26 @@ describe('OpenAPI Freely perform column transformations (e2e)', () => {
|
||||
},
|
||||
};
|
||||
|
||||
const { newField } = await expectUpdate(table1, linkFieldRo, linkFieldRo2);
|
||||
const linkField = await createField(table1.id, linkFieldRo);
|
||||
await updateRecordByApi(table1.id, table1.records[0].id, linkField.id, {
|
||||
id: table2.records[0].id,
|
||||
});
|
||||
|
||||
const newField = await convertField(table1.id, linkField.id, linkFieldRo2);
|
||||
|
||||
expect(newField.name).toEqual('other name');
|
||||
|
||||
const { name: _, ...newFieldOthers } = newField;
|
||||
const { name: _0, ...oldFieldOthers } = linkField;
|
||||
|
||||
expect(newFieldOthers).toEqual(oldFieldOthers);
|
||||
|
||||
const table2Records = await getRecords(table2.id, { fieldKeyType: FieldKeyType.Id });
|
||||
expect(
|
||||
table2Records.records[0].fields[
|
||||
(linkField.options as ILinkFieldOptions).symmetricFieldId as string
|
||||
]
|
||||
).toMatchObject([{ id: table1.records[0].id }]);
|
||||
});
|
||||
|
||||
it('should modify rollup field name', async () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { RouteConfig } from '@asteasolutions/zod-to-openapi';
|
||||
import type { IFieldVo, IUpdateFieldRo } from '@teable/core';
|
||||
import type { IUpdateFieldRo } from '@teable/core';
|
||||
import { updateFieldRoSchema } from '@teable/core';
|
||||
import { axios } from '../axios';
|
||||
import { registerRoute, urlBuilder } from '../utils';
|
||||
@ -35,7 +35,7 @@ export const UpdateFieldRoute: RouteConfig = registerRoute({
|
||||
});
|
||||
|
||||
export const updateField = async (tableId: string, fieldId: string, fieldRo: IUpdateFieldRo) => {
|
||||
return axios.patch<IFieldVo>(
|
||||
return axios.patch(
|
||||
urlBuilder(UPDATE_FIELD, {
|
||||
tableId,
|
||||
fieldId,
|
||||
|
Loading…
Reference in New Issue
Block a user