Skip to content

Commit

Permalink
Merge pull request #8737 from nocodb/nc-fix/foreign-key-update
Browse files Browse the repository at this point in the history
fix: Support FK column update(system field) in external dbs
  • Loading branch information
pranavxc committed Jun 13, 2024
2 parents 8737e1c + c467598 commit d327b5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 6 additions & 3 deletions packages/nocodb/src/db/BaseModelSqlv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3850,7 +3850,6 @@ class BaseModelSqlv2 {
let preInsertOps: (() => Promise<string>)[] = [];
let aiPkCol: Column;
let agPkCol: Column;

if (!raw) {
const columns = await this.model.getColumns(this.context);

Expand All @@ -3873,7 +3872,11 @@ class BaseModelSqlv2 {
);
}

if (col.system && !allowSystemColumn) {
if (
col.system &&
!allowSystemColumn &&
col.uidt !== UITypes.ForeignKey
) {
NcError.badRequest(
`Column "${col.title}" is system column and cannot be updated`,
);
Expand Down Expand Up @@ -4950,7 +4953,7 @@ class BaseModelSqlv2 {
);
}

if (column.system) {
if (column.system && column.uidt !== UITypes.ForeignKey) {
NcError.badRequest(
`Column "${column.title}" is system column and cannot be updated`,
);
Expand Down
7 changes: 1 addition & 6 deletions packages/nocodb/src/models/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ export default class Model implements TableType {
let { list: modelList } = cachedList;
const { isNoneList } = cachedList;

let condition;
if(source_id){
condition = { source_id }
}

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

Expand Down

0 comments on commit d327b5c

Please sign in to comment.