fix space search bug
parent
19232ff1b6
commit
6a6081635d
|
|
@ -17,6 +17,9 @@ export function getLotNameWhereClause(lotName = '', lotNameSearchType, lotsTable
|
||||||
default: {
|
default: {
|
||||||
const lotNamePieces = lotName.toLowerCase().split(' ');
|
const lotNamePieces = lotName.toLowerCase().split(' ');
|
||||||
for (const lotNamePiece of lotNamePieces) {
|
for (const lotNamePiece of lotNamePieces) {
|
||||||
|
if (lotNamePiece === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and instr(lower(' + lotsTableAlias + '.lotName), ?)';
|
' and instr(lower(' + lotsTableAlias + '.lotName), ?)';
|
||||||
sqlParameters.push(lotNamePiece);
|
sqlParameters.push(lotNamePiece);
|
||||||
|
|
@ -70,6 +73,9 @@ export function getOccupantNameWhereClause(occupantName = '', tableAlias = 'o')
|
||||||
if (occupantName !== '') {
|
if (occupantName !== '') {
|
||||||
const occupantNamePieces = occupantName.toLowerCase().split(' ');
|
const occupantNamePieces = occupantName.toLowerCase().split(' ');
|
||||||
for (const occupantNamePiece of occupantNamePieces) {
|
for (const occupantNamePiece of occupantNamePieces) {
|
||||||
|
if (occupantNamePiece === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`;
|
sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`;
|
||||||
sqlParameters.push(occupantNamePiece);
|
sqlParameters.push(occupantNamePiece);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ export function getLotNameWhereClause(
|
||||||
default: {
|
default: {
|
||||||
const lotNamePieces = lotName.toLowerCase().split(' ')
|
const lotNamePieces = lotName.toLowerCase().split(' ')
|
||||||
for (const lotNamePiece of lotNamePieces) {
|
for (const lotNamePiece of lotNamePieces) {
|
||||||
|
if (lotNamePiece === '') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
' and instr(lower(' + lotsTableAlias + '.lotName), ?)'
|
' and instr(lower(' + lotsTableAlias + '.lotName), ?)'
|
||||||
sqlParameters.push(lotNamePiece)
|
sqlParameters.push(lotNamePiece)
|
||||||
|
|
@ -100,6 +104,10 @@ export function getOccupantNameWhereClause(
|
||||||
if (occupantName !== '') {
|
if (occupantName !== '') {
|
||||||
const occupantNamePieces = occupantName.toLowerCase().split(' ')
|
const occupantNamePieces = occupantName.toLowerCase().split(' ')
|
||||||
for (const occupantNamePiece of occupantNamePieces) {
|
for (const occupantNamePiece of occupantNamePieces) {
|
||||||
|
if (occupantNamePiece === '') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`
|
sqlWhereClause += ` and instr(lower(${tableAlias}.occupantName), ?)`
|
||||||
sqlParameters.push(occupantNamePiece)
|
sqlParameters.push(occupantNamePiece)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@ export async function getPastLotOccupancyOccupants(filters, options) {
|
||||||
const database = await acquireConnection();
|
const database = await acquireConnection();
|
||||||
let sqlWhereClause = ' where o.recordDelete_timeMillis is null and l.recordDelete_timeMillis is null';
|
let sqlWhereClause = ' where o.recordDelete_timeMillis is null and l.recordDelete_timeMillis is null';
|
||||||
const sqlParameters = [];
|
const sqlParameters = [];
|
||||||
if (filters.searchFilter) {
|
if (filters.searchFilter !== '') {
|
||||||
const searchFilterPieces = filters.searchFilter.split(' ');
|
const searchFilterPieces = filters.searchFilter.split(' ');
|
||||||
for (const searchFilterPiece of searchFilterPieces) {
|
for (const searchFilterPiece of searchFilterPieces) {
|
||||||
|
if (searchFilterPiece === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
" and (o.occupantName like '%' || ? || '%'" +
|
" and (o.occupantName like '%' || ? || '%'" +
|
||||||
" or o.occupantAddress1 like '%' || ? || '%'" +
|
" or o.occupantAddress1 like '%' || ? || '%'" +
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,14 @@ export async function getPastLotOccupancyOccupants(
|
||||||
|
|
||||||
const sqlParameters: unknown[] = []
|
const sqlParameters: unknown[] = []
|
||||||
|
|
||||||
if (filters.searchFilter) {
|
if (filters.searchFilter !== '') {
|
||||||
const searchFilterPieces = filters.searchFilter.split(' ')
|
const searchFilterPieces = filters.searchFilter.split(' ')
|
||||||
|
|
||||||
for (const searchFilterPiece of searchFilterPieces) {
|
for (const searchFilterPiece of searchFilterPieces) {
|
||||||
|
if (searchFilterPiece === '') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
sqlWhereClause +=
|
sqlWhereClause +=
|
||||||
" and (o.occupantName like '%' || ? || '%'" +
|
" and (o.occupantName like '%' || ? || '%'" +
|
||||||
" or o.occupantAddress1 like '%' || ? || '%'" +
|
" or o.occupantAddress1 like '%' || ? || '%'" +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue