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

@neo4j/cypher-builder 1.0.0 #1

Merged
merged 74 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
af73d65
add delete methods to cypher WITH
a-alle Nov 16, 2022
f0b1860
Merge branch 'dev' into refactor/create-delete-and-params-to-cypherbu…
a-alle Mar 8, 2023
ce4cbf1
Merge branch '4.0.0' into refactor/create-delete-and-params-to-cypher…
a-alle Mar 9, 2023
d224258
implement createDeleteAndParams with cypher builder
a-alle Mar 9, 2023
08f6c0b
fix eslint type import error
a-alle Mar 9, 2023
8046540
code review changes
a-alle Mar 10, 2023
1e8ece9
Merge pull request #2430 from a-alle/refactor/create-delete-and-param…
a-alle Mar 10, 2023
1711037
Merge branch 'dev' into 4.0.0
darrellwarde Mar 10, 2023
0713c2f
Merge remote-tracking branch 'origin/dev' into 4.0.0
angrykoala Mar 24, 2023
a5f1895
Merge branch 'dev' into 4.0.0
mjfwebb Mar 24, 2023
332b36a
Merge branch 'dev' into 4.0.0
mjfwebb Mar 28, 2023
841ca2c
Merge branch 'dev' into 4.0.0
darrellwarde Mar 30, 2023
2f9b1c4
Merge branch 'dev' into 4.0.0
angrykoala Mar 31, 2023
7df81ab
Merge branch 'dev' into 4.0.0
MacondoExpress Apr 4, 2023
6399553
Merge branch 'dev' into 4.0.0
angrykoala Apr 4, 2023
86ce697
Merge remote-tracking branch 'origin/dev' into 4.0.0
angrykoala Apr 5, 2023
08b16e2
Merge branch 'dev' into 4.0.0
angrykoala Apr 5, 2023
2450a2f
Merge branch 'dev' into 4.0.0
angrykoala Apr 11, 2023
7af4a55
Merge branch 'dev' into 4.0.0
darrellwarde Apr 12, 2023
0363e15
Merge remote-tracking branch 'origin/dev' into 4.0.0
angrykoala Apr 24, 2023
a5397d1
Merge remote-tracking branch 'origin/dev' into 4.0.0
angrykoala Apr 26, 2023
c655408
Merge branch 'dev' into 4.0.0
angrykoala Apr 26, 2023
7428600
Fix escaping for relationships
angrykoala Apr 26, 2023
47059da
Merge branch 'dev' into 4.0.0
angrykoala Apr 26, 2023
4216a88
Merge branch '4.0.0' into escape-properties-and-relationships
angrykoala Apr 26, 2023
3e8e44f
Fix cypher builder tests
angrykoala Apr 26, 2023
797f0d9
Merge pull request #3242 from angrykoala/escape-properties-and-relati…
angrykoala Apr 27, 2023
ebcdcc8
merge with dev
MacondoExpress May 9, 2023
9791845
Merge remote-tracking branch 'origin/dev' into 4.0.0
angrykoala May 15, 2023
337559d
Merge remote-tracking branch 'origin/dev' into 4.0.0
angrykoala May 31, 2023
eb8bb02
Merge remote-tracking branch 'origin-2/master' into neo4j-graphql-4
angrykoala Jun 1, 2023
9f96156
Version Packages
neo4j-team-graphql May 30, 2023
25d1599
Merge branch 'master' into neo4j-graphql-4
angrykoala Jun 2, 2023
993aab7
Merge remote-tracking branch 'origin/master' into neo4j-graphql-4
angrykoala Jun 5, 2023
e80269b
Update snapshot tests
angrykoala Jun 5, 2023
b30b997
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 5, 2023
782f6a5
Minor cleanup of Pattern.test.ts
angrykoala Jun 6, 2023
554a58d
Only escape labels
angrykoala Jun 6, 2023
06aa090
Add labels expressions on nodes
angrykoala Jun 6, 2023
6f57eaf
Label expressions for relationships
angrykoala Jun 6, 2023
e818900
Add tsdocs on label expressions
angrykoala Jun 6, 2023
8c4adac
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 6, 2023
03d7036
Merge branch 'neo4j-graphql-4' into fix-escape-labels
angrykoala Jun 6, 2023
eb3e0ff
Merge branch 'fix-escape-labels' into label-expressions
angrykoala Jun 6, 2023
0768a5e
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 7, 2023
9776d94
Merge branch 'neo4j-graphql-4' into fix-escape-labels
angrykoala Jun 7, 2023
c9a869f
Merge branch 'fix-escape-labels' into label-expressions
angrykoala Jun 7, 2023
0c6e13c
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 7, 2023
11476d4
Updates escape utils
angrykoala Jun 7, 2023
2385f46
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 8, 2023
82c91df
Merge remote-tracking branch 'origin/main' into fix-escape-labels
angrykoala Jun 8, 2023
37f3bd9
Merge branch 'neo4j-graphql-4' into fix-escape-labels
angrykoala Jun 8, 2023
d5848e0
Merge branch 'fix-escape-labels' into label-expressions
angrykoala Jun 8, 2023
a374805
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 8, 2023
455cfd8
Remove comment
angrykoala Jun 13, 2023
9a99bcd
Merge pull request #7 from neo4j/label-expressions
angrykoala Jun 13, 2023
f72f8e8
Merge branch 'neo4j-graphql-4' into fix-escape-labels
angrykoala Jun 13, 2023
a931799
Merge pull request #6 from neo4j/fix-escape-labels
angrykoala Jun 13, 2023
6e32c89
Merge remote-tracking branch 'origin/main' into neo4j-graphql-4
angrykoala Jun 13, 2023
0ae565b
Fix failing snapshot
angrykoala Jun 13, 2023
233be64
Merge remote-tracking branch 'origin/main' into neo4j-graphql-4
angrykoala Jun 19, 2023
f7f676d
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 27, 2023
561d5f7
Update tests snapshot
angrykoala Jun 27, 2023
9b9446c
Merge remote-tracking branch 'origin/main' into neo4j-graphql-4
angrykoala Jun 29, 2023
79f4834
Add missing changeset
angrykoala Jun 29, 2023
2ee40d5
Merge branch 'main' into neo4j-graphql-4
angrykoala Jun 30, 2023
2dec1da
Merge remote-tracking branch 'origin/main' into neo4j-graphql-4
angrykoala Jul 3, 2023
91ee39c
Escape variable names if needed
angrykoala Jul 4, 2023
9bfbf7d
Merge branch 'main' into neo4j-graphql-4
angrykoala Jul 5, 2023
8a8c87b
Merge pull request #50 from neo4j/escape-variables
angrykoala Jul 6, 2023
b9a9d80
Merge branch 'main' into neo4j-graphql-4
angrykoala Jul 6, 2023
a910803
Update changeset versioning
angrykoala Jul 6, 2023
c8c8cb1
Merge branch 'main' into neo4j-graphql-4
angrykoala Jul 7, 2023
76d6f7e
Merge branch 'main' into neo4j-graphql-4
angrykoala Jul 10, 2023
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
5 changes: 5 additions & 0 deletions .changeset/afraid-points-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/cypher-builder": major
---

Escape variable names if needed
5 changes: 5 additions & 0 deletions .changeset/cold-singers-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/cypher-builder": major
---

Escape relationship types if needed
11 changes: 11 additions & 0 deletions .changeset/funny-apes-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@neo4j/cypher-builder": minor
---

Support for label expressions for nodes and relationships

For example:

```
(:A&(B|C))
```
8 changes: 8 additions & 0 deletions .changeset/little-wombats-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@neo4j/cypher-builder": patch
---

Updates escape logic so names with numbers are not escaped unless they begin with a number:

- `this0` OK
- `0this` Should be escaped
5 changes: 5 additions & 0 deletions .changeset/rotten-queens-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/cypher-builder": major
---

Escape properties in map projections
5 changes: 5 additions & 0 deletions .changeset/rude-books-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@neo4j/cypher-builder": patch
---

Only escape labels if needed
3 changes: 3 additions & 0 deletions src/Cypher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export { concat } from "./clauses/utils/concat";

// Patterns
export { Pattern } from "./pattern/Pattern";
export { labelExpr } from "./expressions/labels/label-expressions";

// Variables and references
export { NodeRef as Node, NamedNode } from "./references/NodeRef";
Expand Down Expand Up @@ -118,8 +119,10 @@ export type { SetParam } from "./clauses/sub-clauses/Set";
export type { PredicateFunction } from "./expressions/functions/predicate";
export type { Order } from "./clauses/sub-clauses/OrderBy";
export type { CompositeClause } from "./clauses/utils/concat";
export type { LabelExpr, LabelOperator } from "./expressions/labels/label-expressions";
export type { CypherAggregationFunction as AggregationFunction } from "./expressions/functions/aggregation";
export type { HasLabel } from "./expressions/HasLabel";
export type { InputArgument } from "./utils/normalize-variable";

// utils
export * as utils from "./utils/utils";
18 changes: 9 additions & 9 deletions src/apoc/cypher/run-first-column.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("apoc.cypher", () => {
const apocRunFirstColum = Cypher.apoc.cypher.runFirstColumnSingle(subquery, [node]);
const queryResult = new TestClause(apocRunFirstColum).build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"apoc.cypher.runFirstColumnSingle(\\"MATCH (this0:\`Movie\`)
"apoc.cypher.runFirstColumnSingle(\\"MATCH (this0:Movie)
RETURN this0\\", { this0: this0 })"
`);

Expand All @@ -42,7 +42,7 @@ describe("apoc.cypher", () => {
const apocRunFirstColum = Cypher.apoc.cypher.runFirstColumnMany(subquery, [node]);
const queryResult = new TestClause(apocRunFirstColum).build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"apoc.cypher.runFirstColumnMany(\\"MATCH (this0:\`Movie\`)
"apoc.cypher.runFirstColumnMany(\\"MATCH (this0:Movie)
RETURN this0\\", { this0: this0 })"
`);

Expand Down Expand Up @@ -104,13 +104,13 @@ describe("apoc.cypher", () => {
const cypherResult = topQuery.build();

expect(cypherResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
WHERE this0.title = $param0
RETURN { result: apoc.cypher.runFirstColumnMany(\\"MATCH (this0)
SET
this0.released = $param1
RETURN this0\\", { this0: this0, param1: $param1 }) }"
`);
"MATCH (this0:Movie)
WHERE this0.title = $param0
RETURN { result: apoc.cypher.runFirstColumnMany(\\"MATCH (this0)
SET
this0.released = $param1
RETURN this0\\", { this0: this0, param1: $param1 }) }"
`);
expect(cypherResult.params).toMatchInlineSnapshot(`
{
"param0": "The Matrix",
Expand Down
2 changes: 1 addition & 1 deletion src/apoc/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe("apoc.util", () => {

const { cypher, params } = query.build();
expect(cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE apoc.util.validatePredicate(1 = 2, \\"That's not how math works\\", [0])
RETURN this0"
`);
Expand Down
14 changes: 7 additions & 7 deletions src/clauses/Call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("CypherBuilder Call", () => {
const queryResult = new Cypher.Call(createQuery).build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
CREATE (this0:\`Movie\`)
CREATE (this0:Movie)
SET
this0.id = $param0
RETURN this0
Expand All @@ -57,7 +57,7 @@ describe("CypherBuilder Call", () => {
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
CALL {
CREATE (this0:\`Movie\`)
CREATE (this0:Movie)
SET
this0.id = $param0
RETURN this0
Expand All @@ -83,7 +83,7 @@ describe("CypherBuilder Call", () => {
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
WITH this0
MATCH (this0:\`Movie\`)
MATCH (this0:Movie)
WHERE $param0 = $param1
RETURN this0.title AS movie
}"
Expand Down Expand Up @@ -121,7 +121,7 @@ describe("CypherBuilder Call", () => {
const queryResult = clause.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
MATCH (this0:\`Movie\`)
MATCH (this0:Movie)
WHERE $param0 = $param1
RETURN this0.title AS movie
}
Expand All @@ -146,7 +146,7 @@ describe("CypherBuilder Call", () => {
const queryResult = clause.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
MATCH (this0:\`Movie\`)
MATCH (this0:Movie)
WHERE $param0 = $param1
RETURN this0.title AS movie
}
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("CypherBuilder Call", () => {

expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
MATCH (this0:\`Movie\`)
MATCH (this0:Movie)
WHERE $param0 = $param1
RETURN this0.title AS var1
}
Expand Down Expand Up @@ -204,7 +204,7 @@ describe("CypherBuilder Call", () => {

expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
MATCH (this0:\`Movie\`)
MATCH (this0:Movie)
WHERE $param0 = $param1
RETURN this0.title AS var1
}
Expand Down
36 changes: 18 additions & 18 deletions src/clauses/Create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ describe("CypherBuilder Create", () => {

const queryResult = createQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CREATE (this0:\`Movie\` { test: $param0, id: $param1 })
"CREATE (this0:Movie { test: $param0, id: $param1 })
SET
this0.title = $param2,
this0.runtime = $param3
RETURN this0"
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "test-value",
"param1": "my-id",
"param2": "The Matrix",
"param3": 120,
}
`);
{
"param0": "test-value",
"param1": "my-id",
"param2": "The Matrix",
"param3": 120,
}
`);
});

test("Create Node with null property", () => {
Expand All @@ -76,18 +76,18 @@ describe("CypherBuilder Create", () => {

const queryResult = createQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CREATE (this0:\`Movie\` { id: NULL })
"CREATE (this0:Movie { id: NULL })
SET
this0.test = NULL,
this0.nullStr = $param0
RETURN this0"
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "null",
}
`);
{
"param0": "null",
}
`);
});

test("Create Node with null property and assign path variable", () => {
Expand All @@ -110,17 +110,17 @@ describe("CypherBuilder Create", () => {

const queryResult = createQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CREATE p0 = (this1:\`Movie\` { id: NULL })
"CREATE p0 = (this1:Movie { id: NULL })
SET
this1.test = NULL,
this1.nullStr = $param0
RETURN this1"
`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
"param0": "null",
}
`);
{
"param0": "null",
}
`);
});
});
2 changes: 1 addition & 1 deletion src/clauses/Foreach.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("Foreach", () => {
const queryResult = foreachClause.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"FOREACH (var0 IN [1, 2, 3] |
CREATE (this1:\`Movie\`)
CREATE (this1:Movie)
SET
this1.id = var0
)
Expand Down
32 changes: 16 additions & 16 deletions src/clauses/Match.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("CypherBuilder Match", () => {
);

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`"MATCH (this0:\`Movie\` { test: $param0 })"`);
expect(queryResult.cypher).toMatchInlineSnapshot(`"MATCH (this0:Movie { test: $param0 })"`);

expect(queryResult.params).toMatchInlineSnapshot(`
{
Expand All @@ -52,7 +52,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
RETURN this0"
`);

Expand All @@ -74,7 +74,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE (this0.id = $param0 AND this0.name = $param1)
REMOVE this0.name
RETURN this0.id"
Expand All @@ -100,7 +100,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"OPTIONAL MATCH (this0:\`Movie\` { test: $param0 })
"OPTIONAL MATCH (this0:Movie { test: $param0 })
RETURN this0"
`);

Expand Down Expand Up @@ -140,8 +140,8 @@ describe("CypherBuilder Match", () => {

const queryResult = query.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH my-path = (this0)-[this1:ACTED_IN]->(this2)
RETURN my-path"
"MATCH \`my-path\` = (this0)-[this1:ACTED_IN]->(this2)
RETURN \`my-path\`"
`);
expect(queryResult.params).toMatchInlineSnapshot(`{}`);
});
Expand All @@ -167,7 +167,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\` { test: $param0 })
"MATCH (this0:Movie { test: $param0 })
WHERE ((this0.id = $param1 AND this0.name = $param2) AND this0.age = $param3)
RETURN this0"
`);
Expand Down Expand Up @@ -200,7 +200,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\` { test: $param0 })
"MATCH (this0:Movie { test: $param0 })
WHERE (this0.id = $param1 AND this0.name = $param2)
RETURN this0.name AS myAlias"
`);
Expand Down Expand Up @@ -231,7 +231,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\` { test: NULL })
"MATCH (this0:Movie { test: NULL })
WHERE this0.name IS NULL
RETURN this0"
`);
Expand All @@ -254,7 +254,7 @@ describe("CypherBuilder Match", () => {

const queryResult = clause.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE (($param0 > $param1 OR $param0 < $param2) AND $param3 = $param4)
RETURN this0.title AS movie"
`);
Expand All @@ -279,7 +279,7 @@ describe("CypherBuilder Match", () => {

const queryResult = queryMatch.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE NOT (this0.title = $param0)"
`);

Expand All @@ -303,7 +303,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE NOT (this0.name = $param0)
RETURN this0"
`);
Expand Down Expand Up @@ -336,7 +336,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE NOT (this0.age = $param0 OR this0.name = $param1)
RETURN this0"
`);
Expand Down Expand Up @@ -366,7 +366,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Person\`)
"MATCH (this0:Person)
WHERE this0.name = $param0
SET
this0.name = $param1
Expand Down Expand Up @@ -398,7 +398,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE (this0.id = $param0 AND this0.name = $param1)
DELETE this0
RETURN 5"
Expand Down Expand Up @@ -426,7 +426,7 @@ describe("CypherBuilder Match", () => {

const queryResult = matchQuery.build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"MATCH (this0:\`Movie\`)
"MATCH (this0:Movie)
WHERE (this0.id = $param0 AND this0.name = $param1)
DETACH DELETE this0"
`);
Expand Down
Loading
Loading