|
|
|
@ -2886,17 +2886,27 @@ class BaseModelSqlv2 {
|
|
|
|
|
if (!raw) await this.validate(d); |
|
|
|
|
const pkValues = await this._extractPksValues(d); |
|
|
|
|
if (!pkValues) { |
|
|
|
|
if (!pkValues) { |
|
|
|
|
if (throwExceptionIfNotExist) |
|
|
|
|
// throw or skip if no pk provided
|
|
|
|
|
if (throwExceptionIfNotExist) { |
|
|
|
|
NcError.unprocessableEntity( |
|
|
|
|
`Record with pk ${JSON.stringify(pkValues)} not found`, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (!raw) { |
|
|
|
|
const oldRecord = await this.readByPk(pkValues); |
|
|
|
|
if (!oldRecord) { |
|
|
|
|
// throw or skip if no record found
|
|
|
|
|
if (throwExceptionIfNotExist) { |
|
|
|
|
NcError.unprocessableEntity( |
|
|
|
|
`Record with pk ${JSON.stringify(pkValues)} not found`, |
|
|
|
|
); |
|
|
|
|
else { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
prevData.push(oldRecord); |
|
|
|
|
} |
|
|
|
|
if (!raw) prevData.push(await this.readByPk(pkValues)); |
|
|
|
|
const wherePk = await this._wherePk(pkValues); |
|
|
|
|
toBeUpdated.push({ d, wherePk }); |
|
|
|
|
updatePkValues.push(pkValues); |
|
|
|
@ -3024,16 +3034,26 @@ class BaseModelSqlv2 {
|
|
|
|
|
for (const d of deleteIds) { |
|
|
|
|
const pkValues = await this._extractPksValues(d); |
|
|
|
|
if (!pkValues) { |
|
|
|
|
// pk not specified - bypass
|
|
|
|
|
// throw or skip if no pk provided
|
|
|
|
|
if (throwExceptionIfNotExist) { |
|
|
|
|
NcError.unprocessableEntity( |
|
|
|
|
`Record with pk ${JSON.stringify(pkValues)} not found`, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const oldRecord = await this.readByPk(pkValues); |
|
|
|
|
if (!oldRecord && throwExceptionIfNotExist) |
|
|
|
|
NcError.unprocessableEntity( |
|
|
|
|
`Record with pk ${JSON.stringify(pkValues)} not found`, |
|
|
|
|
); |
|
|
|
|
deleted.push(oldRecord); |
|
|
|
|
const deletedRecord = await this.readByPk(pkValues); |
|
|
|
|
if (!deletedRecord) { |
|
|
|
|
// throw or skip if no record found
|
|
|
|
|
if (throwExceptionIfNotExist) { |
|
|
|
|
NcError.unprocessableEntity( |
|
|
|
|
`Record with pk ${JSON.stringify(pkValues)} not found`, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
deleted.push(deletedRecord); |
|
|
|
|
|
|
|
|
|
res.push(d); |
|
|
|
|
} |
|
|
|
|