Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable security/detect-object-injection */
import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import AbstractUseCase from '../../../common/abstract-use.case.js';
import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js';
Expand Down Expand Up @@ -85,23 +84,22 @@ export class DeleteRowFromTableUseCase
const availablePrimaryColumns: Array<string> = primaryColumns.map((column) => column.column_name);

Object.keys(primaryKey).forEach((key) => {
if (
(!primaryKey[key] && primaryKey[key] !== '') ||
(typeof primaryKey[key] === 'object' && !Object.keys(primaryKey[key]).length)
) {
// eslint-disable-next-line security/detect-object-injection
if (!primaryKey[key] && primaryKey[key] !== '') {
// eslint-disable-next-line security/detect-object-injection
delete primaryKey[key];
}
});

// const receivedPrimaryColumns = Object.keys(primaryKey);
// if (!compareArrayElements(availablePrimaryColumns, receivedPrimaryColumns)) {
// throw new HttpException(
// {
// message: Messages.PRIMARY_KEY_INVALID,
// },
// HttpStatus.BAD_REQUEST,
// );
// }
const receivedPrimaryColumns = Object.keys(primaryKey);
if (!compareArrayElements(availablePrimaryColumns, receivedPrimaryColumns)) {
throw new HttpException(
{
message: Messages.PRIMARY_KEY_INVALID,
},
HttpStatus.BAD_REQUEST,
);
}

const tableSettings = await this._dbContext.tableSettingsRepository.findTableSettings(connectionId, tableName);
if (tableSettings && !tableSettings?.can_delete) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable security/detect-object-injection */
import { HttpException, HttpStatus, Inject, Injectable } from '@nestjs/common';
import AbstractUseCase from '../../../common/abstract-use.case.js';
import { IGlobalDatabaseContext } from '../../../common/application/global-database-context.interface.js';
Expand Down Expand Up @@ -97,23 +96,22 @@ export class DeleteRowsFromTableUseCase

primaryKeys.forEach((primaryKey) => {
Object.keys(primaryKey).forEach((key) => {
if (
(!primaryKey[key] && primaryKey[key] !== '') ||
(typeof primaryKey[key] === 'object' && !Object.keys(primaryKey[key]).length)
) {
// eslint-disable-next-line security/detect-object-injection
if (!primaryKey[key] && primaryKey[key] !== '') {
// eslint-disable-next-line security/detect-object-injection
delete primaryKey[key];
}
});

const receivedPrimaryColumns = Object.keys(primaryKey);
// if (!compareArrayElements(availablePrimaryColumns, receivedPrimaryColumns)) {
// throw new HttpException(
// {
// message: Messages.PRIMARY_KEY_INVALID,
// },
// HttpStatus.BAD_REQUEST,
// );
// }
if (!compareArrayElements(availablePrimaryColumns, receivedPrimaryColumns)) {
throw new HttpException(
{
message: Messages.PRIMARY_KEY_INVALID,
},
HttpStatus.BAD_REQUEST,
);
}
});

let oldRowsData: Array<Record<string, unknown>>;
Expand Down
Loading