-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request juju#17009 from Aflynn50/reuse-prepare
juju#17009 When using SQLair statements in domain, there is often little to no reuse of the prepared statements. The statements are created just before they are used then dropped when the method finishes. SQLair statements are designed to be prepared once then reused. This PR adds a `Prepare` function to state base that can be used instead of `sqlair.Prepare`. This function saves the prepared statements in a map keyed by the query itself. `StateBase.Prepare` can be used right next to where the query is run since it is relatively cheap. This allows readers of the code to quickly grok what is going on. This code also updates to the latest version of SQLair which returns `ErrNoRows` when `GetAll` returns no rows (previously it just left the list it was passed empty) [SQLair PR here](canonical/sqlair#138). Because of this checks are added to calls of `GetAll`. <!-- Why this change is needed and what it does. --> ## Checklist <!-- If an item is not applicable, use `~strikethrough~`. --> - [x] Code style: imports ordered, good names, simple structure, etc - [x] Comments saying why design decisions were made - [x] Go unit tests, with comments saying what you're testing - [x] [Integration tests](https://github.com/juju/juju/tree/main/tests), with comments saying what you're testing - [x] [doc.go](https://discourse.charmhub.io/t/readme-in-packages/451) added or updated in changed packages ## QA steps
- Loading branch information
Showing
23 changed files
with
292 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.