mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
dbeaver/pro#8331 added sql generation for large objects (#4208)
* dbeaver/pro#8331 added sql generation for large objects * dbeaver/pro#8331 check only relevant columns --------- Co-authored-by: Ainur <59531286+yagudin10@users.noreply.github.com>
This commit is contained in:
co-authored by
Ainur
parent
cb8b1cfc52
commit
36d2b46496
+29
@@ -31,6 +31,7 @@ import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.DBPDataKind;
|
||||
import org.jkiss.dbeaver.model.DBPDataSource;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
|
||||
import org.jkiss.dbeaver.model.DBUtils;
|
||||
@@ -256,10 +257,38 @@ public class WebServiceSQL implements DBWServiceSQL {
|
||||
@NotNull String resultsId,
|
||||
@NotNull List<WebSQLResultsRow> selectedRows
|
||||
) throws DBWebException {
|
||||
checkAndFillTruncatedData(sqlContext, resultsId, selectedRows);
|
||||
WebDBDResultSetDataProvider dataProvider = new WebDBDResultSetDataProvider(resultsId, sqlContext, selectedRows);
|
||||
return createAndRunGenerator(webSession, generatorId, Collections.singletonList(dataProvider));
|
||||
}
|
||||
|
||||
private void checkAndFillTruncatedData(
|
||||
@NotNull WebSQLContextInfo sqlContext,
|
||||
@NotNull String resultsId,
|
||||
@NotNull List<WebSQLResultsRow> selectedRows
|
||||
) throws DBWebException {
|
||||
List<DBDAttributeBinding> attributes = Arrays.stream(sqlContext.getResults(resultsId).getAttributes())
|
||||
.filter(attr -> canBeTruncated(attr.getDataKind()))
|
||||
.toList();
|
||||
for (WebSQLResultsRow row : selectedRows) {
|
||||
Object[] data = row.getData();
|
||||
for (DBDAttributeBinding attribute : attributes) {
|
||||
int position = attribute.getOrdinalPosition();
|
||||
boolean valueIsTruncated = data[position] != null &&
|
||||
data[position].toString().length() == WebSQLConstants.TEXT_PREVIEW_MAX_LENGTH;
|
||||
if (valueIsTruncated) {
|
||||
data[position] = getCellValue(sqlContext, resultsId, position, row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canBeTruncated(@NotNull DBPDataKind dataKind) {
|
||||
return dataKind.equals(DBPDataKind.STRING) ||
|
||||
dataKind.equals(DBPDataKind.CONTENT) ||
|
||||
dataKind.equals(DBPDataKind.BINARY);
|
||||
}
|
||||
|
||||
private String createAndRunGenerator(
|
||||
@NotNull WebSession session,
|
||||
@NotNull String generatorId,
|
||||
|
||||
Reference in New Issue
Block a user