Skip to content

Commit

Permalink
[fixes #1359] multiple-column sort problem 修复多字段排序问题
Browse files Browse the repository at this point in the history
If some field aliases, some without an alias is to generate the Order by clause orders the results is not expected
  • Loading branch information
cjy37 committed Nov 24, 2016
1 parent 228d317 commit db78dc3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/waterline/core/transformations.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Transformation.prototype.initialize = function(attributes, tables) {

// Set transformation attr to new key
if (key === 'columnName') {
if (attr === attributes[attr][key]) return;
// if (attr === attributes[attr][key]) return; // cjy37 del
self._transformations[attr] = attributes[attr][key];
}

Expand Down Expand Up @@ -103,8 +103,9 @@ Transformation.prototype.serialize = function(attributes, behavior) {
// Schema must be serialized in first level only
if (behavior === 'schema') {
if (hasOwnProperty(self._transformations, property)) {
obj[self._transformations[property]] = _.clone(obj[property]);
var tmpval = _.clone(obj[property]); // cjy37
delete obj[property];
obj[self._transformations[property]] = tmpval; // cjy37
}
return;
}
Expand All @@ -117,8 +118,9 @@ Transformation.prototype.serialize = function(attributes, behavior) {

// check if object key is in the transformations
if (hasOwnProperty(self._transformations, property)) {
obj[self._transformations[property]] = _.clone(obj[property]);
var tmpval = _.clone(obj[property]); // cjy37
delete obj[property];
obj[self._transformations[property]] = tmpval; // cjy37

return recursiveParse(obj[self._transformations[property]]);
}
Expand All @@ -129,8 +131,10 @@ Transformation.prototype.serialize = function(attributes, behavior) {
// Check if property is a transformation key
if (hasOwnProperty(self._transformations, property)) {

obj[self._transformations[property]] = obj[property];
var tmpval = obj[property]; // cjy37
delete obj[property];
obj[self._transformations[property]] = tmpval; // cjy37

}
});
}
Expand Down

0 comments on commit db78dc3

Please sign in to comment.