@snowtop/ent 0.1.23 → 0.1.24
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/core/base.d.ts +1 -0
- package/core/query_impl.d.ts +1 -0
- package/core/query_impl.js +3 -2
- package/package.json +1 -1
package/core/base.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export interface SelectBaseDataOptions extends DataOptions {
|
|
|
70
70
|
fields: string[];
|
|
71
71
|
fieldsAlias?: string;
|
|
72
72
|
disableFieldsAlias?: boolean;
|
|
73
|
+
disableDefaultOrderByAlias?: boolean;
|
|
73
74
|
}
|
|
74
75
|
export interface SelectDataOptions extends SelectBaseDataOptions {
|
|
75
76
|
key: string;
|
package/core/query_impl.d.ts
CHANGED
package/core/query_impl.js
CHANGED
|
@@ -13,7 +13,8 @@ function getOrderByPhrase(orderby, alias) {
|
|
|
13
13
|
nullsPlacement = " NULLS LAST";
|
|
14
14
|
break;
|
|
15
15
|
}
|
|
16
|
-
const
|
|
16
|
+
const orderByAlias = v.alias ?? alias;
|
|
17
|
+
const col = orderByAlias ? `${orderByAlias}.${v.column}` : v.column;
|
|
17
18
|
return `${col} ${v.direction}${nullsPlacement}`;
|
|
18
19
|
})
|
|
19
20
|
.join(", ");
|
|
@@ -71,7 +72,7 @@ function buildQuery(options) {
|
|
|
71
72
|
parts.push(`GROUP BY ${options.groupby}`);
|
|
72
73
|
}
|
|
73
74
|
if (options.orderby) {
|
|
74
|
-
parts.push(`ORDER BY ${getOrderByPhrase(options.orderby, fieldsAlias)}`);
|
|
75
|
+
parts.push(`ORDER BY ${getOrderByPhrase(options.orderby, options.disableDefaultOrderByAlias ? undefined : fieldsAlias)}`);
|
|
75
76
|
}
|
|
76
77
|
if (options.limit) {
|
|
77
78
|
parts.push(`LIMIT ${options.limit}`);
|