From 574acf3e8739a7ca08a492445894b6f00a40fb1d Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Sat, 17 Jan 2026 22:08:23 -0600 Subject: [PATCH] fix: return raw rows from enhanced repository methods (refs #47) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhanced repository methods were incorrectly calling mapRow() which converts snake_case to camelCase, but the service's toEnhancedResponse() expects raw database rows with snake_case properties. This caused "Invalid time value" errors when calling new Date(row.created_at). Fixed methods: - createEnhanced - findByVehicleIdEnhanced - findByUserIdEnhanced - findByIdEnhanced - getPreviousLogByOdometer - getLatestLogForVehicle - updateEnhanced 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../fuel-logs/data/fuel-logs.repository.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/features/fuel-logs/data/fuel-logs.repository.ts b/backend/src/features/fuel-logs/data/fuel-logs.repository.ts index 934936e..f2b9501 100644 --- a/backend/src/features/fuel-logs/data/fuel-logs.repository.ts +++ b/backend/src/features/fuel-logs/data/fuel-logs.repository.ts @@ -293,7 +293,7 @@ export class FuelLogsRepository { data.notes ?? null ]; const res = await this.pool.query(query, values); - return res.rows[0] ? this.mapRow(res.rows[0]) : null; + return res.rows[0] ?? null; } async findByVehicleIdEnhanced(vehicleId: string): Promise { @@ -301,7 +301,7 @@ export class FuelLogsRepository { `SELECT * FROM fuel_logs WHERE vehicle_id = $1 ORDER BY date_time DESC NULLS LAST, date DESC NULLS LAST, created_at DESC`, [vehicleId] ); - return res.rows.map(row => this.mapRow(row)); + return res.rows; } async findByUserIdEnhanced(userId: string): Promise { @@ -309,12 +309,12 @@ export class FuelLogsRepository { `SELECT * FROM fuel_logs WHERE user_id = $1 ORDER BY date_time DESC NULLS LAST, date DESC NULLS LAST, created_at DESC`, [userId] ); - return res.rows.map(row => this.mapRow(row)); + return res.rows; } async findByIdEnhanced(id: string): Promise { const res = await this.pool.query(`SELECT * FROM fuel_logs WHERE id = $1`, [id]); - return res.rows[0] ? this.mapRow(res.rows[0]) : null; + return res.rows[0] ?? null; } async getPreviousLogByOdometer(vehicleId: string, odometerReading: number): Promise { @@ -322,7 +322,7 @@ export class FuelLogsRepository { `SELECT * FROM fuel_logs WHERE vehicle_id = $1 AND odometer IS NOT NULL AND odometer < $2 ORDER BY odometer DESC LIMIT 1`, [vehicleId, odometerReading] ); - return res.rows[0] ? this.mapRow(res.rows[0]) : null; + return res.rows[0] ?? null; } async getLatestLogForVehicle(vehicleId: string): Promise { @@ -330,7 +330,7 @@ export class FuelLogsRepository { `SELECT * FROM fuel_logs WHERE vehicle_id = $1 ORDER BY date_time DESC NULLS LAST, date DESC NULLS LAST, created_at DESC LIMIT 1`, [vehicleId] ); - return res.rows[0] ? this.mapRow(res.rows[0]) : null; + return res.rows[0] ?? null; } async updateEnhanced(id: string, data: { @@ -416,6 +416,6 @@ export class FuelLogsRepository { return null; } - return this.mapRow(result.rows[0]); + return result.rows[0]; } }