Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clob data type for E2E assertion #34292

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading