flowquery 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/python-publish.yml +8 -9
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/pattern_expression.d.ts +1 -0
- package/dist/graph/pattern_expression.d.ts.map +1 -1
- package/dist/graph/pattern_expression.js +14 -3
- package/dist/graph/pattern_expression.js.map +1 -1
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +6 -5
- package/dist/parsing/parser.js.map +1 -1
- package/docs/flowquery.min.js +1 -1
- package/flowquery-py/CONTRIBUTING.md +127 -0
- package/flowquery-py/README.md +13 -112
- package/flowquery-py/pyproject.toml +1 -1
- package/flowquery-py/src/graph/pattern_expression.py +6 -3
- package/flowquery-py/src/io/command_line.py +44 -2
- package/flowquery-py/src/parsing/base_parser.py +2 -2
- package/flowquery-py/src/parsing/operations/load.py +6 -0
- package/flowquery-py/src/parsing/parser.py +4 -5
- package/flowquery-py/src/tokenization/token.py +122 -176
- package/flowquery-py/src/tokenization/tokenizer.py +4 -4
- package/flowquery-py/tests/parsing/test_parser.py +6 -0
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/package.json +1 -1
- package/src/graph/pattern_expression.ts +14 -3
- package/src/parsing/parser.ts +7 -4
- package/tests/parsing/parser.test.ts +8 -0
package/package.json
CHANGED
|
@@ -10,11 +10,22 @@ class PatternExpression extends Pattern {
|
|
|
10
10
|
throw new Error("Cannot set identifier on PatternExpression");
|
|
11
11
|
}
|
|
12
12
|
public addElement(element: Relationship | Node): void {
|
|
13
|
-
if (this._chain.length == 0 && !(element instanceof NodeReference)) {
|
|
14
|
-
throw new Error("PatternExpression must start with a NodeReference");
|
|
15
|
-
}
|
|
16
13
|
super.addElement(element);
|
|
17
14
|
}
|
|
15
|
+
public verify(): void {
|
|
16
|
+
if (this._chain.length === 0) {
|
|
17
|
+
throw new Error("PatternExpression must contain at least one element");
|
|
18
|
+
}
|
|
19
|
+
const referenced = this._chain.some((element) => {
|
|
20
|
+
if (element instanceof NodeReference) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
});
|
|
25
|
+
if (!referenced) {
|
|
26
|
+
throw new Error("PatternExpression must contain at least one NodeReference");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
18
29
|
public async evaluate(): Promise<void> {
|
|
19
30
|
this._evaluation = false;
|
|
20
31
|
this.endNode.todoNext = async () => {
|
package/src/parsing/parser.ts
CHANGED
|
@@ -516,9 +516,6 @@ class Parser extends BaseParser {
|
|
|
516
516
|
if (node === null) {
|
|
517
517
|
throw new Error("Expected node definition");
|
|
518
518
|
}
|
|
519
|
-
if (!(node instanceof NodeReference)) {
|
|
520
|
-
throw new Error("PatternExpression must start with a NodeReference");
|
|
521
|
-
}
|
|
522
519
|
pattern.addElement(node);
|
|
523
520
|
let relationship: Relationship | null = null;
|
|
524
521
|
while (true) {
|
|
@@ -536,6 +533,7 @@ class Parser extends BaseParser {
|
|
|
536
533
|
}
|
|
537
534
|
pattern.addElement(node);
|
|
538
535
|
}
|
|
536
|
+
pattern.verify();
|
|
539
537
|
return pattern;
|
|
540
538
|
}
|
|
541
539
|
|
|
@@ -709,7 +707,12 @@ class Parser extends BaseParser {
|
|
|
709
707
|
const lookup = this.parseLookup(func);
|
|
710
708
|
expression.addNode(lookup);
|
|
711
709
|
}
|
|
712
|
-
} else if (
|
|
710
|
+
} else if (
|
|
711
|
+
this.token.isLeftParenthesis() &&
|
|
712
|
+
(this.peek()?.isIdentifier() ||
|
|
713
|
+
this.peek()?.isColon() ||
|
|
714
|
+
this.peek()?.isRightParenthesis())
|
|
715
|
+
) {
|
|
713
716
|
// Possible graph pattern expression
|
|
714
717
|
const pattern = this.parsePatternExpression();
|
|
715
718
|
if (pattern !== null) {
|
|
@@ -752,3 +752,11 @@ test("Parse statement with graph pattern in where clause", () => {
|
|
|
752
752
|
expect(relationship.type).toBe("KNOWS");
|
|
753
753
|
expect(target.label).toBe("Person");
|
|
754
754
|
});
|
|
755
|
+
|
|
756
|
+
test("Test check pattern expression without NodeReference", () => {
|
|
757
|
+
const parser = new Parser();
|
|
758
|
+
// Should throw an error because pattern does not start with NodeReference
|
|
759
|
+
expect(() => {
|
|
760
|
+
parser.parse("MATCH (a:Person) WHERE (:Person)-[:KNOWS]->(:Person) RETURN a");
|
|
761
|
+
}).toThrow("PatternExpression must contain at least one NodeReference");
|
|
762
|
+
});
|