Permalink
Browse files

normalize() and tests fix

  • Loading branch information...
1 parent aac0d62 commit c7c3d0d02e59936c1bef99f04b5f49a7817eb34a @dvv dvv committed Nov 30, 2010
Showing with 7 additions and 7 deletions.
  1. +4 −4 lib/query.js
  2. +3 −3 test/query.js
View
@@ -184,16 +184,16 @@ Query.prototype.normalize = function(options){
// cache some parameters
if (func === 'sort' || func === 'select') {
result[func] = args;
- result[func+'Arr'] = result[func].map(function(x, pos){
- if (pos === 0 && x instanceof Array) x = x.join('.');
+ result[func+'Arr'] = result[func].map(function(x){
+ if (x instanceof Array) x = x.join('.');
var o = {};
var a = /([-+]*)(.+)/.exec(x);
o[a[2]] = a[1].charAt(0) === '-' ? -1 : 1;
return o;
});
result[func+'Obj'] = {};
- result[func].forEach(function(x, pos){
- if (pos === 0 && x instanceof Array) x = x.join('.');
+ result[func].forEach(function(x){
+ if (x instanceof Array) x = x.join('.');
var a = /([-+]*)(.+)/.exec(x);
result[func+'Obj'][a[2]] = a[1].charAt(0) === '-' ? -1 : 1;
});
View
@@ -172,9 +172,9 @@ exports.testStringification = function() {
// string to array and back
var str = 'somefunc(and(1),(a,b),(10,(10,1)),(a,b.c))';
assert.equal(parseQuery(str)+'', str);
- // arguments with dots
- assert.equal(parseQuery(Query().eq(['a/b','c'],1)+'')+'', 'eq(a%2Fb/c,1)');
- var name = ['a/b','c'];
+ // quirky arguments
+ var name = ['a/b','c.d'];
+ assert.equal(parseQuery(Query().eq(name,1)+'')+'', 'eq(a%2Fb/c.d,1)');
assert.deepEqual(parseQuery(Query().eq(name,1)+'').args[0].args[0], name);
};

0 comments on commit c7c3d0d

Please sign in to comment.