+
Skip to content

Add new kotlin.Short / java.sql.Types.SMALLINT type #160

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

Merged
merged 2 commits into from
Jun 23, 2020
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
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ subprojects { project ->
name = "afezeria"
email = "zodal@outlook.com"
}
developer {
id = "scorsi"
name = "Sylvain Corsini"
email = "sylvain.corsini@protonmail.com"
}
}
scm {
url = "https://github.com/vincentlauvlwj/Ktorm.git"
Expand Down
1 change: 1 addition & 0 deletions docs/source/en/schema-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Here is a list of SQL types supported in Ktorm by default:
| float | kotlin.Float | float | Types.FLOAT |
| double | kotlin.Double | double | Types.DOUBLE |
| decimal | java.math.BigDecimal | decimal | Types.DECIMAL |
| short | kotlin.Short | smallint | Types.SMALLINT |
| varchar | kotlin.String | varchar | Types.VARCHAR |
| text | kotlin.String | text | Types.LONGVARCHAR |
| blob | kotlin.ByteArray | blob | Types.BLOB |
Expand Down
1 change: 1 addition & 0 deletions docs/source/zh-cn/schema-definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Ktorm 默认支持的数据类型如下表:
| float | kotlin.Float | float | Types.FLOAT |
| double | kotlin.Double | double | Types.DOUBLE |
| decimal | java.math.BigDecimal | decimal | Types.DECIMAL |
| short | kotlin.Short | smallint | Types.SMALLINT |
| varchar | kotlin.String | varchar | Types.VARCHAR |
| text | kotlin.String | text | Types.LONGVARCHAR |
| blob | kotlin.ByteArray | blob | Types.BLOB |
Expand Down
20 changes: 20 additions & 0 deletions ktorm-core/src/main/kotlin/me/liuwj/ktorm/schema/SqlTypes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ object DecimalSqlType : SqlType<BigDecimal>(Types.DECIMAL, "decimal") {
}
}

/**
* Define a column typed of [ShortSqlType].
*/
fun BaseTable<*>.short(name: String): Column<Short> {
return registerColumn(name, ShortSqlType)
}

/**
* [SqlType] implementation represents `smallint` SQL type.
*/
object ShortSqlType : SqlType<Short>(Types.SMALLINT, typeName = "smallint") {
override fun doSetParameter(ps: PreparedStatement, index: Int, parameter: Short) {
ps.setShort(index, parameter)
}

override fun doGetResult(rs: ResultSet, index: Int): Short? {
return rs.getShort(index)
}
}

/**
* Define a column typed of [VarcharSqlType].
*/
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载