File tree Expand file tree Collapse file tree 4 files changed +16
-18
lines changed
main/java/oracle/r2dbc/impl Expand file tree Collapse file tree 4 files changed +16
-18
lines changed Original file line number Diff line number Diff line change @@ -68,17 +68,21 @@ private OracleResultImpl() { }
68
68
69
69
/**
70
70
* Creates a {@code Result} that publishes either an empty stream of row
71
- * data, or publishes an {@code updateCount} if it is greater than zero. An
72
- * {@code updateCount} less than 1 is published as an empty stream.
71
+ * data, or publishes an {@code updateCount} if it is greater than or equal
72
+ * to zero. An {@code updateCount} less than zero is published as an empty
73
+ * stream.
73
74
* @param updateCount Update count to publish
74
75
* @return An update count {@code Result}
75
76
*/
76
77
public static Result createUpdateCountResult (int updateCount ) {
77
78
return new OracleResultImpl () {
78
79
80
+ final Publisher <Integer > updateCountPublisher =
81
+ updateCount < 0 ? Mono .empty () : Mono .just (updateCount );
82
+
79
83
@ Override
80
84
Publisher <Integer > publishUpdateCount () {
81
- return updateCount < 1 ? Mono . empty () : Mono . just ( updateCount ) ;
85
+ return updateCountPublisher ;
82
86
}
83
87
84
88
@ Override
Original file line number Diff line number Diff line change @@ -98,21 +98,21 @@ public void testGetRowsUpdated() {
98
98
// Expect update count publisher to support multiple subscribers
99
99
awaitOne (1 , insertCountPublisher1 );
100
100
101
- // Expect no update count from UPDATE of zero rows
101
+ // Expect an update count of zero from UPDATE of zero rows
102
102
Result noUpdateResult = awaitOne (connection .createStatement (
103
103
"UPDATE testGetRowsUpdated SET y = 99 WHERE x = 99" )
104
104
.execute ());
105
105
Publisher <Integer > noUpdateCountPublisher =
106
106
noUpdateResult .getRowsUpdated ();
107
- awaitNone ( noUpdateCountPublisher );
107
+ awaitOne ( 0 , noUpdateCountPublisher );
108
108
109
109
// Expect IllegalStateException from multiple Result consumptions.
110
110
assertThrows (IllegalStateException .class ,
111
111
() -> noUpdateResult .map ((row , metadata ) -> "unexpected" ));
112
112
assertThrows (IllegalStateException .class , noUpdateResult ::getRowsUpdated );
113
113
114
114
// Expect update count publisher to support multiple subscribers
115
- awaitNone ( noUpdateCountPublisher );
115
+ awaitOne ( 0 , noUpdateCountPublisher );
116
116
117
117
// Expect update count of 2 from UPDATE of 2 rows
118
118
Result updateResult = awaitOne (connection .createStatement (
Original file line number Diff line number Diff line change @@ -811,11 +811,9 @@ public void testExecute() {
811
811
Connection connection =
812
812
Mono .from (sharedConnection ()).block (connectTimeout ());
813
813
try {
814
- // Expect DDL to result in no update count
815
- awaitUpdate (
816
- Collections .emptyList (),
817
- connection .createStatement (
818
- "CREATE TABLE testExecute (x NUMBER)" ));
814
+ // Expect DDL to result in an update count of zero
815
+ awaitUpdate (0 , connection .createStatement (
816
+ "CREATE TABLE testExecute (x NUMBER)" ));
819
817
// Expect DDL to result in no row data
820
818
awaitQuery (
821
819
Collections .emptyList (),
Original file line number Diff line number Diff line change @@ -132,16 +132,12 @@ public static <T> List<T> awaitMany(Publisher<T> multiPublisher) {
132
132
/**
133
133
* Executes a {@code statement} and blocks until the execution
134
134
* completes. This method verifies that the execution produces a
135
- * {@link Result} with no count of updated rows.
136
- * @param statement A statement that does not update rows.
135
+ * {@link Result} with a count of zero updated rows.
136
+ * @param statement A statement that does updates zero rows.
137
137
* @throws Throwable If the statement execution results in an error.
138
138
*/
139
139
public static void awaitExecution (Statement statement ) {
140
- assertNull (
141
- Mono .from (statement .execute ())
142
- .flatMap (result -> Mono .from (result .getRowsUpdated ()))
143
- .block (sqlTimeout ()),
144
- "Expected no update count when not updating rows" );
140
+ awaitUpdate (0 , statement );
145
141
}
146
142
147
143
/**
You can’t perform that action at this time.
0 commit comments