chore: Implement joins with golang templates (#6429)

* feat: Implement view for workspace builds to include rbac info

* Removes the need to fetch the workspace to run an rbac check.
* chore: Use workspace build as RBAC object
* chore: Use golang templates instead of sqlc files
This commit is contained in:
Steven Masley
2023-03-10 09:44:38 -06:00
committed by GitHub
parent a666539bfa
commit 8b125d6c5d
36 changed files with 894 additions and 660 deletions
+12
View File
@@ -16,6 +16,8 @@ import (
"github.com/jmoiron/sqlx"
"golang.org/x/xerrors"
"github.com/coder/coder/coderd/database/sqlxqueries"
)
// Store contains all queryable database functions.
@@ -37,11 +39,21 @@ type DBTX interface {
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
// Extends the sqlx interface
sqlx.QueryerContext
}
// New creates a new database store using a SQL database connection.
func New(sdb *sql.DB) Store {
dbx := sqlx.NewDb(sdb, "postgres")
// Load the embedded queries. If this fails, some of our queries
// will never work. This is a fatal developer error that should never
// happen.
_, err := sqlxqueries.LoadQueries()
if err != nil {
panic(xerrors.Errorf("load queries: %w", err))
}
return &sqlQuerier{
db: dbx,
sdb: dbx,