|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2022, FusionAuth, All Rights Reserved |
| 2 | + * Copyright (c) 2022-2024, FusionAuth, All Rights Reserved |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, |
| 11 | + * software distributed under the License is distributed on an |
| 12 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
| 13 | + * either express or implied. See the License for the specific |
| 14 | + * language governing permissions and limitations under the License. |
3 | 15 | */
|
4 | 16 | package io.fusionauth.domain.search;
|
5 | 17 |
|
@@ -41,11 +53,14 @@ public Set<String> supportedOrderByColumns() {
|
41 | 53 |
|
42 | 54 | @Override
|
43 | 55 | protected String defaultOrderBy() {
|
44 |
| - return "insertInstant ASC"; |
| 56 | + // All memberships for a given group share an insertInstant because they are recreated each time |
| 57 | + // Add userId to provide consistent ordering within a group. The groupId ordering ensures consistency |
| 58 | + // for a single user's memberships across multiple groups if they happen to have the same insertInstant. |
| 59 | + return "insertInstant ASC, userId ASC, groupId ASC"; |
45 | 60 | }
|
46 | 61 |
|
47 | 62 | static {
|
48 |
| - SortableFields.put("id", "id"); |
| 63 | + SortableFields.put("id", "gm.id"); |
49 | 64 | SortableFields.put("insertInstant", "gm.insert_instant");
|
50 | 65 | SortableFields.put("groupId", "gm.groups_id");
|
51 | 66 | SortableFields.put("tenantId", "g.tenants_id");
|
|
0 commit comments