From 449908c833fd2178a2c2aa8cf9f20cfb9a18c481 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Mon, 24 Nov 2025 15:48:15 +0100 Subject: [PATCH] Handle null values consistently and add `deleted_at` checks in `vehiclesRoute` queries - Updated `db_object_t` to treat both `null` and string `'null'` as null values for filtering. - Added `deleted_at IS NULL` condition in `vehiclesRoute` booking-related queries to exclude soft-deleted entries. --- services/nginx/app/routes/vehiclesRoute.php | 4 ++++ services/nginx/app/traits/db_object_t.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/services/nginx/app/routes/vehiclesRoute.php b/services/nginx/app/routes/vehiclesRoute.php index 43140327..fc847a35 100644 --- a/services/nginx/app/routes/vehiclesRoute.php +++ b/services/nginx/app/routes/vehiclesRoute.php @@ -829,12 +829,14 @@ class vehiclesRoute $booking = (new order_bookings_o())->getFieldsWhere([ 'reg_1' => $reg, 'order_id' => null, + 'deleted_at' => null, ], ['id', 'customer_number', 'reference', 'note']); // If there is no booking with the tractor reg, check the trailer reg if (!$booking) { $booking = (new order_bookings_o())->getFieldsWhere([ 'reg_2' => $reg, 'order_id' => null, + 'deleted_at' => null, ], ['id', 'customer_number', 'reference', 'note']); } // Populate other variables @@ -973,6 +975,7 @@ class vehiclesRoute [ 'reg_1' => $search, 'order_id' => null, + 'deleted_at' => null, ...$filters ], ['reg_1'], @@ -982,6 +985,7 @@ class vehiclesRoute [ 'reg_2' => $search, 'order_id' => null, + 'deleted_at' => null, ...$filters ], ['reg_2'], diff --git a/services/nginx/app/traits/db_object_t.php b/services/nginx/app/traits/db_object_t.php index 893ad950..0d077371 100644 --- a/services/nginx/app/traits/db_object_t.php +++ b/services/nginx/app/traits/db_object_t.php @@ -192,7 +192,7 @@ trait db_object_t $where = []; foreach ( $fieldsAndValues as $field => $value ) { // Check if the value is null - if ($value === null) { + if ($value === null || $value === 'null') { $where[] = "$field IS NULL"; continue; }