Browse Source

Merge pull request #8737 from nocodb/nc-fix/foreign-key-update

fix: Support FK column update(system field) in external dbs
pull/8739/head
Pranav C 6 months ago committed by GitHub
parent
commit
d327b5c50e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 9
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 7
      packages/nocodb/src/models/Model.ts

9
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -3850,7 +3850,6 @@ class BaseModelSqlv2 {
let preInsertOps: (() => Promise<string>)[] = []; let preInsertOps: (() => Promise<string>)[] = [];
let aiPkCol: Column; let aiPkCol: Column;
let agPkCol: Column; let agPkCol: Column;
if (!raw) { if (!raw) {
const columns = await this.model.getColumns(this.context); const columns = await this.model.getColumns(this.context);
@ -3873,7 +3872,11 @@ class BaseModelSqlv2 {
); );
} }
if (col.system && !allowSystemColumn) { if (
col.system &&
!allowSystemColumn &&
col.uidt !== UITypes.ForeignKey
) {
NcError.badRequest( NcError.badRequest(
`Column "${col.title}" is system column and cannot be updated`, `Column "${col.title}" is system column and cannot be updated`,
); );
@ -4950,7 +4953,7 @@ class BaseModelSqlv2 {
); );
} }
if (column.system) { if (column.system && column.uidt !== UITypes.ForeignKey) {
NcError.badRequest( NcError.badRequest(
`Column "${column.title}" is system column and cannot be updated`, `Column "${column.title}" is system column and cannot be updated`,
); );

7
packages/nocodb/src/models/Model.ts

@ -237,11 +237,6 @@ export default class Model implements TableType {
let { list: modelList } = cachedList; let { list: modelList } = cachedList;
const { isNoneList } = cachedList; const { isNoneList } = cachedList;
let condition;
if(source_id){
condition = { source_id }
}
if (!isNoneList && !modelList.length) { if (!isNoneList && !modelList.length) {
modelList = await ncMeta.metaList2( modelList = await ncMeta.metaList2(
context.workspace_id, context.workspace_id,
@ -251,7 +246,7 @@ export default class Model implements TableType {
orderBy: { orderBy: {
order: 'asc', order: 'asc',
}, },
condition, ...(source_id ? { condition: { source_id } } : {}),
}, },
); );

Loading…
Cancel
Save