ts-dynamic-query
Advanced tools
Comparing version 1.0.42 to 1.0.43
@@ -9,3 +9,19 @@ export declare enum SortDirection { | ||
*/ | ||
DESC = 1 | ||
DESC = 1, | ||
/** | ||
* Asc sort direction, null/underfined first | ||
*/ | ||
ASC_NULL_FIRST = 2, | ||
/** | ||
* Desc sort direction, null/underfined first | ||
*/ | ||
DESC_NULL_FIRST = 3, | ||
/** | ||
* Asc sort direction, null/underfined last | ||
*/ | ||
ASC_NULL_LAST = 4, | ||
/** | ||
* Desc sort direction, null/underfined last | ||
*/ | ||
DESC_NULL_LAST = 5 | ||
} |
@@ -13,3 +13,19 @@ "use strict"; | ||
SortDirection[SortDirection["DESC"] = 1] = "DESC"; | ||
/** | ||
* Asc sort direction, null/underfined first | ||
*/ | ||
SortDirection[SortDirection["ASC_NULL_FIRST"] = 2] = "ASC_NULL_FIRST"; | ||
/** | ||
* Desc sort direction, null/underfined first | ||
*/ | ||
SortDirection[SortDirection["DESC_NULL_FIRST"] = 3] = "DESC_NULL_FIRST"; | ||
/** | ||
* Asc sort direction, null/underfined last | ||
*/ | ||
SortDirection[SortDirection["ASC_NULL_LAST"] = 4] = "ASC_NULL_LAST"; | ||
/** | ||
* Desc sort direction, null/underfined last | ||
*/ | ||
SortDirection[SortDirection["DESC_NULL_LAST"] = 5] = "DESC_NULL_LAST"; | ||
})(SortDirection = exports.SortDirection || (exports.SortDirection = {})); | ||
//# sourceMappingURL=sortDirection.js.map |
@@ -8,2 +8,3 @@ import { SortDescriptor } from "../models/sortDescriptor"; | ||
static getRealSorts<T>(sorts: SortDescriptorBase[]): SortDescriptorBase[]; | ||
private static getDefaultValue; | ||
} |
@@ -34,7 +34,9 @@ "use strict"; | ||
var direction = sortDescriptor.direction; | ||
var propValue1 = ts_commons_1.ObjectUtils.getOrDefault(obj1[propertyPath], ts_commons_1.NumberUtils.MIN_SAFE_INTEGER); | ||
var propValue2 = ts_commons_1.ObjectUtils.getOrDefault(obj2[propertyPath], ts_commons_1.NumberUtils.MIN_SAFE_INTEGER); | ||
var propValue1 = this.getDefaultValue(direction, obj1[propertyPath]); | ||
var propValue2 = this.getDefaultValue(direction, obj2[propertyPath]); | ||
var result = 0; | ||
switch (direction) { | ||
case sortDirection_1.SortDirection.ASC: | ||
case sortDirection_1.SortDirection.ASC_NULL_FIRST: | ||
case sortDirection_1.SortDirection.ASC_NULL_LAST: | ||
if (propValue1 === propValue2) { | ||
@@ -51,2 +53,4 @@ result = 0; | ||
case sortDirection_1.SortDirection.DESC: | ||
case sortDirection_1.SortDirection.DESC_NULL_FIRST: | ||
case sortDirection_1.SortDirection.DESC_NULL_LAST: | ||
if (propValue1 === propValue2) { | ||
@@ -81,2 +85,27 @@ result = 0; | ||
}; | ||
SortHelper.getDefaultValue = function (sortDirection, value) { | ||
if (sortDirection == sortDirection_1.SortDirection.ASC_NULL_FIRST && | ||
ts_commons_1.ObjectUtils.isNullOrUndefined(value)) { | ||
return ts_commons_1.NumberUtils.MIN_SAFE_INTEGER; | ||
} | ||
if (sortDirection == sortDirection_1.SortDirection.DESC_NULL_FIRST && | ||
ts_commons_1.ObjectUtils.isNullOrUndefined(value)) { | ||
return ts_commons_1.NumberUtils.MAX_SAFE_INTEGER; | ||
} | ||
if (sortDirection == sortDirection_1.SortDirection.ASC_NULL_LAST && | ||
ts_commons_1.ObjectUtils.isNullOrUndefined(value)) { | ||
return ts_commons_1.NumberUtils.MAX_SAFE_INTEGER; | ||
} | ||
if (sortDirection == sortDirection_1.SortDirection.DESC_NULL_LAST && | ||
ts_commons_1.ObjectUtils.isNullOrUndefined(value)) { | ||
return ts_commons_1.NumberUtils.MIN_SAFE_INTEGER; | ||
} | ||
if (ts_commons_1.ObjectUtils.isNullOrUndefined(value)) { | ||
// default return min value same as mysql | ||
return ts_commons_1.NumberUtils.MIN_SAFE_INTEGER; | ||
} | ||
else { | ||
return value; | ||
} | ||
}; | ||
return SortHelper; | ||
@@ -83,0 +112,0 @@ }()); |
@@ -51,3 +51,2 @@ "use strict"; | ||
this.sorts.push(sort); | ||
sortOption; | ||
return this; | ||
@@ -54,0 +53,0 @@ }; |
{ | ||
"name": "ts-dynamic-query", | ||
"version": "1.0.42", | ||
"version": "1.0.43", | ||
"description": "", | ||
@@ -8,31 +8,31 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"class-transformer": "^0.1.9", | ||
"class-transformer": "0.1.9", | ||
"ts-commons": "~1.0.29" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@types/chai": "^4.1.4", | ||
"@types/mocha": "^5.2.5", | ||
"babel-loader": "^8.0.0", | ||
"browserify": "^16.2.2", | ||
"chai": "^4.1.2", | ||
"coveralls": "^3.0.2", | ||
"cross-env": "^5.2.0", | ||
"del-cli": "^1.1.0", | ||
"istanbul": "^0.4.5", | ||
"karma": "^3.0.0", | ||
"karma-browserify": "^5.3.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-mocha-reporter": "^2.2.5", | ||
"mocha": "^5.2.0", | ||
"mocha-lcov-reporter": "^1.3.0", | ||
"nyc": "^12.0.2", | ||
"ts-loader": "^4.5.0", | ||
"tslint": "^5.11.0", | ||
"typescript": "^3.0.3", | ||
"uglifyjs-webpack-plugin": "^1.3.0", | ||
"webpack": "^4.17.1", | ||
"webpack-cli": "^3.1.0" | ||
"@babel/core": "7.0.0", | ||
"@types/chai": "4.1.4", | ||
"@types/mocha": "5.2.5", | ||
"babel-loader": "8.0.0", | ||
"browserify": "16.2.2", | ||
"chai": "4.1.2", | ||
"coveralls": "3.0.2", | ||
"cross-env": "5.2.0", | ||
"del-cli": "1.1.0", | ||
"istanbul": "0.4.5", | ||
"karma": "3.0.0", | ||
"karma-browserify": "5.3.0", | ||
"karma-chai": "0.1.0", | ||
"karma-firefox-launcher": "1.1.0", | ||
"karma-mocha": "1.3.0", | ||
"karma-mocha-reporter": "2.2.5", | ||
"mocha": "5.2.0", | ||
"mocha-lcov-reporter": "1.3.0", | ||
"nyc": "12.0.2", | ||
"ts-loader": "4.5.0", | ||
"tslint": "5.11.0", | ||
"typescript": "3.0.3", | ||
"uglifyjs-webpack-plugin": "1.3.0", | ||
"webpack": "4.17.1", | ||
"webpack-cli": "3.1.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
162413
55
1198
0
+ Addedclass-transformer@0.1.9(transitive)
- Removedclass-transformer@0.1.10(transitive)
Updatedclass-transformer@0.1.9