diff --git a/helpers/lotOccupancyDB/getLotOccupancies.js b/helpers/lotOccupancyDB/getLotOccupancies.js index 2dace040..15e389c3 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.js +++ b/helpers/lotOccupancyDB/getLotOccupancies.js @@ -37,7 +37,10 @@ function buildWhereClause(filters) { } if ((filters.occupancyEffectiveDateString ?? '') !== '') { sqlWhereClause += - ' and (o.occupancyStartDate <= ? and (o.occupancyEndDate is null or o.occupancyEndDate >= ?))'; + ` and ( + o.occupancyEndDate is null + or (o.occupancyStartDate <= ? and o.occupancyEndDate >= ?) + )`; sqlParameters.push(dateStringToInteger(filters.occupancyEffectiveDateString), dateStringToInteger(filters.occupancyEffectiveDateString)); } if ((filters.mapId ?? '') !== '') { diff --git a/helpers/lotOccupancyDB/getLotOccupancies.ts b/helpers/lotOccupancyDB/getLotOccupancies.ts index 61cf481d..48e4ea95 100644 --- a/helpers/lotOccupancyDB/getLotOccupancies.ts +++ b/helpers/lotOccupancyDB/getLotOccupancies.ts @@ -98,7 +98,10 @@ function buildWhereClause(filters: GetLotOccupanciesFilters): { if ((filters.occupancyEffectiveDateString ?? '') !== '') { sqlWhereClause += - ' and (o.occupancyStartDate <= ? and (o.occupancyEndDate is null or o.occupancyEndDate >= ?))' + ` and ( + o.occupancyEndDate is null + or (o.occupancyStartDate <= ? and o.occupancyEndDate >= ?) + )` sqlParameters.push( dateStringToInteger(filters.occupancyEffectiveDateString!), dateStringToInteger(filters.occupancyEffectiveDateString!)