From 641c3b97d0571b8b8b7f44e038ffc34ac17c49e5 Mon Sep 17 00:00:00 2001 From: Samuel Brucksch Date: Thu, 24 Oct 2024 08:58:31 +0200 Subject: [PATCH] fix: Throw error if rows in limit is missing for expand, same as in limit() (#858) OData requests like `$expand=xxx($skip=5)` currently fail, because rows is missing which causes a TypeError on HANA. We already have a missing rows check for limit(), so i added the same here. --- hana/lib/HANAService.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hana/lib/HANAService.js b/hana/lib/HANAService.js index 9cdf165b1..18eea7f4d 100644 --- a/hana/lib/HANAService.js +++ b/hana/lib/HANAService.js @@ -333,6 +333,7 @@ class HANAService extends SQLService { } let { limit, one, orderBy, expand, columns = ['*'], localized, count, parent } = q.SELECT + // When one of these is defined wrap the query in a sub query if (expand || (parent && (limit || one || orderBy))) { @@ -421,6 +422,11 @@ class HANAService extends SQLService { } if (parent && (limit || one)) { + if (limit && limit.rows == null) { + // same error as in limit(), but for limits in expand + throw new Error('Rows parameter is missing in SELECT.limit(rows, offset)') + } + // Apply row number limits q.where( one