mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user