@snowtop/ent 0.1.23 → 0.1.25
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/clause.js +7 -7
- 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/clause.js
CHANGED
|
@@ -591,7 +591,7 @@ function ArrayNotEq(col, value) {
|
|
|
591
591
|
exports.ArrayNotEq = ArrayNotEq;
|
|
592
592
|
function Eq(col, value, overrideAlias) {
|
|
593
593
|
return new simpleClause(col, value, "=", {
|
|
594
|
-
handleNull: new isNullClause(col),
|
|
594
|
+
handleNull: new isNullClause(col, overrideAlias),
|
|
595
595
|
overrideAlias,
|
|
596
596
|
});
|
|
597
597
|
}
|
|
@@ -870,7 +870,7 @@ exports.JSONPathValuePredicate = JSONPathValuePredicate;
|
|
|
870
870
|
function JSONKeyExists(dbCol, val, overrideAlias) {
|
|
871
871
|
return new simpleClause(dbCol, val, "?", {
|
|
872
872
|
// TODO ola: does isNullClause make sense here???
|
|
873
|
-
handleNull: new isNullClause(dbCol),
|
|
873
|
+
handleNull: new isNullClause(dbCol, overrideAlias),
|
|
874
874
|
overrideAlias,
|
|
875
875
|
});
|
|
876
876
|
}
|
|
@@ -952,35 +952,35 @@ exports.PaginationMultipleColsQuery = PaginationMultipleColsQuery;
|
|
|
952
952
|
// These 5 are used on the RHS of an expression
|
|
953
953
|
function Add(col, value, overrideAlias) {
|
|
954
954
|
return new simpleClause(col, value, "+", {
|
|
955
|
-
handleNull: new isNullClause(col),
|
|
955
|
+
handleNull: new isNullClause(col, overrideAlias),
|
|
956
956
|
overrideAlias,
|
|
957
957
|
});
|
|
958
958
|
}
|
|
959
959
|
exports.Add = Add;
|
|
960
960
|
function Subtract(col, value, overrideAlias) {
|
|
961
961
|
return new simpleClause(col, value, "-", {
|
|
962
|
-
handleNull: new isNullClause(col),
|
|
962
|
+
handleNull: new isNullClause(col, overrideAlias),
|
|
963
963
|
overrideAlias,
|
|
964
964
|
});
|
|
965
965
|
}
|
|
966
966
|
exports.Subtract = Subtract;
|
|
967
967
|
function Multiply(col, value, overrideAlias) {
|
|
968
968
|
return new simpleClause(col, value, "*", {
|
|
969
|
-
handleNull: new isNullClause(col),
|
|
969
|
+
handleNull: new isNullClause(col, overrideAlias),
|
|
970
970
|
overrideAlias,
|
|
971
971
|
});
|
|
972
972
|
}
|
|
973
973
|
exports.Multiply = Multiply;
|
|
974
974
|
function Divide(col, value, overrideAlias) {
|
|
975
975
|
return new simpleClause(col, value, "/", {
|
|
976
|
-
handleNull: new isNullClause(col),
|
|
976
|
+
handleNull: new isNullClause(col, overrideAlias),
|
|
977
977
|
overrideAlias,
|
|
978
978
|
});
|
|
979
979
|
}
|
|
980
980
|
exports.Divide = Divide;
|
|
981
981
|
function Modulo(col, value, overrideAlias) {
|
|
982
982
|
return new simpleClause(col, value, "%", {
|
|
983
|
-
handleNull: new isNullClause(col),
|
|
983
|
+
handleNull: new isNullClause(col, overrideAlias),
|
|
984
984
|
overrideAlias,
|
|
985
985
|
});
|
|
986
986
|
}
|
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}`);
|