Skip to content

Commit f27bb96

Browse files
committed
bug fix
1 parent 60f7c77 commit f27bb96

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/ld-query.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,15 @@
535535
// create an path alias '#document' to represent the root of the current QueryNode json
536536
var stepId = 0;
537537
steps = [{ id: stepId++, path: "#document", directChild: false, tests: [] }];
538+
539+
if(separatedSteps[0] && separatedSteps[0].key) {
540+
541+
// our first step is a bare test but we can't do this on the document as it might be anywhere in the structure
542+
// so we create an empty step to attach the test to in the loop below.
543+
steps.unshift({ id: stepId++, directChild: false, tests: [] });
544+
545+
}
546+
538547
// process the extracted steps, to combine 'where' steps into keys on path steps.
539548
separatedSteps.forEach(function (step) {
540549

0 commit comments

Comments
 (0)