Skip to content

Commit 509e5ac

Browse files
committed
Emit NoticeResponse through the message stream.
We now pass-thru NoticeResponse so that notices can be consumed as Result.Message. [resolves #570] Signed-off-by: Mark Paluch <[email protected]>
1 parent 02a9a26 commit 509e5ac

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

src/main/java/io/r2dbc/postgresql/client/ReactorNettyClient.java

-2
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ private boolean consumeMessage(BackendMessage message) {
268268
}
269269

270270
if (message.getClass() == NoticeResponse.class) {
271-
272271
this.settings.getNoticeLogLevel().log(logger, () -> this.context.getMessage(String.format("Notice: %s", toString(((NoticeResponse) message).getFields()))));
273-
return true;
274272
}
275273

276274
if (message.getClass() == BackendKeyData.class) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.r2dbc.postgresql;
18+
19+
import io.r2dbc.spi.Result;
20+
import org.junit.jupiter.api.Test;
21+
import reactor.core.publisher.Mono;
22+
import reactor.test.StepVerifier;
23+
24+
/**
25+
* Integration tests {@link Result.Segment}.
26+
*/
27+
final class SegmentIntegrationTests extends AbstractIntegrationTests {
28+
29+
@Test
30+
void shouldConsumeNotice() {
31+
32+
this.connection.createStatement("DO language plpgsql $$\n" +
33+
"BEGIN\n" +
34+
" RAISE NOTICE 'hello, world!';\n" +
35+
"END\n" +
36+
"$$;").execute().flatMap(it -> it.flatMap(segment -> {
37+
if (segment instanceof Result.Message) {
38+
return Mono.just(((Result.Message) segment).message());
39+
}
40+
return Mono.empty();
41+
})).as(StepVerifier::create)
42+
.expectNext("hello, world!")
43+
.verifyComplete();
44+
}
45+
46+
}

0 commit comments

Comments
 (0)