Skip to content

Commit

Permalink
fix: EXPOSED-701 [Oracle] Insert into table using only database defau…
Browse files Browse the repository at this point in the history
…lt values fails

- Refactor to include dialect check & logic in default insert()
  • Loading branch information
bog-walk committed Jan 28, 2025
1 parent c8c3bc7 commit f670fc8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,10 @@ abstract class FunctionProvider {
nextValExpression != null && columns.isNotEmpty() -> (columns + autoIncColumn) to expr.dropLast(1) + ", $nextValExpression)"
nextValExpression != null -> listOf(autoIncColumn) to "VALUES ($nextValExpression)"
columns.isNotEmpty() -> columns to expr
currentDialect is OracleDialect -> {
val oracleDefaults = "VALUES(DEFAULT${", DEFAULT".repeat(table.columns.lastIndex)})"
emptyList<Column<*>>() to oracleDefaults
}
else -> emptyList<Column<*>>() to DEFAULT_VALUE_EXPRESSION
}
val columnsExpr = columnsToInsert.takeIf { it.isNotEmpty() }?.joinToString(prefix = "(", postfix = ")") { transaction.identity(it) } ?: ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,22 +367,6 @@ internal object OracleFunctionProvider : FunctionProvider() {
}
}

override fun insert(
ignore: Boolean,
table: Table,
columns: List<Column<*>>,
expr: String,
transaction: Transaction
): String {
val def = super.insert(ignore, table, columns, expr, transaction)
return if (def.endsWith(" $DEFAULT_VALUE_EXPRESSION")) {
val oracleDefaults = "VALUES(DEFAULT${", DEFAULT".repeat(table.columns.lastIndex)})"
"${def.removeSuffix(DEFAULT_VALUE_EXPRESSION)}$oracleDefaults"
} else {
def
}
}

override fun explain(
analyze: Boolean,
options: String?,
Expand Down

0 comments on commit f670fc8

Please sign in to comment.