Add confict supports on Database
iNoles opened this issue · 2 comments
Right now, Agera doesn't use any conflict actions on the database.
Is this is a good idea for this?
Huh, true. I guess we never did have need for this in agera-database before. It definitely should be added though.
So, I assume you're referring to update and insert? In practice this would mean replacing the calls to insert
and update
in SqlDatabaseFunctions
with updateWithOnConflict
and insertWithOnConflict
.
It also means adding the capability in the SqlRequestCompiler, I'm kind of envisioning adding an optional set of operations, failOnConflict()
, ignoreOnConflict()
, replaceOnConflict()
, before compile()
for update and insert requests only, treating the absence of these to be the default conflict algorithm.
Correct me if I'm wrong, but I'm assuming that in these particular use-cases (insert/update), ROLLBACK, NONE and ABORT would all mean the same, resulting in default SQL behaviour, and the behaviour that agera-database has now.
This would mean creating insert with replace would look like;
SqlInsertRequest sqlInsertRequest =
sqlInsertRequest()
.table("table)
.column("column", "value")
.replaceOnConflict()
.compile();
Does this all sound sensible and applicable to your own needs?
It looks fine to me.