v1.6.16:修复issue I5Y567,kingbase中TINYINT类型转换错误

This commit is contained in:
inrgihc
2022-11-05 23:02:26 +08:00
parent c6ec7ef22e
commit 5c3a8c2003
11 changed files with 38 additions and 41 deletions

Binary file not shown.

View File

@@ -99,7 +99,7 @@
<artifactId>kingbase-jdbc</artifactId>
<version>8.2.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/kingbase8-8.2.0.jar</systemPath>
<systemPath>${project.basedir}/lib/kingbase8-8.6.0.jar</systemPath>
</dependency>
<dependency>

View File

@@ -300,7 +300,7 @@ public abstract class AbstractDatabase implements IDatabaseInterface {
// nothing more we can do here by catch the exception.
}
cd.setSigned(signed);
cd.setDbType(getDatabaseType());
cd.setProductType(getDatabaseType());
ret.add(cd);
}

View File

@@ -115,7 +115,7 @@ public class DatabaseHiveImpl extends AbstractDatabase implements IDatabaseInter
// nothing more we can do here by catch the exception.
}
cd.setSigned(signed);
cd.setDbType(ProductTypeEnum.HIVE);
cd.setProductType(ProductTypeEnum.HIVE);
ret.add(cd);
}

View File

@@ -33,7 +33,7 @@ import org.apache.commons.lang3.StringUtils;
public class DatabaseKingbaseImpl extends AbstractDatabase implements IDatabaseInterface {
private static final String SHOW_CREATE_VIEW_SQL =
"SELECT pg_get_viewdef((select pg_class.relfilenode from pg_catalog.pg_class \n"
"SELECT pg_get_viewdef((select pg_class.oid from pg_catalog.pg_class \n"
+ "join pg_catalog.pg_namespace on pg_class.relnamespace = pg_namespace.oid \n"
+ "where pg_namespace.nspname='%s' and pg_class.relname ='%s'),true) ";

View File

@@ -26,11 +26,11 @@ public class ColumnDescription {
private int displaySize;
private int scaleSize;
private int precisionSize;
private boolean isAutoIncrement;
private boolean isNullable;
private boolean autoIncrement;
private boolean nullable;
private String remarks;
private boolean signed = false;
private ProductTypeEnum dbtype;
private ProductTypeEnum productType;
public String getFieldName() {
if (null != this.fieldName) {
@@ -52,8 +52,8 @@ public class ColumnDescription {
return this.fieldName;
}
public void setLabelName(String labalName) {
this.labelName = labalName;
public void setLabelName(String labelName) {
this.labelName = labelName;
}
public String getFieldTypeName() {
@@ -105,19 +105,19 @@ public class ColumnDescription {
}
public boolean isAutoIncrement() {
return isAutoIncrement;
return autoIncrement;
}
public void setAutoIncrement(boolean isAutoIncrement) {
this.isAutoIncrement = isAutoIncrement;
public void setAutoIncrement(boolean autoIncrement) {
this.autoIncrement = autoIncrement;
}
public boolean isNullable() {
return isNullable;
return nullable;
}
public void setNullable(boolean isNullable) {
this.isNullable = isNullable;
this.nullable = isNullable;
}
public boolean isSigned() {
@@ -128,12 +128,12 @@ public class ColumnDescription {
this.signed = signed;
}
public ProductTypeEnum getDbType() {
return this.dbtype;
public ProductTypeEnum getProductType() {
return this.productType;
}
public void setDbType(ProductTypeEnum dbtype) {
this.dbtype = dbtype;
public void setProductType(ProductTypeEnum productType) {
this.productType = productType;
}
public String getRemarks() {
@@ -154,11 +154,11 @@ public class ColumnDescription {
description.setDisplaySize(displaySize);
description.setScaleSize(scaleSize);
description.setPrecisionSize(precisionSize);
description.setAutoIncrement(isAutoIncrement);
description.setNullable(isNullable);
description.setAutoIncrement(autoIncrement);
description.setNullable(nullable);
description.setRemarks(remarks);
description.setSigned(signed);
description.setDbType(dbtype);
description.setProductType(productType);
return description;
}

View File

@@ -84,8 +84,7 @@ public class ColumnMetaData {
* The Constant typeCodes.
*/
public static final String[] TYPE_CODES = new String[]{"-", "Number", "String", "Date", "Boolean",
"Integer",
"BigNumber", "Serializable", "Binary", "Timestamp", "Time", "Internet Address",};
"Integer", "BigNumber", "Serializable", "Binary", "Timestamp", "Time", "Internet Address",};
//////////////////////////////////////////////////////////////////////
@@ -353,7 +352,10 @@ public class ColumnMetaData {
}
// If we're dealing with PostgreSQL and double precision types
if (desc.getDbType() == ProductTypeEnum.POSTGRESQL && type == java.sql.Types.DOUBLE
if ((desc.getProductType() == ProductTypeEnum.POSTGRESQL
|| desc.getProductType() == ProductTypeEnum.GREENPLUM
|| desc.getProductType() == ProductTypeEnum.KINGBASE)
&& type == java.sql.Types.DOUBLE
&& precision >= 16
&& length >= 16) {
precision = -1;
@@ -362,7 +364,8 @@ public class ColumnMetaData {
// MySQL: max resolution is double precision floating point (double)
// The (12,31) that is given back is not correct
if (desc.getDbType() == ProductTypeEnum.MYSQL) {
if (desc.getProductType() == ProductTypeEnum.MYSQL
|| desc.getProductType() == ProductTypeEnum.MARIADB) {
if (precision >= length) {
precision = -1;
length = -1;
@@ -370,7 +373,7 @@ public class ColumnMetaData {
}
// If we're dealing with Hive and double/float precision types
if (desc.getDbType() == ProductTypeEnum.HIVE) {
if (desc.getProductType() == ProductTypeEnum.HIVE) {
if (type == java.sql.Types.DOUBLE
&& precision >= 15
&& length >= 15) {
@@ -386,14 +389,9 @@ public class ColumnMetaData {
}
}
// if the length or precision needs a BIGNUMBER
//if (length > 15 || precision > 15) {
// valtype = ColumnMetaData.TYPE_BIGNUMBER;
//}
} else {
if (precision == 0) {
if (length <= 18 && length > 0) { // Among others Oracle is affected
// here.
if (length <= 18 && length > 0) { // Among others Oracle is affected here.
valtype = ColumnMetaData.TYPE_INTEGER; // Long can hold up to 18
// significant digits
} else if (length > 18) {
@@ -406,8 +404,9 @@ public class ColumnMetaData {
}
}
if (desc.getDbType() == ProductTypeEnum.POSTGRESQL
|| desc.getDbType() == ProductTypeEnum.GREENPLUM) {
if (desc.getProductType() == ProductTypeEnum.POSTGRESQL
|| desc.getProductType() == ProductTypeEnum.KINGBASE
|| desc.getProductType() == ProductTypeEnum.GREENPLUM) {
// undefined size => arbitrary precision
if (type == java.sql.Types.NUMERIC && length == 0 && precision == 0) {
valtype = ColumnMetaData.TYPE_BIGNUMBER;
@@ -416,7 +415,8 @@ public class ColumnMetaData {
}
}
if (desc.getDbType() == ProductTypeEnum.ORACLE) {
if (desc.getProductType() == ProductTypeEnum.ORACLE ||
desc.getProductType() == ProductTypeEnum.DM) {
if (precision == 0 && length == 38) {
valtype = ColumnMetaData.TYPE_INTEGER;
}

View File

@@ -30,9 +30,9 @@ public class DatabaseDescription {
protected String username;
protected String password;
public DatabaseDescription(String dbtype, String host, int port, String mode, String dbname,
public DatabaseDescription(String productType, String host, int port, String mode, String dbname,
String charset, String username, String password) {
this.type = ProductTypeEnum.valueOf(dbtype.toUpperCase());
this.type = ProductTypeEnum.valueOf(productType.toUpperCase());
this.host = host;
this.port = port;
this.mode = mode;

View File

@@ -14,9 +14,7 @@ import java.util.List;
public class SchemaTableMeta extends TableDescription {
private List<String> primaryKeys;
private String createSql;
private List<ColumnDescription> columns;
public List<String> getPrimaryKeys() {

View File

@@ -35,9 +35,8 @@ public final class GenerateSqlUtils {
String schemaName,
String tableName,
boolean autoIncr) {
AbstractDatabase db = DatabaseFactory.getDatabaseInstance(type);
return getDDLCreateTableSQL(
db,
DatabaseFactory.getDatabaseInstance(type),
fieldNames,
primaryKeys,
schemaName,