mirror of
https://gitee.com/dromara/dbswitch.git
synced 2025-10-20 00:23:55 +00:00
修正issue的问题反馈
This commit is contained in:
@@ -217,11 +217,11 @@ public enum ProductTypeEnum {
|
|||||||
/**
|
/**
|
||||||
* OceanBase数据库类型
|
* OceanBase数据库类型
|
||||||
*/
|
*/
|
||||||
OCEANBASE(22, "`", "OceanBase", "com.oceanbase.jdbc.Driver", 2881,
|
OCEANBASE(22, "", "OceanBase", "com.oceanbase.jdbc.Driver", 2881,
|
||||||
"/* ping */ SELECT 1",
|
"/* ping */",
|
||||||
"jdbc:oceanbase://",
|
"jdbc:oceanbase://",
|
||||||
new String[]{"jdbc:oceanbase://{host}[:{port}]/[{database}][\\?{params}]"},
|
new String[]{"jdbc:oceanbase://{host}[:{port}]/[{database}][\\?{params}]"},
|
||||||
"jdbc:oceanbase://127.0.0.1:2881/test?pool=false&useUnicode=true&characterEncoding=utf-8&useSSL=false&"),
|
"jdbc:oceanbase://127.0.0.1:2881/test?pool=false&useUnicode=true&characterEncoding=utf-8&useSSL=false"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
/////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////
|
||||||
package com.gitee.dbswitch.product.oceanbase;
|
package com.gitee.dbswitch.product.oceanbase;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.StrPool;
|
||||||
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
import com.gitee.dbswitch.common.type.ProductTypeEnum;
|
||||||
import com.gitee.dbswitch.product.mysql.MysqlMetadataQueryProvider;
|
import com.gitee.dbswitch.product.mysql.MysqlMetadataQueryProvider;
|
||||||
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
import com.gitee.dbswitch.provider.ProductFactoryProvider;
|
||||||
@@ -21,6 +22,8 @@ import com.gitee.dbswitch.schema.SourceProperties;
|
|||||||
import com.gitee.dbswitch.schema.TableDescription;
|
import com.gitee.dbswitch.schema.TableDescription;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
public class OceanbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
public class OceanbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
||||||
@@ -127,7 +130,10 @@ public class OceanbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendPrimaryKeyForCreateTableSql(StringBuilder builder, List<String> primaryKeys) {
|
public void appendPrimaryKeyForCreateTableSql(StringBuilder builder, List<String> primaryKeys) {
|
||||||
this.delegate.appendPrimaryKeyForCreateTableSql(builder, primaryKeys);
|
if (CollectionUtils.isNotEmpty(primaryKeys)) {
|
||||||
|
String primaryKeyAsString = getPrimaryKeyAsString(primaryKeys);
|
||||||
|
builder.append(", PRIMARY KEY (").append(primaryKeyAsString).append(")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,7 +144,15 @@ public class OceanbaseMetadataQueryProvider extends AbstractMetadataProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPrimaryKeyAsString(List<String> pks) {
|
public String getPrimaryKeyAsString(List<String> pks) {
|
||||||
return this.delegate.getPrimaryKeyAsString(pks);
|
if (!pks.isEmpty()) {
|
||||||
|
return quoteName(
|
||||||
|
StringUtils.join(
|
||||||
|
pks.stream().distinct().collect(Collectors.toList())
|
||||||
|
, quoteName(StrPool.COMMA)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return StringUtils.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user