diff --git a/spec/store_spec.js b/spec/store_spec.js index 73cb6562..5d61902c 100644 --- a/spec/store_spec.js +++ b/spec/store_spec.js @@ -5,7 +5,7 @@ describe("Store", function () { it("Should pass integration test #1", function (done) { new Store.Store({name: 'test', overwrite: true}, function (err, store) { - expect(err == null); + expect(err).toBe(null); store.execute('INSERT DATA { }', function (err, result) { expect(err).toBe(null); store.execute('SELECT * { ?s ?p ?o }', function (err, results) { @@ -22,6 +22,32 @@ describe("Store", function () { }); }); + it("Should pass integration test #1a", function (done) { + new Store.Store({name: 'test', overwrite: true}, function (err, store) { + expect(err).toBe(null); + store.execute('SELECT * {}', function (err, results) { + expect(err).toBe(null); + expect(results.length).toBe(1); + store.close(function () { + done(); + }); + }); + }); + }); + + it("Should pass integration test #1b", function (done) { + new Store.Store({name: 'test', overwrite: true}, function (err, store) { + expect(err).toBe(null); + store.execute('SELECT * { OPTIONAL { ?s ?p ?o } }', function (err, results) { + expect(err).toBe(null); + expect(results.length).toBe(1); + store.close(function () { + done(); + }); + }); + }); + }); + it("Should pass integration test #2", function (done) { new Store.Store({treeOrder: 50, name: 'test', overwrite: true}, function (err, store) { expect(err).toBe(null); diff --git a/src/query_engine.js b/src/query_engine.js index e88f9d7b..ab75cfe0 100644 --- a/src/query_engine.js +++ b/src/query_engine.js @@ -949,7 +949,7 @@ QueryEngine.prototype.executeSelectUnit = function(projection, dataset, pattern, }); } else if(pattern.kind === "EMPTY_PATTERN") { // as an example of this case check DAWG test case: algebra/filter-nested-2 - callback([]); + callback([{}]); //} else if(pattern.kind === "ZERO_OR_MORE_PATH" || pattern.kind === 'ONE_OR_MORE_PATH') { // return this.executeZeroOrMorePath(pattern, dataset, env); } else { @@ -1158,8 +1158,11 @@ QueryEngine.prototype.executeLEFT_JOIN = function(projection, dataset, patterns, var setQuery1 = patterns.lvalue; var setQuery2 = patterns.rvalue; if(setQuery1.kind === "EMPTY_PATTERN") { - // LEFT JOIN ( Z | X) => X - this.executeSelectUnit(projection, dataset, setQuery2, env, callback); + // LEFT JOIN ( Z | X) => X; exception: X returns no results + this.executeSelectUnit(projection, dataset, setQuery2, env, function (result) { + if (result != null && result.length > 0) callback(result); + else callback([{}]); + }); } else { var set1 = null; var set2 = null;