kazu2012 / persevere-framework

Automatically exported from code.google.com/p/persevere-framework
0 stars 0 forks source link

multiple sort not working #233

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. create objects in /example/
{name:"foo", extra:1}
{name:"foo", extra:2}
{name:"bar", extra:1}
2. query: /example/[/name, \extra]

What is the expected output? What do you see instead?
second sort criterion is ignored.

What version of the product are you using? On what operating system?
nightly from last night (2009-Aug-18), linux

Please provide any additional information below.

Original issue reported on code.google.com by elf...@gmail.com on 20 Aug 2009 at 6:16

GoogleCodeExporter commented 8 years ago
I believe in server.js, this is what was meant to be (or something similar?):
return ".fastSort(" +
oper[1].replace(/\s*,?\s*([\/\\])\s*([^,\\\/]+)/g,function(t,a,b){return (first 
?
(first=false) || '': ').fastSort(') + "function($obj){return " + b + "}," + (a==
"/");}) + ")";

instead of this:
return ".fastSort(" +
oper[1].replace(/\s*,?\s*([\/\\])\s*([^,\\\/]+)/g,function(t,a,b){return (first 
?
(first=false) || '': ',') + "function($obj){return " + b + "}," + (a== "/");}) 
+ ")";

Original comment by beau.cro...@gmail.com on 20 Aug 2009 at 11:29

GoogleCodeExporter commented 8 years ago
Or something along the lines of (in PersistableArray.java):
if(args.length > 2)
  return Query.parseQuery((Query) id, scope, ((Function)args[0]), true,
ascending).getTarget();
else
  return Query.parseQuery((Query) id, scope, ((Function)args[0]), false,
ascending).getTarget();

I tested against:
curl -g 'http://localhost:8080/test3/[/name,\extra]'
{}&&[
{"id":"3",
    "name":"bar",
    "extra":"1"
},
{"id":"2",
    "name":"foo",
    "extra":"2"
},
{"id":"1",
    "name":"foo",
    "extra":"1"
}
]

AND

curl -g 'http://localhost:8080/test3/[/name,/extra]'
{}&&[
{"id":"3",
    "name":"bar",
    "extra":"1"
},
{"id":"1",
    "name":"foo",
    "extra":"1"
},
{"id":"2",
    "name":"foo",
    "extra":"2"
}
]

This seems to work, but I don't know if this was the proper meaning.

Original comment by beau.cro...@gmail.com on 21 Aug 2009 at 3:49

GoogleCodeExporter commented 8 years ago
Thanks for the suggestion.

Original comment by kris...@gmail.com on 29 Aug 2009 at 4:28