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)