Skip to content

Commit

Permalink
Add clob data type for E2E assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
FlyingZC committed Jan 9, 2025
1 parent d41a743 commit 78252ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private Object getValue(final String value, final String type) {
case "longtext":
case "mediumtext":
case "json":
case "clob":
return value;
case "tinyint":
return Byte.parseByte(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
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;
Expand Down Expand Up @@ -48,6 +49,7 @@
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;
Expand Down Expand Up @@ -284,6 +286,8 @@ private void assertValue(final ResultSet actual, final int columnIndex, final St
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));
}
Expand All @@ -293,6 +297,11 @@ private boolean isPostgreSQLOrOpenGaussMoney(final String columnTypeName, final
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
Expand Down

0 comments on commit 78252ca

Please sign in to comment.