Skip to content

Commit

Permalink
Extract defaultColumnsForInsertSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreckYe committed Jun 23, 2023
1 parent 3a16475 commit 025b6f3
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ fun <T : Table> T.insertIgnoreStatement(body: T.(InsertStatement<Number>) -> Uni
body(this)
}

fun Table.defaultColumnsForInsertSelect() =
columns.filter { !it.columnType.isAutoInc || it.autoIncColumnType?.nextValExpression != null }

/**
* Adapted from [org.jetbrains.exposed.sql.insert].
*/
fun <T : Table> T.insertSelectStatement(
selectQuery: AbstractQuery<*>,
columns: List<Column<*>> = this.columns.filter { !it.columnType.isAutoInc || it.autoIncColumnType?.nextValExpression != null },
columns: List<Column<*>> = defaultColumnsForInsertSelect(),
isIgnore: Boolean = false
): InsertSelectStatement =
InsertSelectStatement(columns, selectQuery, isIgnore)
Expand Down

0 comments on commit 025b6f3

Please sign in to comment.