Yoavya
10/20/2020, 8:52 AMoverride fun replace(
table: Table,
data: List<Pair<Column<*>, Any?>>,
transaction: Transaction
): String {
val builder = QueryBuilder(true)
val sql = if (data.isEmpty()) {
""
} else {
data.appendTo(builder, prefix = "VALUES (", postfix = ")") { (col, value) -> registerArgument(col, value) }.toString()
}
val columns = data.map { it.first }
val def = super.insert(false, table, columns, sql, transaction)
val uniqueCols = table.primaryKey?.columns
if (uniqueCols.isNullOrEmpty()) {
transaction.throwUnsupportedException("PostgreSQL replace table must supply at least one primary key.")
}
val conflictKey = uniqueCols.joinToString { transaction.identity(it) }
return def + "ON CONFLICT ($conflictKey) DO UPDATE SET " + columns.joinToString { "${transaction.identity(it)}=EXCLUDED.${transaction.identity(it)}" }
}
is this intentional? why not include all unique indices ? I can try fixing it with a PR if needed 🙂tapac
10/20/2020, 6:22 PMYoavya
10/20/2020, 6:23 PM