also looking at this
fix(browser): stop serialising an exclusion as an inclusion
#1108
2 files
+115
-1
| @@ -525,11 +525,15 @@ export class BrowserQueryBuilder<T = any> { | ||
| 525 | 525 | private buildQueryParams(): URLSearchParams { |
| 526 | 526 | const params = new URLSearchParams() |
| 527 | 527 | |
| 528 | // As in BrowserModelQueryBuilder: `boolean` is not read, so an `orWhere` | |
| 529 | // serialises as an AND. Left alone deliberately — see #1096. | |
| 528 | 530 | // Add where clauses as query params |
| 529 | 531 | for (const where of this.state.wheres) { |
| 530 | 532 | if (where.operator === '=') { |
| 531 | 533 | params.append(where.column, String(where.value)) |
| 532 | 534 | } |
| 535 | // `in` only — `not in` falls through to the filter branch, so an | |
| 536 | // exclusion stays distinguishable from an inclusion (#1096). | |
| 533 | 537 | else if (where.operator === 'in' && Array.isArray(where.value)) { |
| 534 | 538 | params.append(`${where.column}[]`, where.value.join(',')) |
| 535 | 539 | } |
| @@ -970,11 +974,22 @@ else { | ||
| 970 | 974 | private buildQueryParams(): URLSearchParams { |
| 971 | 975 | const params = new URLSearchParams() |
| 972 | 976 | |
| 977 | // `where.boolean` is not read here, so an `orWhere` serialises exactly like | |
| 978 | // a `where` and the server reads it as AND. Representing OR needs a wire | |
| 979 | // format that this file has no precedent for, so it is left alone rather | |
| 980 | // than invented — see #1096. BrowserQueryBuilder.buildQueryParams has the | |
| 981 | // same gap. | |
| 973 | 982 | for (const where of this._wheres) { |
| 974 | 983 | if (where.operator === '=') { |
| 975 | 984 | params.append(where.column, String(where.value)) |
| 976 | 985 | } |
| 977 | else if ((where.operator === 'in' || where.operator === 'not in') && Array.isArray(where.value)) { | |
| 986 | // `in` only. Including `not in` here made an exclusion serialise | |
| 987 | // byte-identically to an inclusion — `whereNotIn('role', ['banned'])` | |
| 988 | // and `whereIn('role', ['banned'])` both sent `role[]=banned`, so the | |
| 989 | // server returned precisely the rows the caller meant to exclude. | |
| 990 | // Falling through to the filter branch below is what the sibling | |
| 991 | // BrowserQueryBuilder already does. See #1096. | |
| 992 | else if (where.operator === 'in' && Array.isArray(where.value)) { | |
| 978 | 993 | params.append(`${where.column}[]`, where.value.join(',')) |
| 979 | 994 | } |
| 980 | 995 | else if (where.operator === 'is' && where.value === null) { |