fix occupant name test

deepsource-autofix-76c6eb20
Dan Gowans 2023-02-02 11:39:00 -05:00
parent f7b8874b0d
commit b2dc453b44
4 changed files with 7 additions and 6 deletions

View File

@ -76,8 +76,7 @@ export function getOccupantNameWhereClause(occupantName = '', tableAlias = 'o')
if (occupantNamePiece === '') {
continue;
}
sqlWhereClause += ` and (instr(lower(${tableAlias}.occupantName), ?)
or instr(lower(${tableAlias}.occupantFamilyName), ?))`;
sqlWhereClause += ` and (instr(lower(${tableAlias}.occupantName), ?) or instr(lower(${tableAlias}.occupantFamilyName), ?))`;
sqlParameters.push(occupantNamePiece, occupantNamePiece);
}
}

View File

@ -108,8 +108,7 @@ export function getOccupantNameWhereClause(
continue
}
sqlWhereClause += ` and (instr(lower(${tableAlias}.occupantName), ?)
or instr(lower(${tableAlias}.occupantFamilyName), ?))`
sqlWhereClause += ` and (instr(lower(${tableAlias}.occupantName), ?) or instr(lower(${tableAlias}.occupantFamilyName), ?))`
sqlParameters.push(occupantNamePiece, occupantNamePiece)
}
}

View File

@ -200,7 +200,8 @@ describe('functions.sqlFilters', () => {
describe('OccupantName filter', () => {
it('returns filter', () => {
const filter = sqlFilterFunctions.getOccupantNameWhereClause('TEST1 TEST2', 'o');
assert.strictEqual(filter.sqlWhereClause, ' and instr(lower(o.occupantName), ?) and instr(lower(o.occupantName), ?)');
assert.strictEqual(filter.sqlWhereClause, ' and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?)) and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?))');
assert.ok(filter.sqlParameters.length === 4);
assert.ok(filter.sqlParameters.includes('test1'));
assert.ok(filter.sqlParameters.includes('test2'));
});

View File

@ -346,9 +346,11 @@ describe('functions.sqlFilters', () => {
assert.strictEqual(
filter.sqlWhereClause,
' and instr(lower(o.occupantName), ?) and instr(lower(o.occupantName), ?)'
' and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?)) and (instr(lower(o.occupantName), ?) or instr(lower(o.occupantFamilyName), ?))'
)
assert.ok(filter.sqlParameters.length === 4)
assert.ok(filter.sqlParameters.includes('test1'))
assert.ok(filter.sqlParameters.includes('test2'))
})