Skip to content

Commit

Permalink
#300 Varchar doesn't validate length
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Aug 9, 2018
1 parent 647af99 commit 1f3919e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/kotlin/org/jetbrains/exposed/sql/ColumnType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,14 @@ open class VarCharColumnType(val colLength: Int = 255, collate: String? = null)
append(" COLLATE $collate")
}
}

override fun notNullValueToDB(value: Any): Any {
val string = super.notNullValueToDB(value)
require(string is String && string.length <= colLength) {
"Value '$string' can't be stored to database column because exceeds length $colLength"
}
return string
}
}

open class TextColumnType(collate: String? = null) : StringColumnType(collate) {
Expand Down

0 comments on commit 1f3919e

Please sign in to comment.