|
1 | | -const flattenOrderBy = (orderBy: OrderBy<any>[] = []): string => { |
| 1 | +const flattenOrderBy = (orderBy: OrderBy<any>[] = []): string[] => { |
2 | 2 |
|
3 | 3 | const applyModifiers = (property: string, modifier: { TRIM?: boolean; LOWER?: boolean; LENGTH?: boolean }) => { |
4 | 4 | let result = property; |
@@ -48,7 +48,7 @@ const flattenOrderBy = (orderBy: OrderBy<any>[] = []): string => { |
48 | 48 | return `${property} ${sort}`; |
49 | 49 | }; |
50 | 50 |
|
51 | | - return orderBy.map(flattenSingle).join(', '); |
| 51 | + return orderBy.map(flattenSingle); |
52 | 52 | } |
53 | 53 |
|
54 | 54 | export type ComparisonOperator = |
@@ -345,12 +345,22 @@ const evaluateCaseExpression = <FilterProps, PropType>( |
345 | 345 | : evaluateCaseExpression((exp.ELSE as CaseNode<FilterProps, PropType>).CASE, setModifiers, nestedPaths) |
346 | 346 | })`; |
347 | 347 |
|
348 | | -const assembleOrderBy = (orderBy: OrderBy<any>[] = []): Record<string, string> => { |
| 348 | +const assembleOrderBy = (orderBy: OrderBy<any>[] = [], usePost?: boolean): Record<string, string | string[]> => { |
349 | 349 | if(!orderBy.length) { |
350 | 350 | return {} |
351 | 351 | } |
352 | | - const flattedOrderBy = flattenOrderBy(orderBy); |
353 | | - return flattedOrderBy.length ? { orderBy: flattedOrderBy } : {}; |
| 352 | + const flattedOrderByList = flattenOrderBy(orderBy); |
| 353 | + |
| 354 | + if(!flattedOrderByList.length) { |
| 355 | + return {}; |
| 356 | + } |
| 357 | + |
| 358 | + if(usePost) { |
| 359 | + return { orderBy: flattedOrderByList }; |
| 360 | + } |
| 361 | + |
| 362 | + const flattedOrderBy = flattedOrderByList.join(','); |
| 363 | + return { orderBy: flattedOrderBy }; |
354 | 364 | } |
355 | 365 |
|
356 | 366 | const assembleFilterParam = ( |
@@ -404,16 +414,20 @@ const _some = ( |
404 | 414 | const usePost = cfg?.usePost ?? globalConfig?.usePost; |
405 | 415 | const payload = { |
406 | 416 | serializeNulls: query?.serializeNulls, |
407 | | - additionalProperties: query?.properties?.join(','), |
408 | | - properties: query?.select |
409 | | - ? flattenSelect(query.select).join(',') |
| 417 | + additionalProperties: usePost ? query?.properties : query?.properties?.join(','), |
| 418 | + properties: query?.select |
| 419 | + ? usePost |
| 420 | + ? flattenSelect(query.select) |
| 421 | + : flattenSelect(query.select).join(',') |
410 | 422 | : undefined, |
411 | 423 | includeReferencedEntities: query?.include |
412 | | - ? Object.keys(query.include).join(',') |
413 | | - : undefined, |
| 424 | + ? usePost |
| 425 | + ? Object.keys(query.include) |
| 426 | + : Object.keys(query.include).join(',') |
| 427 | + : undefined, |
414 | 428 | ...assembleFilterParam(query?.where), |
415 | | - ...flattenSort(query?.sort), |
416 | | - ...assembleOrderBy(query?.orderBy), |
| 429 | + ...flattenSort(query?.sort, usePost), |
| 430 | + ...assembleOrderBy(query?.orderBy, usePost), |
417 | 431 | ...query?.params, |
418 | 432 | ...query?.pagination |
419 | 433 | }; |
|
0 commit comments