Skip to content
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 @@ -87,7 +87,16 @@ public static OptionalInt findColumnSize(final String schemaName, final String t

private static String buildTableKey(final String schemaName, final String tableName) {
String schemaKey = null == schemaName ? "" : toKey(schemaName);
return schemaKey + "." + toKey(tableName);
String logicTable = trimToLogicTableName(tableName);
return schemaKey + "." + toKey(logicTable);
}

private static String trimToLogicTableName(final String tableName) {
int end = tableName.length() - 1;
while (end >= 0 && !Character.isLetter(tableName.charAt(end))) {
end--;
}
return end < 0 ? tableName : tableName.substring(0, end + 1);
}

private static String toKey(final String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ private void processColumn(final Collection<FirebirdReturnColumnPacket> describe
String tableAliasString = null == tableAlias ? table.getName() : tableAlias.getValue();
String columnAliasString = null == columnAlias ? column.getName() : columnAlias.getValue();
String owner = connectionSession.getConnectionContext().getGrantee().getUsername();
Integer columnLength = resolveColumnLength(table, column);
Integer columnLength = (null != column && isDynamicLengthType(column.getDataType())) ? resolveColumnLength(table, column) : null;
describeColumns.add(new FirebirdReturnColumnPacket(requestedItems, idx, table, column, tableAliasString, columnAliasString, owner, columnLength));
}

Expand All @@ -469,4 +469,21 @@ private Integer resolveColumnLength(final ShardingSphereTable table, final Shard
OptionalInt columnSize = FirebirdSizeRegistry.findColumnSize(connectionSession.getCurrentDatabaseName(), table.getName(), column.getName());
return columnSize.isPresent() ? columnSize.getAsInt() : null;
}

private boolean isDynamicLengthType(final int dataType) {
switch (dataType) {
case Types.CHAR:
case Types.NCHAR:
case Types.VARCHAR:
case Types.NVARCHAR:
case Types.LONGVARCHAR:
case Types.LONGNVARCHAR:
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
return true;
default:
return false;
}
}
}
Loading