Skip to content

Commit

Permalink
SchemaUtils.create doesn't use enum column's 'toDb' function #1475
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Apr 10, 2022
1 parent c0915ad commit fc8775e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ open class Table(name: String = "") : ColumnSet(), DdlAware {
override fun sqlType(): String = sql ?: error("Column $name should exists in database ")
override fun valueFromDB(value: Any): T = if (value::class.isSubclassOf(Enum::class)) value as T else fromDb(value)
override fun notNullValueToDB(value: Any): Any = toDb(value as T)
override fun nonNullValueToString(value: Any): String = super.nonNullValueToString(notNullValueToDB(value))
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,11 @@ class DDLTests : DatabaseTestsBase() {
}
}

internal enum class Foo { Bar, Baz }
internal enum class Foo {
Bar, Baz;

override fun toString(): String = "Foo Enum ToString: $name"
}

class PGEnum<T : Enum<T>>(enumTypeName: String, enumValue: T?) : PGobject() {
init {
Expand Down

0 comments on commit fc8775e

Please sign in to comment.