fix: where clause issue (#4023)

This commit is contained in:
Rajat Dabade 2023-11-22 20:32:25 +05:30 committed by GitHub
parent d9950d9223
commit c109636889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,9 +117,15 @@ export function replaceStringWithMaxLength(
array: string[],
replacementString: string,
): string {
const lastSearchValue = array.pop() ?? ''; // Remove the last search value from the array
if (lastSearchValue === '') return `${mainString}${replacementString},`; // if user select direclty from options
return mainString.replace(lastSearchValue, `${replacementString},`);
const lastSearchValue = array.pop() ?? '';
if (lastSearchValue === '') {
return `${mainString}${replacementString},`;
}
const updatedString = mainString.replace(
new RegExp(`${lastSearchValue}(?=[^${lastSearchValue}]*$)`),
replacementString,
);
return `${updatedString},`;
}
export function checkCommaInValue(str: string): string {