From 46adcc33123769070f3825e77dbbc4cafb0188d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E9=98=94?= <1520622465@qq.com> Date: Sun, 24 Nov 2024 10:27:11 +0800 Subject: [PATCH] =?UTF-8?q?ActionInsert=E5=85=81=E8=AE=B8=E6=8F=92?= =?UTF-8?q?=E5=85=A5=E7=A9=BA=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/taboolib/module/database/ActionInsert.kt | 12 ++++++------ .../kotlin/taboolib/module/database/Attributes.kt | 2 +- .../kotlin/taboolib/module/database/Statement.kt | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/module/database/src/main/kotlin/taboolib/module/database/ActionInsert.kt b/module/database/src/main/kotlin/taboolib/module/database/ActionInsert.kt index de9d313b1..2ee77ab68 100644 --- a/module/database/src/main/kotlin/taboolib/module/database/ActionInsert.kt +++ b/module/database/src/main/kotlin/taboolib/module/database/ActionInsert.kt @@ -15,7 +15,7 @@ class ActionInsert(val table: String, val keys: Array) : Action { private var finallyCallback: (PreparedStatement.(Connection) -> Unit)? = null /** 插入值 */ - private var values = ArrayList>() + private var values = ArrayList>() /** 重复时更新 */ private var duplicateUpdate = ArrayList() @@ -37,26 +37,26 @@ class ActionInsert(val table: String, val keys: Array) : Action { }.build() /** 元素 */ - override val elements: List + override val elements: List get() { - val el = ArrayList() + val el = ArrayList() el.addAll(values.flatMap { it.toList() }) el.addAll(duplicateUpdate.mapNotNull { it.value }) return el } /** 插入值 */ - fun value(vararg args: Any) { + fun value(vararg args: Any?) { values.add(arrayOf(*args)) } /** 插入值 */ - fun values(args: Array) { + fun values(args: Array) { values.add(args) } /** 插入值 */ - fun values(args: List) { + fun values(args: List) { values.add(args.toTypedArray()) } diff --git a/module/database/src/main/kotlin/taboolib/module/database/Attributes.kt b/module/database/src/main/kotlin/taboolib/module/database/Attributes.kt index f5b22d058..ef44712eb 100644 --- a/module/database/src/main/kotlin/taboolib/module/database/Attributes.kt +++ b/module/database/src/main/kotlin/taboolib/module/database/Attributes.kt @@ -12,6 +12,6 @@ interface Attributes { val query: String /** 占位符对应的元素 */ - val elements: List + val elements: List get() = emptyList() } \ No newline at end of file diff --git a/module/database/src/main/kotlin/taboolib/module/database/Statement.kt b/module/database/src/main/kotlin/taboolib/module/database/Statement.kt index ffb289c57..1eef0f403 100644 --- a/module/database/src/main/kotlin/taboolib/module/database/Statement.kt +++ b/module/database/src/main/kotlin/taboolib/module/database/Statement.kt @@ -71,7 +71,7 @@ class Statement { } /** 追加值 */ - fun addValues(values: List>): Statement { + fun addValues(values: List>): Statement { query += values.joinToString { "(${it.joinToString { "?" }})" } return this }