File tree Expand file tree Collapse file tree 6 files changed +75
-3
lines changed Expand file tree Collapse file tree 6 files changed +75
-3
lines changed Original file line number Diff line number Diff line change 8
8
9
9
namespace Neo4jClient . Tests . Cypher
10
10
{
11
-
11
+ public class CypherFluentQueryInTransactionsTests : IClassFixture < CultureInfoSetupFixture >
12
+ {
13
+ private static IRawGraphClient GraphClient_44
14
+ {
15
+ get
16
+ {
17
+ var client = Substitute . For < IRawGraphClient > ( ) ;
18
+ client . CypherCapabilities . Returns ( CypherCapabilities . Cypher44 ) ;
19
+ return client ;
20
+ }
21
+ }
22
+
23
+ [ Fact ]
24
+ public void AddsInTransactionsWithNoRows_WhenRowsNotSpecified ( )
25
+ {
26
+ var client = GraphClient_44 ;
27
+ var query = new CypherFluentQuery ( client )
28
+ . Call ( "{arlo()}" )
29
+ . InTransactions ( )
30
+ . Query ;
31
+
32
+ Assert . Equal ( "CALL {arlo()}\r \n IN TRANSACTIONS" , query . QueryText ) ;
33
+ }
34
+
35
+ [ Fact ]
36
+ public void AddsInTransactionsWithRows_WhenRowsSpecified ( )
37
+ {
38
+ var client = GraphClient_44 ;
39
+ var query = new CypherFluentQuery ( client )
40
+ . Call ( "{arlo()}" )
41
+ . InTransactions ( 1000 )
42
+ . Query ;
43
+
44
+ Assert . Equal ( "CALL {arlo()}\r \n IN TRANSACTIONS OF 1000 ROWS" , query . QueryText ) ;
45
+ }
46
+
47
+ [ Fact ]
48
+ public void AddsInTransactionsWithNoRows_WhenRowsAreNull ( )
49
+ {
50
+ var client = GraphClient_44 ;
51
+ var query = new CypherFluentQuery ( client )
52
+ . Call ( "{arlo()}" )
53
+ . InTransactions ( null )
54
+ . Query ;
55
+
56
+ Assert . Equal ( "CALL {arlo()}\r \n IN TRANSACTIONS" , query . QueryText ) ;
57
+ }
58
+ }
59
+
12
60
public class CypherFluentQueryCallTests : IClassFixture < CultureInfoSetupFixture >
13
61
{
14
62
private class Foo
Original file line number Diff line number Diff line change @@ -285,10 +285,12 @@ public async Task ConnectAsync(NeoServerConfiguration configuration = null)
285
285
var version = record [ "versions" ] . As < List < object > > ( ) ;
286
286
ServerVersion = RootApiResponse . GetVersion ( version ? . First ( ) ? . ToString ( ) ) ;
287
287
288
- if ( ServerVersion > new Version ( 3 , 0 ) )
288
+ if ( ServerVersion >= new Version ( 3 , 0 ) )
289
289
CypherCapabilities = CypherCapabilities . Cypher30 ;
290
290
if ( ServerVersion >= new Version ( 4 , 0 ) )
291
291
CypherCapabilities = CypherCapabilities . Cypher40 ;
292
+ if ( ServerVersion >= new Version ( 4 , 4 ) )
293
+ CypherCapabilities = CypherCapabilities . Cypher44 ;
292
294
}
293
295
294
296
await session . CloseAsync ( ) . ConfigureAwait ( false ) ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ public CypherCapabilities(CypherCapabilities cypherCapabilities)
14
14
SupportsStoredProcedures = cypherCapabilities . SupportsStoredProcedures ;
15
15
SupportsHasFunction = cypherCapabilities . SupportsHasFunction ;
16
16
SupportsMultipleTenancy = cypherCapabilities . SupportsMultipleTenancy ;
17
+ SupportsStoredProceduresWithTransactionalBatching = cypherCapabilities . SupportsStoredProceduresWithTransactionalBatching ;
17
18
}
18
19
19
20
public static readonly CypherCapabilities Cypher19 = new CypherCapabilities
@@ -34,7 +35,7 @@ public CypherCapabilities(CypherCapabilities cypherCapabilities)
34
35
public static readonly CypherCapabilities Cypher23 = new CypherCapabilities ( Cypher226 ) { SupportsStartsWith = true } ;
35
36
public static readonly CypherCapabilities Cypher30 = new CypherCapabilities ( Cypher23 ) { SupportsStoredProcedures = true , SupportsHasFunction = false } ;
36
37
public static readonly CypherCapabilities Cypher40 = new CypherCapabilities ( Cypher30 ) { SupportsMultipleTenancy = true , SupportsShow = true } ;
37
-
38
+ public static readonly CypherCapabilities Cypher44 = new CypherCapabilities ( Cypher40 ) { SupportsStoredProceduresWithTransactionalBatching = true } ;
38
39
public static readonly CypherCapabilities Default = Cypher20 ;
39
40
40
41
/// <summary>
@@ -46,6 +47,7 @@ public CypherCapabilities(CypherCapabilities cypherCapabilities)
46
47
public bool SupportsPropertySuffixesForControllingNullComparisons { get ; set ; }
47
48
public bool SupportsNullComparisonsWithIsOperator { get ; set ; }
48
49
public bool SupportsStartsWith { get ; set ; }
50
+ public bool SupportsStoredProceduresWithTransactionalBatching { get ; set ; }
49
51
50
52
/// <summary>
51
53
/// Cypher 3.0 provides support for Stored Procedures via the CALL keyword.
Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ public ICypherFluentQuery Call<T>(Func<ICypherFluentQuery<T>> subQuery)
62
62
return Call ( $ "{{ { query . QueryText } }}", query . QueryParameters ) ;
63
63
}
64
64
65
+ public ICypherFluentQuery InTransactions ( int ? rows = null )
66
+ {
67
+ if ( ! Client . CypherCapabilities . SupportsStoredProceduresWithTransactionalBatching )
68
+ throw new InvalidOperationException ( "IN TRANSACTIONS not supported in Neo4j versions older than 4.4" ) ;
69
+
70
+ return Mutate ( w =>
71
+ {
72
+ w . AppendClause ( $ "IN TRANSACTIONS{ ( rows . HasValue ? $ " OF { rows . Value } ROWS" : string . Empty ) } { Environment . NewLine } ") ;
73
+ } ) ;
74
+ }
75
+
65
76
66
77
67
78
public ICypherFluentQuery Read
Original file line number Diff line number Diff line change @@ -77,6 +77,13 @@ public partial interface ICypherFluentQuery
77
77
/// <exception cref="InvalidOperationException">Thrown if an attempt is made to call this against a server version prior to 3.0.</exception>
78
78
ICypherFluentQuery Call < T > ( Func < ICypherFluentQuery < T > > subQuery ) ;
79
79
80
+ /// <summary>
81
+ /// [Neo4j 4.4+] Batches subqueries
82
+ /// </summary>
83
+ /// <param name="rows"></param>
84
+ /// <returns></returns>
85
+ ICypherFluentQuery InTransactions ( int ? rows = null ) ;
86
+
80
87
/// <summary>
81
88
/// [Neo4j 3.0+] Yields the values from the response of a <see cref="Call"/> method
82
89
/// </summary>
Original file line number Diff line number Diff line change @@ -119,6 +119,8 @@ void StopTimerAndNotifyCompleted()
119
119
120
120
if ( version >= new Version ( 4 , 0 ) )
121
121
CypherCapabilities = CypherCapabilities . Cypher40 ;
122
+ if ( ServerVersion >= new Version ( 4 , 4 ) )
123
+ CypherCapabilities = CypherCapabilities . Cypher44 ;
122
124
}
123
125
catch ( AggregateException ex )
124
126
{
You can’t perform that action at this time.
0 commit comments