fix space search bug

deepsource-autofix-76c6eb20
Dan Gowans 2023-01-24 14:45:45 -05:00
parent 19232ff1b6
commit 6a6081635d
4 changed files with 23 additions and 2 deletions

View File

@ -17,6 +17,9 @@ export function getLotNameWhereClause(lotName = '', lotNameSearchType, lotsTable
default: {
const lotNamePieces = lotName.toLowerCase().split(' ');
for (const lotNamePiece of lotNamePieces) {
if (lotNamePiece === '') {
continue;
}
sqlWhereClause +=
' and instr(lower(' + lotsTableAlias + '.lotName), ?)';
sqlParameters.push(lotNamePiece);
@ -70,6 +73,9 @@ export function getOccupantNameWhereClause(occupantName = '', tableAlias = 'o')
if (occupantName !== '') {
const occupantNamePieces = occupantName.toLowerCase().split(' ');
for (const occupantNamePiece of occupantNamePieces) {
if (occupantNamePiece === '') {
continue;
}
sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`;
sqlParameters.push(occupantNamePiece);
}

View File

@ -30,6 +30,10 @@ export function getLotNameWhereClause(
default: {
const lotNamePieces = lotName.toLowerCase().split(' ')
for (const lotNamePiece of lotNamePieces) {
if (lotNamePiece === '') {
continue
}
sqlWhereClause +=
' and instr(lower(' + lotsTableAlias + '.lotName), ?)'
sqlParameters.push(lotNamePiece)
@ -100,6 +104,10 @@ export function getOccupantNameWhereClause(
if (occupantName !== '') {
const occupantNamePieces = occupantName.toLowerCase().split(' ')
for (const occupantNamePiece of occupantNamePieces) {
if (occupantNamePiece === '') {
continue
}
sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`
sqlParameters.push(occupantNamePiece)
}

View File

@ -3,9 +3,12 @@ export async function getPastLotOccupancyOccupants(filters, options) {
const database = await acquireConnection();
let sqlWhereClause = ' where o.recordDelete_timeMillis is null and l.recordDelete_timeMillis is null';
const sqlParameters = [];
if (filters.searchFilter) {
if (filters.searchFilter !== '') {
const searchFilterPieces = filters.searchFilter.split(' ');
for (const searchFilterPiece of searchFilterPieces) {
if (searchFilterPiece === '') {
continue;
}
sqlWhereClause +=
" and (o.occupantName like '%' || ? || '%'" +
" or o.occupantAddress1 like '%' || ? || '%'" +

View File

@ -21,10 +21,14 @@ export async function getPastLotOccupancyOccupants(
const sqlParameters: unknown[] = []
if (filters.searchFilter) {
if (filters.searchFilter !== '') {
const searchFilterPieces = filters.searchFilter.split(' ')
for (const searchFilterPiece of searchFilterPieces) {
if (searchFilterPiece === '') {
continue
}
sqlWhereClause +=
" and (o.occupantName like '%' || ? || '%'" +
" or o.occupantAddress1 like '%' || ? || '%'" +