Skip to content

Commit

Permalink
[Improve][Jdbc] Support custom case-sensitive config for dameng (#6510)
Browse files Browse the repository at this point in the history
  • Loading branch information
hailin0 committed Mar 15, 2024
1 parent 77ffa56 commit d6dcb03
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum;

import java.util.Arrays;
import java.util.List;
Expand All @@ -31,14 +30,12 @@

public class DmdbDialect implements JdbcDialect {

public String fieldIde = FieldIdeEnum.ORIGINAL.getValue();
public String fieldIde;

public DmdbDialect(String fieldIde) {
this.fieldIde = fieldIde;
}

public DmdbDialect() {}

@Override
public String dialectName() {
return DatabaseIdentifier.DAMENG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum;

import com.google.auto.service.AutoService;

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

@Override
public JdbcDialect create() {
return new DmdbDialect();
return create(null, FieldIdeEnum.ORIGINAL.getValue());
}

@Override
public JdbcDialect create(String compatibleMode, String fieldIde) {
return new DmdbDialect(fieldIde);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dm;

import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect;
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.dialectenum.FieldIdeEnum;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class DmdbDialectTest {
@Test
public void testIdentifierCaseSensitive() {
DmdbDialectFactory factory = new DmdbDialectFactory();

JdbcDialect dialect = factory.create();
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("test"));
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("TEST"));

dialect = factory.create(null, FieldIdeEnum.ORIGINAL.getValue());
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("test"));
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("TEST"));

dialect = factory.create(null, FieldIdeEnum.LOWERCASE.getValue());
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("test"));
Assertions.assertEquals("\"test\"", dialect.quoteIdentifier("TEST"));

dialect = factory.create(null, FieldIdeEnum.UPPERCASE.getValue());
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("test"));
Assertions.assertEquals("\"TEST\"", dialect.quoteIdentifier("TEST"));
}
}

0 comments on commit d6dcb03

Please sign in to comment.