dave08
10/15/2023, 4:34 PMexecuteScript()
but that's not ideal, since I can't re-use Komapper's generated entities... I'd really like to have the naming of the tables and fields in one place and not spread out in the code...
Maybe having some kind of public api to re-use entity definitions even when writing sql's for executeScript()
? For now, it seems a bit complex... it was really written for internal dialect classes and not the end-user.Toshihiro Nakamura
10/16/2023, 11:14 AMdave08
10/16/2023, 11:26 AMToshihiro Nakamura
10/16/2023, 11:43 AMCan I just use the current one and swap the implementation for the upsert?Please extend
MySqlR2dbcDialect
, override getEntityUpsertStatementBuilder
, and return a customized implementation of EntityUpsertStatementBuilder
.dave08
10/16/2023, 11:47 AMbuf.append(" (")
for (p in properties) {
column(p)
buf.append(", ")
}
buf.cutBack(2)
buf.append(") values ")
for (entity in entities) {
buf.append("(")
for (p in properties) {
buf.bind(p.toValue(entity))
buf.append(", ")
}
buf.cutBack(2)
buf.append("), ")
}
buf.cutBack(2) /// ***This cutBack***
buf.append(" as ")
table(excluded, TableNameType.ALIAS_ONLY)
Toshihiro Nakamura
10/16/2023, 11:51 AMcutBack
removes a specified number of characters from the SQL string buffer. This is a necessary operation here, so it should not be removed from the code.dave08
10/16/2023, 11:51 AMbuf.append(" as ")
table(excluded, TableNameType.ALIAS_ONLY)
Toshihiro Nakamura
10/16/2023, 11:55 AMbuf.append(" as ")
table(excluded, TableNameType.ALIAS_ONLY)