@nocobase/database 1.0.0-alpha.3 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,15 +117,21 @@ const _OptionsParser = class _OptionsParser {
117
117
  * @protected
118
118
  */
119
119
  parseSort(filterParams) {
120
- var _a;
120
+ var _a, _b;
121
121
  let sort = ((_a = this.options) == null ? void 0 : _a.sort) || [];
122
122
  if (typeof sort === "string") {
123
123
  sort = sort.split(",");
124
124
  }
125
+ const primaryKeyField = this.model.primaryKeyAttribute;
126
+ if (primaryKeyField && !((_b = this.options) == null ? void 0 : _b.group)) {
127
+ if (!sort.includes(primaryKeyField)) {
128
+ sort.push(primaryKeyField);
129
+ }
130
+ }
125
131
  const orderParams = [];
126
132
  for (const sortKey of sort) {
127
133
  let direction = sortKey.startsWith("-") ? "DESC" : "ASC";
128
- const sortField = sortKey.replace("-", "").split(".");
134
+ const sortField = sortKey.startsWith("-") ? sortKey.replace("-", "").split(".") : sortKey.split(".");
129
135
  if (this.database.inDialect("postgres", "sqlite")) {
130
136
  direction = `${direction} NULLS LAST`;
131
137
  }
package/lib/repository.js CHANGED
@@ -198,7 +198,8 @@ const _Repository = class _Repository {
198
198
  fields: []
199
199
  });
200
200
  (_a = options.optionsTransformer) == null ? void 0 : _a.call(options, queryOptions);
201
- const hasAssociationFilter = /* @__PURE__ */ __name(() => {
201
+ delete queryOptions.order;
202
+ const hasAssociationFilter = (() => {
202
203
  if (queryOptions.include && queryOptions.include.length > 0) {
203
204
  const filterInclude = queryOptions.include.filter((include) => {
204
205
  var _a2;
@@ -207,8 +208,8 @@ const _Repository = class _Repository {
207
208
  return filterInclude.length > 0;
208
209
  }
209
210
  return false;
210
- }, "hasAssociationFilter");
211
- if (hasAssociationFilter()) {
211
+ })();
212
+ if (hasAssociationFilter) {
212
213
  const primaryKeyField = this.model.primaryKeyAttribute;
213
214
  const queryInterface = this.database.sequelize.getQueryInterface();
214
215
  const findOptions = {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.5",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "AGPL-3.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "1.0.0-alpha.3",
10
- "@nocobase/utils": "1.0.0-alpha.3",
9
+ "@nocobase/logger": "1.0.0-alpha.5",
10
+ "@nocobase/utils": "1.0.0-alpha.5",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -37,5 +37,5 @@
37
37
  "url": "git+https://github.com/nocobase/nocobase.git",
38
38
  "directory": "packages/database"
39
39
  },
40
- "gitHead": "7ccb137c7616cba5d238f87368239640e1d9ace1"
40
+ "gitHead": "c85c3e8af1b57d7078aa0df4d4cdecb73269f2eb"
41
41
  }