* Continue rebasing.
* Wrote unit tests for external associations.
* Fix the generated SQL.
Some syntactic sugar (capitalizing the keywords), but use the 'ON' syntax on JOINs.
* whitespace fix post rebase
* We want "management.cattle.io.projects:spec.displayName" not "...spec.clusterName"
* Fix the database calls: drop the key
* Fix breakage during automatic rebase merging gone wrong.
* ws fix - NFC
* Post rebase-merge fixes
* Fix rebase-driven merge.
* Fix rebase breakage.
* go-uber v0.5.2 prefers real arg names to '<argN>'
* Run tests using sqlite DB in a temp directory.
I was running into write-file errors which happens when two sqlite processes try to update the DB at the same time.
* Implement and test the extractBarredValue custom SQL function.
* Explain the DB path constants better.
* Re-order SQL event hooks so events are last
* Add QueryRowContext for single line queries
* Add test case for unknown resource version
* Properly check rows and close it
* More accurate error message when context.Context is canceled
* Re-order test check
Previous SQLite-related code used context.Background() and context.TODO() because it was not developed with context awareness.
This commit propagates the main Steve context so that it can be used when interacting with SQL context-aware functions.
This PR removes all production-code use of context.Background() and context.TODO() and replaces test-code use of TODO with Background.
Contributes to rancher/rancher#47825
This introduces the a `WithTransaction` function, which is then used for all transactional work in Steve.
Because `WithTransaction` takes care of all `Begin`s, `Commit`s and `Rollback`s, it eliminates the problem where forgotten open transactions can block all other operations (with long stalling and `SQLITE_BUSY` errors).
This also:
- merges together the disparate `DBClient` interfaces in one only `db.Client` interface with one unexported non-test implementation. I found this much easier to follow
- refactors the transaction package in order to make it as minimal as possible, and as close to the wrapped `sql.Tx` and `sql.Stmt` functions as possible, in order to reduce cognitive load when working with this part of the codebase
- simplifies tests accordingly
- adds a couple of known files to `.gitignore`
Credits to @tomleb for suggesting the approach: https://github.com/rancher/lasso/pull/121#pullrequestreview-2515872507