Skip to content

Commit b2ad14e

Browse files
DrRaiderSteveBunlon
authored andcommitted
[*] Has Many Relationships - Fix sorting on hasMany fields in related data (#360)
1 parent b0c0a44 commit b2ad14e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Change Log
22

33
## [Unreleased]
4+
### Added
5+
- Has Many Relationships - Enable sorting on belongsTo relationship columns in related data.
46

57
## RELEASE 5.6.0 - 2020-01-14
68
### Added

src/services/query-builder.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ function QueryBuilder(model, opts, params) {
6565

6666
if (params.sort.indexOf('.') !== -1) {
6767
// NOTICE: Sort on the belongsTo displayed field
68-
const [associationName, fieldName] = params.sort.split('.');
68+
const sortingParameters = params.sort.split('.');
69+
const associationName = aliasName ? `${aliasName}->${sortingParameters[0]}` : sortingParameters[0];
70+
const fieldName = sortingParameters[1];
6971
const column = getReferenceField(
7072
Schemas.schemas,
7173
(aliasSchema || schema),

0 commit comments

Comments
 (0)