[db] turn @sunshowers' limit-reached query into a reusable thing#10889
Conversation
|
I'm putting this up for review now so that I can get @sunshowers' opinion on it: in particular, I'm considering changing it a bit more so that |
@smklein et al, Rain said they have a moderate preference for leaving this as-is and keeping the query composable with other stuff that might want to run in the same transaction, even if it comes at the cost of requiring the user to have to remember they must |
Update on this: now that I have started actually trying to write code that uses this thing, I have quickly realized that it is quite valuable to be able to run the limit-reached check query in a transaction that does other things --- I would like to be able to delete records only if over the limit, and that is, of course, hard to do outside a transaction (or CTE) which ensures that the check if over the limit and the deletion of the records occurs atomically. So, I think I'm going to leave this PR as it is. |
This commit factors out the main logic of @sunshowers'
DataStore::check_blueprint_limit_reachedquery into a reusable query fragment, because I wanted to use a similar query in my implementation of #9384 and felt this was nicer than copying and pasting it, even if it took much more fighting with Diesel than just copying it would have.Fixes #10896