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

Show length instead of value for exceeded column length #1667

Merged
merged 1 commit into from
Jan 16, 2023
Merged
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 @@ -557,8 +557,9 @@ open class CharColumnType(

override fun validateValueBeforeUpdate(value: Any?) {
if (value is String) {
require(value.codePointCount(0, value.length) <= colLength) {
"Value '$value' can't be stored to database column because exceeds length ($colLength)"
val valueLength = value.codePointCount(0, value.length)
require(valueLength <= colLength) {
"Value can't be stored to database column because exceeds length ($valueLength > $colLength)"
}
}
}
Expand Down Expand Up @@ -602,8 +603,9 @@ open class VarCharColumnType(

override fun validateValueBeforeUpdate(value: Any?) {
if (value is String) {
require(value.codePointCount(0, value.length) <= colLength) {
"Value '$value' can't be stored to database column because exceeds length ($colLength)"
val valueLength = value.codePointCount(0, value.length)
require(valueLength <= colLength) {
"Value can't be stored to database column because exceeds length ($valueLength > $colLength)"
}
}
}
Expand Down Expand Up @@ -692,8 +694,9 @@ open class BinaryColumnType(

override fun validateValueBeforeUpdate(value: Any?) {
if (value is ByteArray) {
require(value.size <= length) {
"Value '$value' can't be stored to database column because exceeds length ($length)"
val valueLength = value.size
require(valueLength <= length) {
"Value can't be stored to database column because exceeds length ($valueLength > $length)"
}
}
}
Expand Down