Skip to content

Commit d55560f

Browse files
authored
Merge pull request #574 from neo4j/support-25
Support for Cypher 25 prefix
2 parents 225e29b + 5d7ef2b commit d55560f

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

.changeset/blue-ends-relate.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@neo4j/cypher-builder": patch
3+
---
4+
5+
Add support for `Cypher 25` version prefix:
6+
7+
```js
8+
const { cypher } = matchQuery.build({
9+
cypherVersion: "25",
10+
});
11+
```

src/clauses/Clause.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export type BuildConfig = Partial<{
3333
/** Will prefix generated queries with the Cypher version
3434
* @example `CYPHER 5`
3535
*/
36-
cypherVersion: "5";
36+
cypherVersion: "5" | "25";
3737
/** Prefix variables with given string.
3838
*
3939
* This is useful to avoid name collisions if separate Cypher queries are generated and merged after generating the strings.

tests/build-config/cypher-version.test.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import Cypher from "../../src";
2121

2222
describe("Cypher version", () => {
23-
test("Add cypher version on .build", () => {
23+
test("Add cypher version 5 on .build", () => {
2424
const movieNode = new Cypher.Node();
2525
const pattern = new Cypher.Pattern(movieNode, { labels: ["Movie"] });
2626

@@ -39,6 +39,28 @@ describe("Cypher version", () => {
3939
MATCH (this0:Movie)
4040
WHERE this0.title = $param0
4141
RETURN this0.title"
42+
`);
43+
});
44+
45+
test("Add cypher version 25 on .build", () => {
46+
const movieNode = new Cypher.Node();
47+
const pattern = new Cypher.Pattern(movieNode, { labels: ["Movie"] });
48+
49+
const matchQuery = new Cypher.Match(pattern)
50+
.where(movieNode, {
51+
title: new Cypher.Param("The Matrix"),
52+
})
53+
.return(movieNode.property("title"));
54+
55+
const { cypher } = matchQuery.build({
56+
cypherVersion: "25",
57+
});
58+
59+
expect(cypher).toMatchInlineSnapshot(`
60+
"CYPHER 25
61+
MATCH (this0:Movie)
62+
WHERE this0.title = $param0
63+
RETURN this0.title"
4264
`);
4365
});
4466
});

0 commit comments

Comments
 (0)