Commit 330ff09437a4b76c0160f61a49138fa84af10289
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
1 changed file
with
4 additions
and
3 deletions
@@ -389,6 +389,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { | @@ -389,6 +389,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { | ||
389 | } else { | 389 | } else { |
390 | entityTypeStr = "'" + entityType.name() + "'"; | 390 | entityTypeStr = "'" + entityType.name() + "'"; |
391 | } | 391 | } |
392 | + | ||
392 | if (!StringUtils.isEmpty(entityFieldsSelection)) { | 393 | if (!StringUtils.isEmpty(entityFieldsSelection)) { |
393 | entityFieldsSelection = String.format("e.id id, %s entity_type, %s", entityTypeStr, entityFieldsSelection); | 394 | entityFieldsSelection = String.format("e.id id, %s entity_type, %s", entityTypeStr, entityFieldsSelection); |
394 | } else { | 395 | } else { |
@@ -442,10 +443,10 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { | @@ -442,10 +443,10 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { | ||
442 | EntityKeyMapping sortOrderMapping = sortOrderMappingOpt.get(); | 443 | EntityKeyMapping sortOrderMapping = sortOrderMappingOpt.get(); |
443 | String direction = sortOrder.getDirection() == EntityDataSortOrder.Direction.ASC ? "asc" : "desc"; | 444 | String direction = sortOrder.getDirection() == EntityDataSortOrder.Direction.ASC ? "asc" : "desc"; |
444 | if (sortOrderMapping.getEntityKey().getType() == EntityKeyType.ENTITY_FIELD) { | 445 | if (sortOrderMapping.getEntityKey().getType() == EntityKeyType.ENTITY_FIELD) { |
445 | - dataQuery = String.format("%s order by %s %s", dataQuery, sortOrderMapping.getValueAlias(), direction); | 446 | + dataQuery = String.format("%s order by %s %s, result.id %s", dataQuery, sortOrderMapping.getValueAlias(), direction, direction); |
446 | } else { | 447 | } else { |
447 | - dataQuery = String.format("%s order by %s %s, %s %s", dataQuery, | ||
448 | - sortOrderMapping.getSortOrderNumAlias(), direction, sortOrderMapping.getSortOrderStrAlias(), direction); | 448 | + dataQuery = String.format("%s order by %s %s, %s %s, result.id %s", dataQuery, |
449 | + sortOrderMapping.getSortOrderNumAlias(), direction, sortOrderMapping.getSortOrderStrAlias(), direction, direction); | ||
449 | } | 450 | } |
450 | } | 451 | } |
451 | } | 452 | } |