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

Add missing db procedures #361

Merged
merged 2 commits into from
Jul 26, 2024
Merged
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
8 changes: 8 additions & 0 deletions .changeset/plenty-lobsters-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@neo4j/cypher-builder": patch
---

Add support for missing fulltext procedures:

- `db.index.fulltext.awaitEventuallyConsistentIndexRefresh`
- `db.index.fulltext.listAvailableAnalyzers`
11 changes: 11 additions & 0 deletions .changeset/red-guests-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@neo4j/cypher-builder": patch
---

Add support for missing db procedures:

- `db.ping`
- `db.propertyKeys`
- `db.relationshipTypes`
- `db.resampleIndex`
- `db.resampleOutdatedIndexes`
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@
"ts-jest": "^29.1.1",
"typedoc": "^0.26.0",
"typescript": "^5.3.2"
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
88 changes: 47 additions & 41 deletions src/clauses/Call.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ import Cypher from "..";
describe("CypherBuilder Call", () => {
test("Wraps query inside Call", () => {
const idParam = new Cypher.Param("my-id");
const movieNode = new Cypher.Node({
labels: ["Movie"],
});
const movieNode = new Cypher.Node();

const createQuery = new Cypher.Create(movieNode).set([movieNode.property("id"), idParam]).return(movieNode);
const createQuery = new Cypher.Create(new Cypher.Pattern(movieNode, { labels: ["Movie"] }))
.set([movieNode.property("id"), idParam])
.return(movieNode);
const queryResult = new Cypher.Call(createQuery).build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
Expand All @@ -45,11 +45,11 @@ describe("CypherBuilder Call", () => {

test("Nested Call", () => {
const idParam = new Cypher.Param("my-id");
const movieNode = new Cypher.Node({
labels: ["Movie"],
});
const movieNode = new Cypher.Node();

const createQuery = new Cypher.Create(movieNode).set([movieNode.property("id"), idParam]).return(movieNode);
const createQuery = new Cypher.Create(new Cypher.Pattern(movieNode, { labels: ["Movie"] }))
.set([movieNode.property("id"), idParam])
.return(movieNode);
const nestedCall = new Cypher.Call(createQuery);
const call = new Cypher.Call(nestedCall);
const queryResult = call.build();
Expand All @@ -72,9 +72,9 @@ describe("CypherBuilder Call", () => {
});

test("CALL with import with", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

Expand All @@ -98,9 +98,12 @@ describe("CypherBuilder Call", () => {
});

test("CALL with import with *", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node).return([node.property("title"), "movie"]);
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] })).return([
node.property("title"),
"movie",
]);

const clause = new Cypher.Call(matchClause).importWith("*");
const queryResult = clause.build();
Expand All @@ -116,9 +119,12 @@ describe("CypherBuilder Call", () => {
});

test("CALL with import with * and extra fields", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node).return([node.property("title"), "movie"]);
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] })).return([
node.property("title"),
"movie",
]);

const clause = new Cypher.Call(matchClause).importWith(node, "*");
const queryResult = clause.build();
Expand All @@ -134,9 +140,9 @@ describe("CypherBuilder Call", () => {
});

test("CALL with import with without parameters", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

Expand All @@ -159,9 +165,9 @@ describe("CypherBuilder Call", () => {
});

test("CALL with import with multiple parameters", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

Expand All @@ -185,9 +191,9 @@ describe("CypherBuilder Call", () => {
});

test("CALL with import with fails if import with is already set", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

Expand All @@ -198,9 +204,9 @@ describe("CypherBuilder Call", () => {
});

test("CALL with external with", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

Expand All @@ -224,9 +230,9 @@ describe("CypherBuilder Call", () => {
});

test("CALL with external with, set and remove", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return(node);

Expand Down Expand Up @@ -257,9 +263,9 @@ WITH *"
});

test("CALL with external with clause", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), "movie"]);

Expand All @@ -283,10 +289,10 @@ WITH *"
});

test("CALL with unwind", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();
const movie = new Cypher.Variable();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), movie]);

Expand All @@ -311,10 +317,10 @@ WITH *"
});

test("CALL with unwind passed as a clause", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();
const movie = new Cypher.Variable();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(new Cypher.Param("aa"), new Cypher.Param("bb")))
.return([node.property("title"), movie]);

Expand All @@ -341,9 +347,9 @@ WITH *"
});

test("CALL with delete", () => {
const node = new Cypher.Node({ labels: ["Movie"] });
const node = new Cypher.Node();

const matchClause = new Cypher.Match(node)
const matchClause = new Cypher.Match(new Cypher.Pattern(node, { labels: ["Movie"] }))
.where(Cypher.eq(node.property("title"), new Cypher.Param("bb")))
.return(node);

Expand All @@ -368,12 +374,12 @@ DELETE this0"

test("Call returns a variable", () => {
const idParam = new Cypher.Param("my-id");
const movieNode = new Cypher.Node({
labels: ["Movie"],
});
const movieNode = new Cypher.Node();

const variable = new Cypher.Variable();
const createQuery = new Cypher.Create(movieNode).set([movieNode.property("id"), idParam]).return(variable);
const createQuery = new Cypher.Create(new Cypher.Pattern(movieNode, { labels: ["Movie"] }))
.set([movieNode.property("id"), idParam])
.return(variable);
const queryResult = new Cypher.Call(createQuery).return(variable).build();
expect(queryResult.cypher).toMatchInlineSnapshot(`
"CALL {
Expand Down Expand Up @@ -415,7 +421,7 @@ CALL {

test("Call in transaction of rows", () => {
const query = Cypher.concat(
new Cypher.Match(node),
new Cypher.Match(new Cypher.Pattern(node)),
new Cypher.Call(subquery).inTransactions({
ofRows: 10,
})
Expand All @@ -433,7 +439,7 @@ CALL {

test("Call in transaction on error fail", () => {
const query = Cypher.concat(
new Cypher.Match(node),
new Cypher.Match(new Cypher.Pattern(node)),
new Cypher.Call(subquery).inTransactions({
onError: "fail",
})
Expand All @@ -450,7 +456,7 @@ CALL {
});
test("Call in transaction on error break", () => {
const query = Cypher.concat(
new Cypher.Match(node),
new Cypher.Match(new Cypher.Pattern(node)),
new Cypher.Call(subquery).inTransactions({
onError: "break",
})
Expand All @@ -468,7 +474,7 @@ CALL {

test("Call in transaction on error continue", () => {
const query = Cypher.concat(
new Cypher.Match(node),
new Cypher.Match(new Cypher.Pattern(node)),
new Cypher.Call(subquery).inTransactions({
onError: "continue",
})
Expand All @@ -489,7 +495,7 @@ CALL {
const deleteSubquery = new Cypher.With(node).detachDelete(node);

const query = Cypher.concat(
new Cypher.Match(node),
new Cypher.Match(new Cypher.Pattern(node)),
new Cypher.Call(deleteSubquery).inTransactions({
ofRows: 10,
onError: "fail",
Expand Down
Loading
Loading