fix: cast date filters in viewer search #11

Merged
tanyar09 merged 1 commits from fix/viewer-search-date-filter into dev 2026-01-28 13:17:39 -05:00
Showing only changes of commit 1d35f4ab5a - Show all commits

View File

@ -171,12 +171,14 @@ export async function GET(request: NextRequest) {
if (dateFrom || dateTo) {
if (dateFrom) {
whereConditions.push(`date_taken >= $${paramIndex}`);
// Cast param to DATE to avoid "operator does not exist: date >= text" in Postgres
whereConditions.push(`date_taken >= $${paramIndex}::date`);
params.push(dateFrom);
paramIndex++;
}
if (dateTo) {
whereConditions.push(`date_taken <= $${paramIndex}`);
// Cast param to DATE to avoid "operator does not exist: date <= text" in Postgres
whereConditions.push(`date_taken <= $${paramIndex}::date`);
params.push(dateTo);
paramIndex++;
}