Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return one empty result for empty patterns #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion spec/store_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 { <http://example/book3> <http://example.com/vocab#title> <http://test.com/example> }', function (err, result) {
expect(err).toBe(null);
store.execute('SELECT * { ?s ?p ?o }', function (err, results) {
Expand All @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions src/query_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down