Browse Source

fix: keep dtxp property on table create/update

re #1132

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1136/head
Pranav C 3 years ago
parent
commit
22a7841318
  1. 28
      packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts
  2. 11
      packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts
  3. 11
      packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

28
packages/nocodb/src/lib/noco/common/BaseApiBuilder.ts

@ -32,6 +32,7 @@ import ncModelsOrderUpgrader from './jobs/ncModelsOrderUpgrader';
import ncParentModelTitleUpgrader from './jobs/ncParentModelTitleUpgrader';
import ncRemoveDuplicatedRelationRows from './jobs/ncRemoveDuplicatedRelationRows';
import xcMetaDiffSync from './handlers/xcMetaDiffSync';
import UITypes from '../../sqlUi/UITypes';
const log = debug('nc:api:base');
@ -755,11 +756,12 @@ export default abstract class BaseApiBuilder<T extends Noco>
const columns =
changeObj.columns
.filter(c => c.altered !== 4)
.map(({ altered: _al, ...rest }) => ({
...rest,
// find and overwrite column property from db
...(columnsFromDb?.find(c => c.cn === rest.cn) || {})
})) || (await this.getColumnList(tn));
.map(({ altered: _al, ...rest }) =>
this.mergeUiColAndDbColMetas(
rest,
columnsFromDb?.find(c => c.cn === rest.cn)
)
) || (await this.getColumnList(tn));
/* Get all relations */
const relations = await this.relationsSyncAndGet();
@ -1201,6 +1203,22 @@ export default abstract class BaseApiBuilder<T extends Noco>
await NcHelp.executeOperations(aclOper, this.connectionConfig.client);
}
protected mergeUiColAndDbColMetas(uiCol, dbCol) {
return {
...(uiCol || {}),
...(dbCol || {}),
// persist x props for single/multi select
...(uiCol?.uidt === UITypes.SingleSelect ||
uiCol?.uidt === UITypes.MultiSelect
? {
dtx: uiCol.dtx,
dtxp: uiCol.dtxp,
dtxs: uiCol.dtxs
}
: {})
};
}
public async onViewUpdate(
viewName: string,
beforeMetaUpdate?: (args: any) => Promise<void>

11
packages/nocodb/src/lib/noco/gql/GqlApiBuilder.ts

@ -195,11 +195,12 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr {
const columns = args.columns
? {
[tn]: args.columns?.map(({ altered: _al, ...rest }) => ({
...rest,
// find and overwrite column property from db
...columnsFromDb?.find(c => c.cn === rest.cn)
}))
[tn]: args.columns?.map(({ altered: _al, ...rest }) =>
this.mergeUiColAndDbColMetas(
rest,
columnsFromDb?.find(c => c.cn === rest.cn)
)
)
}
: {};

11
packages/nocodb/src/lib/noco/rest/RestApiBuilder.ts

@ -881,11 +881,12 @@ export class RestApiBuilder extends BaseApiBuilder<Noco> {
const columns = args.columns
? {
[tn]: args.columns?.map(({ altered: _al, ...rest }) => ({
...rest,
// find and overwrite column property from db
...(columnsFromDb?.find(c => c.cn === rest.cn) || {})
}))
[tn]: args.columns?.map(({ altered: _al, ...rest }) =>
this.mergeUiColAndDbColMetas(
rest,
columnsFromDb?.find(c => c.cn === rest.cn)
)
)
}
: {};

Loading…
Cancel
Save