@@ -7,23 +7,19 @@ import {
7
7
Match ,
8
8
Merge ,
9
9
NodePattern ,
10
+ PatternClause ,
10
11
Raw ,
11
12
Return ,
13
+ TermListClause ,
12
14
With ,
13
15
} from 'cypher-query-builder' ;
14
- import type { PatternClause as TSPatternClause } from 'cypher-query-builder/dist/typings/clauses/pattern-clause' ;
15
- import type {
16
- Term ,
17
- TermListClause as TSTermListClause ,
18
- } from 'cypher-query-builder/dist/typings/clauses/term-list-clause' ;
16
+ import type { Term } from 'cypher-query-builder/dist/typings/clauses/term-list-clause' ;
19
17
import type { Parameter } from 'cypher-query-builder/dist/typings/parameter-bag' ;
20
18
import { camelCase , isPlainObject } from 'lodash' ;
21
- import { Class } from 'type-fest' ;
22
19
import { isExp } from '../query' ;
23
20
24
21
// Add line breaks for each pattern when there's multiple per statement
25
22
// And ignore empty patterns
26
- const PatternClause = Object . getPrototypeOf ( Create ) as Class < TSPatternClause > ;
27
23
PatternClause . prototype . build = function build ( ) {
28
24
// @ts -expect-error private but we are using it
29
25
const patternStrings = this . patterns . map ( ( pattern ) =>
@@ -32,9 +28,6 @@ PatternClause.prototype.build = function build() {
32
28
return patternStrings . filter ( isNotFalsy ) . join ( ',\n ' ) ;
33
29
} ;
34
30
35
- // This class is not exported so grab it a hacky way
36
- const TermListClause = Object . getPrototypeOf ( With ) as Class < TSTermListClause > ;
37
-
38
31
// Change With & Return clauses to not alias as same variable since cypher as
39
32
// problems with it sometimes.
40
33
// e.g. .with({ node: 'node' })
@@ -76,7 +69,7 @@ TermListClause.prototype.stringifyTerm = function stringifyTerm(term: Term) {
76
69
// If the term list clause has no terms render empty string instead of broken cypher
77
70
for ( const Cls of [ With , Return ] ) {
78
71
const origBuild = Cls . prototype . build ;
79
- Cls . prototype . build = function build ( this : TSTermListClause ) {
72
+ Cls . prototype . build = function build ( this : TermListClause ) {
80
73
if ( TermListClause . prototype . build . call ( this ) === '' ) {
81
74
return '' ;
82
75
}
@@ -92,7 +85,7 @@ Raw.prototype.build = function build() {
92
85
// If the pattern clause has no patterns render empty string instead of broken cypher
93
86
for ( const Cls of [ Match , Create , Merge ] ) {
94
87
const origBuild = Cls . prototype . build ;
95
- Cls . prototype . build = function build ( this : TSPatternClause ) {
88
+ Cls . prototype . build = function build ( this : PatternClause ) {
96
89
if ( PatternClause . prototype . build . call ( this ) === '' ) {
97
90
return '' ;
98
91
}
0 commit comments