@nocobase/database 2.1.0-alpha.15 → 2.1.0-alpha.16
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.
- package/lib/query/builder.js +5 -1
- package/package.json +4 -4
package/lib/query/builder.js
CHANGED
|
@@ -166,6 +166,7 @@ function buildQuery(database, collection, options = {}) {
|
|
|
166
166
|
let hasAgg = false;
|
|
167
167
|
const attributes = [];
|
|
168
168
|
const fieldMap = {};
|
|
169
|
+
const projectedFieldMap = {};
|
|
169
170
|
measures.forEach((measure) => {
|
|
170
171
|
const { field, aggregation, alias, distinct } = measure;
|
|
171
172
|
const col = sequelize.col(field);
|
|
@@ -184,6 +185,7 @@ function buildQuery(database, collection, options = {}) {
|
|
|
184
185
|
}
|
|
185
186
|
attributes.push(attribute.length > 1 ? attribute : attribute[0]);
|
|
186
187
|
fieldMap[alias || field] = measure;
|
|
188
|
+
projectedFieldMap[alias || field] = attribute[0];
|
|
187
189
|
});
|
|
188
190
|
const group = [];
|
|
189
191
|
dimensions.forEach((dimension) => {
|
|
@@ -202,11 +204,13 @@ function buildQuery(database, collection, options = {}) {
|
|
|
202
204
|
group.push(attribute[0]);
|
|
203
205
|
}
|
|
204
206
|
fieldMap[alias || field] = dimension;
|
|
207
|
+
projectedFieldMap[alias || field] = attribute[0];
|
|
205
208
|
});
|
|
206
209
|
const order = orders.map((item) => {
|
|
207
210
|
var _a2;
|
|
208
211
|
const alias = sequelize.getQueryInterface().quoteIdentifier(item.alias);
|
|
209
|
-
const
|
|
212
|
+
const projectedField = projectedFieldMap[item.alias] || projectedFieldMap[item.name] || projectedFieldMap[item.field];
|
|
213
|
+
const name = hasAgg ? projectedField || sequelize.literal(alias) : sequelize.col(item.field);
|
|
210
214
|
let sort = ALLOWED_ORDER_DIRECTIONS.includes((_a2 = item.order) == null ? void 0 : _a2.toUpperCase()) ? item.order.toUpperCase() : "ASC";
|
|
211
215
|
if (item.nulls === "first") {
|
|
212
216
|
sort += " NULLS FIRST";
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/logger": "2.1.0-alpha.
|
|
10
|
-
"@nocobase/utils": "2.1.0-alpha.
|
|
9
|
+
"@nocobase/logger": "2.1.0-alpha.16",
|
|
10
|
+
"@nocobase/utils": "2.1.0-alpha.16",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
39
39
|
"directory": "packages/database"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "14cf3dbdb9f0a9669602de4ad21a9464fa27c105"
|
|
42
42
|
}
|