Skip to content

Commit 0eb83da

Browse files
authored
[nexus] use raw query builder for sitrep version insertion CTE (#9380)
Depends on #9335. In [this comment][1] on PR #9335, @smklein suggested using the `raw_query_builder` API for writing CTEs, rather than using Diesel's `QueryFragment` API. This turns out to be a lot less unpleasant and, despite performing less validation of the generated SQL, actually is a lot *less* likely to introduce hard-to-debug SQL syntax errors. Since most of the query can be written in a single string literal, you actually see more or less what you're gonna get, which is much less obvious with Diesel's API. The `InsertSitrepVersionQuery` CTE in the same module still uses the `QueryFragment` API, rather than the `raw_query_builder` module, since I didn't want to change the existing code in that branch. This PR refactors the CTE for inserting a new sitrep version to also use `raw_query_builder`, which is much nicer and should be easier to modify in the future. There should be no functional changes here, just a change to use a different API to generate the query. Incidentally, this was one of the first times I had real success getting Claude to do a fairly trivial "transform this code from using one API to using another" task --- it wrote most of the first commit, and I tweaked some of its style decisions I didn't love. [1]: #9335 (comment)
1 parent c009adb commit 0eb83da

File tree

2 files changed

+265
-304
lines changed

2 files changed

+265
-304
lines changed

0 commit comments

Comments
 (0)