Skip to content

Commit

Permalink
fix: Throw error if rows in limit is missing for expand, same as in l…
Browse files Browse the repository at this point in the history
…imit() (#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.
  • Loading branch information
SamuelBrucksch authored Oct 24, 2024
1 parent f3fd254 commit 641c3b9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hana/lib/HANAService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 641c3b9

Please sign in to comment.