|
|
@ -5457,7 +5457,7 @@ class BaseModelSqlv2 { |
|
|
|
for (const [i, d] of updateDatas.entries()) { |
|
|
|
for (const [i, d] of updateDatas.entries()) { |
|
|
|
const pkValues = getCompositePkValue( |
|
|
|
const pkValues = getCompositePkValue( |
|
|
|
this.model.primaryKeys, |
|
|
|
this.model.primaryKeys, |
|
|
|
this._extractPksValues(d), |
|
|
|
this.extractPksValues(d), |
|
|
|
); |
|
|
|
); |
|
|
|
if (!pkValues) { |
|
|
|
if (!pkValues) { |
|
|
|
// throw or skip if no pk provided
|
|
|
|
// throw or skip if no pk provided
|
|
|
@ -5489,7 +5489,7 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
for (const record of tempToRead) { |
|
|
|
for (const record of tempToRead) { |
|
|
|
const oldRecord = oldRecords.find((r) => |
|
|
|
const oldRecord = oldRecords.find((r) => |
|
|
|
this.comparePks(this._extractPksValues(r), record.pk), |
|
|
|
this.comparePks(this.extractPksValues(r), record.pk), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (!oldRecord) { |
|
|
|
if (!oldRecord) { |
|
|
@ -5600,7 +5600,7 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
await this.prepareNocoData(updateData, false, cookie); |
|
|
|
await this.prepareNocoData(updateData, false, cookie); |
|
|
|
|
|
|
|
|
|
|
|
const pkValues = this._extractPksValues(updateData); |
|
|
|
const pkValues = this.extractPksValues(updateData); |
|
|
|
if (pkValues) { |
|
|
|
if (pkValues) { |
|
|
|
// pk is specified - by pass
|
|
|
|
// pk is specified - by pass
|
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -5699,7 +5699,7 @@ class BaseModelSqlv2 { |
|
|
|
for (const [i, d] of deleteIds.entries()) { |
|
|
|
for (const [i, d] of deleteIds.entries()) { |
|
|
|
const pkValues = getCompositePkValue( |
|
|
|
const pkValues = getCompositePkValue( |
|
|
|
this.model.primaryKeys, |
|
|
|
this.model.primaryKeys, |
|
|
|
this._extractPksValues(d), |
|
|
|
this.extractPksValues(d), |
|
|
|
); |
|
|
|
); |
|
|
|
if (!pkValues) { |
|
|
|
if (!pkValues) { |
|
|
|
// throw or skip if no pk provided
|
|
|
|
// throw or skip if no pk provided
|
|
|
@ -5729,7 +5729,7 @@ class BaseModelSqlv2 { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
for (const { pk, data } of tempToRead) { |
|
|
|
for (const { pk, data } of tempToRead) { |
|
|
|
const oldRecord = oldRecords.find((r) => |
|
|
|
const oldRecord = oldRecords.find((r) => |
|
|
|
this.comparePks(this._extractPksValues(r), pk), |
|
|
|
this.comparePks(this.extractPksValues(r), pk), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (!oldRecord) { |
|
|
|
if (!oldRecord) { |
|
|
@ -6080,7 +6080,7 @@ class BaseModelSqlv2 { |
|
|
|
|
|
|
|
|
|
|
|
public async afterInsert(data: any, _trx: any, req): Promise<void> { |
|
|
|
public async afterInsert(data: any, _trx: any, req): Promise<void> { |
|
|
|
await this.handleHooks('after.insert', null, data, req); |
|
|
|
await this.handleHooks('after.insert', null, data, req); |
|
|
|
const id = this._extractPksValues(data); |
|
|
|
const id = this.extractPksValues(data); |
|
|
|
|
|
|
|
|
|
|
|
let details = ''; |
|
|
|
let details = ''; |
|
|
|
|
|
|
|
|
|
|
@ -6227,7 +6227,7 @@ class BaseModelSqlv2 { |
|
|
|
req, |
|
|
|
req, |
|
|
|
updateObj?: Record<string, any>, |
|
|
|
updateObj?: Record<string, any>, |
|
|
|
): Promise<void> { |
|
|
|
): Promise<void> { |
|
|
|
const id = this._extractPksValues(newData); |
|
|
|
const id = this.extractPksValues(newData); |
|
|
|
let desc = `Record with ID ${id} has been updated in Table ${this.model.title}.`; |
|
|
|
let desc = `Record with ID ${id} has been updated in Table ${this.model.title}.`; |
|
|
|
let details = ''; |
|
|
|
let details = ''; |
|
|
|
if (updateObj) { |
|
|
|
if (updateObj) { |
|
|
@ -6279,7 +6279,7 @@ class BaseModelSqlv2 { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async afterDelete(data: any, _trx: any, req): Promise<void> { |
|
|
|
public async afterDelete(data: any, _trx: any, req): Promise<void> { |
|
|
|
const id = this._extractPksValues(data); |
|
|
|
const id = this.extractPksValues(data); |
|
|
|
await Audit.insert({ |
|
|
|
await Audit.insert({ |
|
|
|
fk_workspace_id: this.model.fk_workspace_id, |
|
|
|
fk_workspace_id: this.model.fk_workspace_id, |
|
|
|
base_id: this.model.base_id, |
|
|
|
base_id: this.model.base_id, |
|
|
@ -6316,7 +6316,7 @@ class BaseModelSqlv2 { |
|
|
|
protected async errorUpdate(_e, _data, _trx, _cookie) {} |
|
|
|
protected async errorUpdate(_e, _data, _trx, _cookie) {} |
|
|
|
|
|
|
|
|
|
|
|
// todo: handle composite primary key
|
|
|
|
// todo: handle composite primary key
|
|
|
|
_extractPksValues(data: any) { |
|
|
|
public extractPksValues(data: any) { |
|
|
|
// data can be still inserted without PK
|
|
|
|
// data can be still inserted without PK
|
|
|
|
|
|
|
|
|
|
|
|
// if composite primary key return an object with all the primary keys
|
|
|
|
// if composite primary key return an object with all the primary keys
|
|
|
@ -6721,7 +6721,7 @@ class BaseModelSqlv2 { |
|
|
|
const oldChildRowId = prevData[column.title] |
|
|
|
const oldChildRowId = prevData[column.title] |
|
|
|
? getCompositePkValue( |
|
|
|
? getCompositePkValue( |
|
|
|
parentTable.primaryKeys, |
|
|
|
parentTable.primaryKeys, |
|
|
|
this._extractPksValues(prevData[column.title]), |
|
|
|
this.extractPksValues(prevData[column.title]), |
|
|
|
) |
|
|
|
) |
|
|
|
: null; |
|
|
|
: null; |
|
|
|
|
|
|
|
|
|
|
@ -6910,7 +6910,7 @@ class BaseModelSqlv2 { |
|
|
|
if (linkedOoRowObj) { |
|
|
|
if (linkedOoRowObj) { |
|
|
|
const oldRowId = getCompositePkValue( |
|
|
|
const oldRowId = getCompositePkValue( |
|
|
|
childTable.primaryKeys, |
|
|
|
childTable.primaryKeys, |
|
|
|
this._extractPksValues(linkedOoRowObj), |
|
|
|
this.extractPksValues(linkedOoRowObj), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (oldRowId) { |
|
|
|
if (oldRowId) { |
|
|
@ -6962,7 +6962,7 @@ class BaseModelSqlv2 { |
|
|
|
if (linkedCurrentOoRowObj) { |
|
|
|
if (linkedCurrentOoRowObj) { |
|
|
|
const oldChildRowId = getCompositePkValue( |
|
|
|
const oldChildRowId = getCompositePkValue( |
|
|
|
childTable.primaryKeys, |
|
|
|
childTable.primaryKeys, |
|
|
|
this._extractPksValues(linkedCurrentOoRowObj), |
|
|
|
this.extractPksValues(linkedCurrentOoRowObj), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (oldChildRowId) { |
|
|
|
if (oldChildRowId) { |
|
|
|