This is an automated email from the ASF dual-hosted git repository.
zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new d9c7c527bd0 Add clob data type for E2E assertion (#34292)
d9c7c527bd0 is described below
commit d9c7c527bd03d4deae87b5ec83cece5fcbfd7f3e
Author: ZhangCheng <[email protected]>
AuthorDate: Thu Jan 9 21:58:21 2025 +0800
Add clob data type for E2E assertion (#34292)
---
.../org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java | 1 +
.../shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java
index 72b9f043139..c6c85015974 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/cases/value/SQLValue.java
@@ -60,6 +60,7 @@ public final class SQLValue {
case "longtext":
case "mediumtext":
case "json":
+ case "clob":
return value;
case "tinyint":
return Byte.parseByte(value);
diff --git
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
index 9e732ae1c2c..fd118fab3ce 100644
---
a/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
+++
b/test/e2e/sql/src/test/java/org/apache/shardingsphere/test/e2e/engine/type/dml/BaseDMLE2EIT.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.test.e2e.engine.type.dml;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import lombok.Getter;
+import lombok.SneakyThrows;
import org.apache.shardingsphere.infra.database.core.type.DatabaseType;
import org.apache.shardingsphere.infra.datanode.DataNode;
import org.apache.shardingsphere.infra.expr.core.InlineExpressionParserFactory;
@@ -48,6 +49,7 @@ import javax.sql.DataSource;
import javax.xml.bind.JAXBException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@@ -284,6 +286,8 @@ public abstract class BaseDMLE2EIT implements
E2EEnvironmentAware {
assertThat(actual.getString(columnIndex), is(expected));
} else if (Types.BINARY ==
actual.getMetaData().getColumnType(columnIndex)) {
assertThat(actual.getObject(columnIndex),
is(expected.getBytes(StandardCharsets.UTF_8)));
+ } else if (Types.CLOB ==
actual.getMetaData().getColumnType(columnIndex)) {
+ assertThat(getClobValue((Clob) actual.getObject(columnIndex)),
is(expected));
} else {
assertThat(String.valueOf(actual.getObject(columnIndex)),
is(expected));
}
@@ -293,6 +297,11 @@ public abstract class BaseDMLE2EIT implements
E2EEnvironmentAware {
return "money".equalsIgnoreCase(columnTypeName) &&
("PostgreSQL".equals(databaseType.getType()) ||
"openGauss".equals(databaseType.getType()));
}
+ @SneakyThrows(SQLException.class)
+ private static String getClobValue(final Clob value) {
+ return value.getSubString(1, (int) value.length());
+ }
+
protected void assertGeneratedKeys(final AssertionTestParameter testParam,
final ResultSet generatedKeys, final DatabaseType databaseType) throws
SQLException {
DataSet generatedKeyDataSet = null == testParam.getAssertion() || null
== testParam.getAssertion().getExpectedGeneratedKeyDataFile()
? null