This commit is contained in:
justdba 2025-04-10 16:21:54 +08:00 committed by GitHub
commit f7a22d34e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 11 deletions

View File

@ -98,6 +98,7 @@ public class DateColumn extends Column {
* */
public DateColumn(final java.sql.Timestamp ts) {
this(ts == null ? null : ts.getTime());
this.setRawNano(ts == null ? 0 : ts.getNanos());
this.setSubType(DateType.DATETIME);
}
@ -123,8 +124,10 @@ public class DateColumn extends Column {
if (null == this.getRawData()) {
return null;
}
return new Date((Long)this.getRawData());
java.sql.Timestamp myts = new java.sql.Timestamp((Long) this.getRawData());
myts.setNanos(this.getRawNano());
return myts;
// return new Date((Long)this.getRawData());
}
@Override
@ -169,4 +172,14 @@ public class DateColumn extends Column {
public void setSubType(DateType subType) {
this.subType = subType;
}
public int getRawNano(){
return rawNano;
}
public void setRawNano(int rawNano){
this.rawNano = rawNano;
}
}
}

View File

@ -305,8 +305,8 @@ public class SingleTableSplitUtil {
String pkRangeSQL = String.format(minMaxTemplate, splitPK, splitPK,
table);
if (StringUtils.isNotBlank(where)) {
pkRangeSQL = String.format("%s WHERE (%s AND %s IS NOT NULL)",
pkRangeSQL, where, splitPK);
pkRangeSQL = String.format("%s WHERE (%s)",
pkRangeSQL, where);
}
return pkRangeSQL;
}
@ -410,4 +410,4 @@ public class SingleTableSplitUtil {
}
return rangeSql;
}
}
}

View File

@ -507,17 +507,20 @@ public class CommonRdbmsWriter {
case Types.TIMESTAMP:
java.sql.Timestamp sqlTimestamp = null;
java.sql.Timestamp tsNano = null;
try {
utilDate = column.asDate();
// utilDate = column.asDate();
tsNano = (java.sql.Timestamp)(column.asDate());
} catch (DataXException e) {
throw new SQLException(String.format(
"TIMESTAMP 类型转换错误:[%s]", column));
}
if (null != utilDate) {
sqlTimestamp = new java.sql.Timestamp(
utilDate.getTime());
}
// if (null != utilDate) {
// sqlTimestamp = new java.sql.Timestamp(
// utilDate.getTime());
// }
sqlTimestamp=tsNano;
preparedStatement.setTimestamp(columnIndex + 1, sqlTimestamp);
break;
@ -536,7 +539,7 @@ public class CommonRdbmsWriter {
// warn: bit(1) -> Types.BIT 可使用setBoolean
// warn: bit(>1) -> Types.VARBINARY 可使用setBytes
case Types.BIT:
if (this.dataBaseType == DataBaseType.MySql) {
if (this.dataBaseType == DataBaseType.MySql || this.dataBaseType == DataBaseType.OceanBase) {
preparedStatement.setBoolean(columnIndex + 1, column.asBoolean());
} else {
preparedStatement.setString(columnIndex + 1, column.asString());