Browse Source

fix: wrap nested add update query select part to avoid issue when referencing same table

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/1757/head
Pranav C 3 years ago
parent
commit
19a0eee9b4
  1. 22
      packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

22
packages/nocodb/src/lib/dataMapper/lib/sql/BaseModelSqlv2.ts

@ -1864,10 +1864,13 @@ class BaseModelSqlv2 {
{
await this.dbDriver(childTable.table_name)
.update({
[childColumn.column_name]: this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, rowId))
.first()
[childColumn.column_name]: this.dbDriver.from(
this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, rowId))
.first()
.as('___cn_alias')
)
})
.where(_wherePk(childTable.primaryKeys, childId));
}
@ -1876,10 +1879,13 @@ class BaseModelSqlv2 {
{
await this.dbDriver(childTable.table_name)
.update({
[childColumn.column_name]: this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, childId))
.first()
[childColumn.column_name]: this.dbDriver.from(
this.dbDriver(parentTable.table_name)
.select(parentColumn.column_name)
.where(_wherePk(parentTable.primaryKeys, childId))
.first()
.as('___cn_alias')
)
})
.where(_wherePk(childTable.primaryKeys, rowId));
}

Loading…
Cancel
Save