Skip to content

Commit f6bec76

Browse files
authored
Merge pull request #573 from neo4j/remove-patterns-in-size
Remove support for patterns in size
2 parents b6cd8ca + 56720a2 commit f6bec76

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

.changeset/common-cycles-obey.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@neo4j/cypher-builder": major
3+
---
4+
5+
Remove support for patterns in size.
6+
7+
_No longer supported_
8+
9+
```js
10+
Cypher.size(new Cypher.Pattern(node));
11+
```
12+
13+
Use `new Cypher.Count(pattern)` instead.

src/expressions/functions/scalar.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,4 @@ describe("Scalar Functions", () => {
102102

103103
expect(queryResult.cypher).toMatchInlineSnapshot(`"size(\\"Hello\\")"`);
104104
});
105-
106-
test("size() applied to a pattern", () => {
107-
const pattern = new Cypher.Pattern(new Cypher.Node()).related().to();
108-
const cypherFunction = Cypher.size(pattern);
109-
const queryResult = new TestClause(cypherFunction).build();
110-
111-
expect(queryResult.cypher).toMatchInlineSnapshot(`"size((this0)-[]->())"`);
112-
});
113105
});

src/expressions/functions/scalar.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
* limitations under the License.
1818
*/
1919

20-
import { Raw } from "../../clauses/Raw";
21-
import type { Pattern } from "../../pattern/Pattern";
2220
import type { Expr } from "../../types";
2321
import { CypherFunction } from "./CypherFunctions";
2422

@@ -99,17 +97,8 @@ export function randomUUID(): CypherFunction {
9997
* @group Functions
10098
* @category Scalar
10199
*/
102-
export function size(expr: Expr): CypherFunction;
103-
/** @deprecated size() with pattern is deprecated in Neo4j 5 */
104-
export function size(expr: Pattern): CypherFunction;
105-
export function size(expr: Expr | Pattern): CypherFunction {
106-
// Support for patterns in size() in Neo4j 4
107-
// Using Raw to avoid adding Patterns to CypherFunction
108-
const sizeParam = new Raw((env) => {
109-
return env.compile(expr);
110-
});
111-
112-
return new CypherFunction("size", [sizeParam]);
100+
export function size(expr: Expr): CypherFunction {
101+
return new CypherFunction("size", [expr]);
113102
}
114103

115104
/**

0 commit comments

Comments
 (0)