From 025b6f3d8129161b9ef1deaf767ee00e69e8fdc6 Mon Sep 17 00:00:00 2001 From: Shreck Ye Date: Fri, 23 Jun 2023 18:45:30 +0800 Subject: [PATCH] Extract `defaultColumnsForInsertSelect` --- .../src/main/kotlin/com/huanshankeji/exposed/Statements.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt b/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt index 0df3886..f60812e 100644 --- a/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt +++ b/exposed/src/main/kotlin/com/huanshankeji/exposed/Statements.kt @@ -49,12 +49,15 @@ fun T.insertIgnoreStatement(body: T.(InsertStatement) -> Uni body(this) } +fun Table.defaultColumnsForInsertSelect() = + columns.filter { !it.columnType.isAutoInc || it.autoIncColumnType?.nextValExpression != null } + /** * Adapted from [org.jetbrains.exposed.sql.insert]. */ fun T.insertSelectStatement( selectQuery: AbstractQuery<*>, - columns: List> = this.columns.filter { !it.columnType.isAutoInc || it.autoIncColumnType?.nextValExpression != null }, + columns: List> = defaultColumnsForInsertSelect(), isIgnore: Boolean = false ): InsertSelectStatement = InsertSelectStatement(columns, selectQuery, isIgnore)