未验证 提交 13b6c521 编写于 作者: S Serge Rider 提交者: GitHub

Merge pull request #13713 from dbeaver/radix-transformer-bits-fix#13510_21_2_0

#13510 Fix trimmed value when value bits < max bits
......@@ -983,4 +983,16 @@ public class CommonUtils {
}
return grouped;
}
/**
* Clamps given value to range between lower and upper bounds.
*
* @param value the value to clamp
* @param min the lower boundary to clamp {@code value} to
* @param max the upper boundary to clamp {@code value} to
* @return {@code min} if {@code value} is less than {@code min}, {@code max} if {@code value} is greater than {@code max}, otherwise {@code value}
*/
public static int clamp(int value, int min, int max) {
return Math.max(min, Math.min(value, max));
}
}
......@@ -113,7 +113,7 @@ public class RadixAttributeTransformer implements DBDAttributeTransformer {
}
}
if (radix == 2) {
sb.append(strValue.substring(Math.max(strValue.length() - bits, 1)));
sb.append(strValue, 0, CommonUtils.clamp(strValue.length(), 1, bits));
} else {
sb.append(strValue);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册