-
Notifications
You must be signed in to change notification settings - Fork 690
Closed
Labels
Description
Hi,
I'm trying to built a query that will match against an array value. I think I have my quoting wrong.
I generate alasql_including_query.js to become:
//var alasql = require('/usr/local/lib/node_modules/alasql/alasql.min.js');
if(typeof exports === 'object') {
var assert = require("assert");
var alasql = require('/usr/local/lib/node_modules/alasql/alasql.min.js'); // technically a straight require("alasql") should work
} else {
__dirname = '.';
};
alasql.fn.myDuration = function(secs) {
return Math.floor(secs/60);
}
function stringify_alasql(query) {
alasql(query,[],function(res){
console.log(JSON.stringify(res));
})
}
var result ="SELECT projects, path, application, myDuration([duration]) as minutes FROM json(\"\") WHERE startDate = \"2015-10-07, 10:00 AM\" AND projects = \"[\\\"4. Client Work/4. Client: XX [MCAB-9]\\\"]\" GROUP BY projects, minutes, path, application, duration ;"
stringify_alasql(result)
Where timing_output looks like:
[
{
"path" : "https:\/\/...\/display\/ATL\/Architecture+Approach+1",
"projects" : [
"4. Client Work\/4. Client: XX [MCAB-9]"
],
"endDate" : "2015-10-07, 10:00 AM",
"startDate" : "2015-10-07, 9:00 AM",
"application" : "Safari",
"duration" : 89.99672394990921
},
{
"path" : "https:\/\/...\/display\/ATL\/Atlassian+Enterprise+Architecture",
"projects" : [
"4. Client Work\/4. Client: XX [MCAB-9]"
],
"endDate" : "2015-10-07, 10:00 AM",
"startDate" : "2015-10-07, 9:00 AM",
"application" : "Safari",
"duration" : 67.80467706918716
},
{
"path" : "https:\/\/...\/pages\/editpage.action\/?pageId=41625335",
"projects" : [
"4. Client Work\/4. Client: XX [MCAB-9]"
],
"endDate" : "2015-10-07, 10:00 AM",
"startDate" : "2015-10-07, 9:00 AM",
"application" : "Safari",
"duration" : 81.00990098714828
},
{
"path" : "\/Volumes\/Storage\/martincleaver\/SoftwareDevelopment\/newchoir_sets\/playlist_builder.rb",
"projects" : [
"0. Ambiguous\/X. Ambiguous: Software Development",
"D. Timesuck: Newchoir"
],
"endDate" : "2015-10-07, 9:00 PM",
"startDate" : "2015-10-07, 8:00 PM",
"application" : "RubyMine",
"duration" : 269.991591989994
},
{
"path" : "http:\/\/...\/display\/AR\/2015\/10\/07\/Playlist+Builder+run+for+2015-10-07-20-43-24",
"projects" : [
"D. Timesuck: Newchoir"
],
"endDate" : "2015-10-07, 9:00 PM",
"startDate" : "2015-10-07, 8:00 PM",
"application" : "Safari",
"duration" : 60.54301196336746
}
]
When I run:
$ cat "/tmp/timing_output" | node '/tmp/alasql_including_query.js'
I get:
[{"minutes":null}]
If I omit my where clause I do get results, so I can only conclude that I am quoting the WHERE clause incorrectly.
I would appreciate any help!