You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is -- unfortunately -- database specific. MySQL and Postgres have different syntax for this functionality. So we'd need to gate that behind the .MySQL and .Postgresql modules.
Based on this comments I came with a solution for postgres in a function named insertSelectWithConflict, firm (MonadIO m, PersistEntity val) => Unique val -> SqlQuery (SqlExpr (Insertion val)) -> (SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Update val)]) -> SqlWriteT m (), it works similar to insertSelect but allows solving conflicts on a single constraint when doing insertSelect, @tysonzero problem could be solved using this function, but he will need to specify updating all the values using the excluded values, I though I could code a replaceSelect based on insertSelectWithConflict but turns out there is no way to get the lenses for each field of a datatype on a single list from persist, so I could not generate the updates list automatically, and the other solution was building all from strings that may introduce some error along the way, given the insertSelectWithConflict already accomplishes the task with a small manual work and that it allows great flexibility I think is a good solution for this issue.
It would be nice to have an
insertSelect
equivalent that replaces overlapping rows that already exist.The text was updated successfully, but these errors were encountered: