Skip to content

Commit d6dcb03

Browse files
authored
[Improve][Jdbc] Support custom case-sensitive config for dameng (#6510)
1 parent 77ffa56 commit d6dcb03

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

Diff for: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbDialect.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
2323
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
2424
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper;
25-
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum;
2625

2726
import java.util.Arrays;
2827
import java.util.List;
@@ -31,14 +30,12 @@
3130

3231
public class DmdbDialect implements JdbcDialect {
3332

34-
public String fieldIde = FieldIdeEnum.ORIGINAL.getValue();
33+
public String fieldIde;
3534

3635
public DmdbDialect(String fieldIde) {
3736
this.fieldIde = fieldIde;
3837
}
3938

40-
public DmdbDialect() {}
41-
4239
@Override
4340
public String dialectName() {
4441
return DatabaseIdentifier.DAMENG;

Diff for: seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/dm/DmdbDialectFactory.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
2121
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory;
22+
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum;
2223

2324
import com.google.auto.service.AutoService;
2425

@@ -33,6 +34,11 @@ public boolean acceptsURL(String url) {
3334

3435
@Override
3536
public JdbcDialect create() {
36-
return new DmdbDialect();
37+
return create(null, FieldIdeEnum.ORIGINAL.getValue());
38+
}
39+
40+
@Override
41+
public JdbcDialect create(String compatibleMode, String fieldIde) {
42+
return new DmdbDialect(fieldIde);
3743
}
3844
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm;
19+
20+
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
21+
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum;
22+
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.Test;
25+
26+
public class DmdbDialectTest {
27+
@Test
28+
public void testIdentifierCaseSensitive() {
29+
DmdbDialectFactory factory = new DmdbDialectFactory();
30+
31+
JdbcDialect dialect = factory.create();
32+
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("test"));
33+
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("TEST"));
34+
35+
dialect = factory.create(null, FieldIdeEnum.ORIGINAL.getValue());
36+
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("test"));
37+
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("TEST"));
38+
39+
dialect = factory.create(null, FieldIdeEnum.LOWERCASE.getValue());
40+
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("test"));
41+
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("TEST"));
42+
43+
dialect = factory.create(null, FieldIdeEnum.UPPERCASE.getValue());
44+
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("test"));
45+
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("TEST"));
46+
}
47+
}

0 commit comments

Comments
 (0)