boulder/db
Jacob Hoffman-Andrews 4be76afcaf
Extract out `db.QuestionMarks` function (#6568)
We use this pattern in several places: there is a query that needs to
have a variable number of placeholders (question marks) in it, depending
on how many items we are inserting or querying for. For instance, when
issuing a precertificate we add that precertificate's names to the
"issuedNames" table. To make things more efficient, we do that in a
single query, whether there is one name on the certificate or a hundred.
That means interpolating into the query string with series of question
marks that matches the number of names.

We have a helper type MultiInserter that solves this problem for simple
inserts, but it does not solve the problem for selects or more complex
inserts, and we still have a number of places that generate their
sequence of question marks manually.

This change updates addIssuedNames to use MultiInserter. To enable that,
it also narrows the interface required by MultiInserter.Insert, so it's
easier to mock in tests.

This change adds the new function db.QuestionMarks, which generates e.g.
`?,?,?` depending on the input N.

In a few places I had to rename a function parameter named `db` to avoid
shadowing the `db` package.
2023-01-10 14:29:31 -08:00
..
gorm.go Unify how we do streaming database selects (#6176) 2022-06-24 14:31:46 -07:00
interfaces.go Extract out `db.QuestionMarks` function (#6568) 2023-01-10 14:29:31 -08:00
map.go Unify how we do streaming database selects (#6176) 2022-06-24 14:31:46 -07:00
map_test.go SA: Standardize methods which use COUNT queries (#6505) 2022-11-14 18:10:32 -08:00
multi.go Extract out `db.QuestionMarks` function (#6568) 2023-01-10 14:29:31 -08:00
multi_test.go Add new SA.NewOrderAndAuthzs gRPC method (#5602) 2021-09-03 13:48:04 -07:00
qmarks.go Extract out `db.QuestionMarks` function (#6568) 2023-01-10 14:29:31 -08:00
qmarks_test.go Extract out `db.QuestionMarks` function (#6568) 2023-01-10 14:29:31 -08:00
rollback.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00
rollback_test.go Fix nits found by staticcheck (#4726) 2020-03-30 10:20:20 -07:00
transaction.go SA: use wrapped database maps/transactions. (#4585) 2019-12-04 13:03:09 -05:00