Skip to content

Commit

Permalink
Merge pull request #506 from CoderKuo/dev/6.2.0
Browse files Browse the repository at this point in the history
ActionInsert允许插入空值
  • Loading branch information
Bkm016 authored Nov 24, 2024
2 parents 3aaf187 + 46adcc3 commit d39091e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ActionInsert(val table: String, val keys: Array<String>) : Action {
private var finallyCallback: (PreparedStatement.(Connection) -> Unit)? = null

/** 插入值 */
private var values = ArrayList<Array<Any>>()
private var values = ArrayList<Array<Any?>>()

/** 重复时更新 */
private var duplicateUpdate = ArrayList<UpdateOperation>()
Expand All @@ -37,26 +37,26 @@ class ActionInsert(val table: String, val keys: Array<String>) : Action {
}.build()

/** 元素 */
override val elements: List<Any>
override val elements: List<Any?>
get() {
val el = ArrayList<Any>()
val el = ArrayList<Any?>()
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<Any>) {
fun values(args: Array<Any?>) {
values.add(args)
}

/** 插入值 */
fun values(args: List<Any>) {
fun values(args: List<Any?>) {
values.add(args.toTypedArray())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ interface Attributes {
val query: String

/** 占位符对应的元素 */
val elements: List<Any>
val elements: List<Any?>
get() = emptyList()
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Statement {
}

/** 追加值 */
fun addValues(values: List<Array<Any>>): Statement {
fun addValues(values: List<Array<Any?>>): Statement {
query += values.joinToString { "(${it.joinToString { "?" }})" }
return this
}
Expand Down

0 comments on commit d39091e

Please sign in to comment.