Skip to content

Commit 0ee7a2b

Browse files
committed
Correctly represent string literals when querying types through PostgresTypes.lookupType
Type names are properly quoted when querying for these. [resolves #437] Signed-off-by: Mark Paluch <[email protected]>
1 parent 1df6992 commit 0ee7a2b

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2021 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.codec;
18+
19+
import io.r2dbc.postgresql.AbstractIntegrationTests;
20+
import io.r2dbc.spi.Connection;
21+
import org.junit.jupiter.api.Test;
22+
import reactor.core.publisher.Flux;
23+
import reactor.core.publisher.Mono;
24+
import reactor.test.StepVerifier;
25+
26+
import java.util.Arrays;
27+
28+
import static org.assertj.core.api.Assertions.assertThat;
29+
30+
/**
31+
* Integration tests for {@link PostgresTypes}.
32+
*/
33+
class PostgresTypesIntegrationTests extends AbstractIntegrationTests {
34+
35+
@Test
36+
void shouldLookupSingleType() {
37+
38+
Mono.usingWhen(getConnectionFactory().create(), c -> {
39+
return PostgresTypes.from(c).lookupType("varchar");
40+
}, Connection::close).map(PostgresTypes.PostgresType::getName).map(String::toLowerCase)
41+
.as(StepVerifier::create).expectNext("varchar").verifyComplete();
42+
}
43+
44+
@Test
45+
void shouldLookupMultipleType() {
46+
47+
Flux.usingWhen(getConnectionFactory().create(), c -> {
48+
return PostgresTypes.from(c).lookupTypes(Arrays.asList("varchar", "int4"));
49+
}, Connection::close).map(PostgresTypes.PostgresType::getName).map(String::toLowerCase).collectList()
50+
.as(StepVerifier::create).consumeNextWith(actual -> {
51+
assertThat(actual).contains("varchar", "int4");
52+
}).verifyComplete();
53+
}
54+
55+
}

0 commit comments

Comments
 (0)