Skip to content

Commit 8780e4e

Browse files
committed
Handle nil prepared case
1 parent d9d23b6 commit 8780e4e

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

coderd/database/databasefake/databasefake.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,11 @@ func (q *fakeQuerier) GetAuthorizedUserCount(ctx context.Context, params databas
612612
defer q.mutex.RUnlock()
613613

614614
// Call this to match the same function calls as the SQL implementation.
615-
_, err := prepared.CompileToSQL(ctx, rbac.ConfigWithoutACL())
616-
if err != nil {
617-
return -1, err
615+
if prepared != nil {
616+
_, err := prepared.CompileToSQL(ctx, rbac.ConfigWithoutACL())
617+
if err != nil {
618+
return -1, err
619+
}
618620
}
619621

620622
users := make([]database.User, 0, len(q.users))
@@ -895,10 +897,12 @@ func (q *fakeQuerier) GetAuthorizedWorkspaces(ctx context.Context, arg database.
895897
q.mutex.RLock()
896898
defer q.mutex.RUnlock()
897899

898-
// Call this to match the same function calls as the SQL implementation.
899-
_, err := prepared.CompileToSQL(ctx, rbac.ConfigWithoutACL())
900-
if err != nil {
901-
return nil, err
900+
if prepared != nil {
901+
// Call this to match the same function calls as the SQL implementation.
902+
_, err := prepared.CompileToSQL(ctx, rbac.ConfigWithoutACL())
903+
if err != nil {
904+
return nil, err
905+
}
902906
}
903907

904908
workspaces := make([]database.Workspace, 0)
@@ -1708,9 +1712,11 @@ func (q *fakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G
17081712
defer q.mutex.RUnlock()
17091713

17101714
// Call this to match the same function calls as the SQL implementation.
1711-
_, err := prepared.CompileToSQL(ctx, rbac.ConfigWithoutACL())
1712-
if err != nil {
1713-
return nil, err
1715+
if prepared != nil {
1716+
_, err := prepared.CompileToSQL(ctx, rbac.ConfigWithACL())
1717+
if err != nil {
1718+
return nil, err
1719+
}
17141720
}
17151721

17161722
var templates []database.Template

0 commit comments

Comments
 (0)