mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
fix(database): remove usage of String()
for comparing UUIDs (#4547)
This commit is contained in:
@ -240,7 +240,7 @@ func (q *fakeQuerier) ParameterValue(_ context.Context, id uuid.UUID) (database.
|
|||||||
defer q.mutex.Unlock()
|
defer q.mutex.Unlock()
|
||||||
|
|
||||||
for _, parameterValue := range q.parameterValues {
|
for _, parameterValue := range q.parameterValues {
|
||||||
if parameterValue.ID.String() != id.String() {
|
if parameterValue.ID != id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return parameterValue, nil
|
return parameterValue, nil
|
||||||
@ -253,7 +253,7 @@ func (q *fakeQuerier) DeleteParameterValueByID(_ context.Context, id uuid.UUID)
|
|||||||
defer q.mutex.Unlock()
|
defer q.mutex.Unlock()
|
||||||
|
|
||||||
for index, parameterValue := range q.parameterValues {
|
for index, parameterValue := range q.parameterValues {
|
||||||
if parameterValue.ID.String() != id.String() {
|
if parameterValue.ID != id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
q.parameterValues[index] = q.parameterValues[len(q.parameterValues)-1]
|
q.parameterValues[index] = q.parameterValues[len(q.parameterValues)-1]
|
||||||
@ -495,7 +495,7 @@ func (q *fakeQuerier) GetUsersByIDs(_ context.Context, ids []uuid.UUID) ([]datab
|
|||||||
users := make([]database.User, 0)
|
users := make([]database.User, 0)
|
||||||
for _, user := range q.users {
|
for _, user := range q.users {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
if user.ID.String() != id.String() {
|
if user.ID != id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
users = append(users, user)
|
users = append(users, user)
|
||||||
@ -716,7 +716,7 @@ func (q *fakeQuerier) GetWorkspaceByID(_ context.Context, id uuid.UUID) (databas
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, workspace := range q.workspaces {
|
for _, workspace := range q.workspaces {
|
||||||
if workspace.ID.String() == id.String() {
|
if workspace.ID == id {
|
||||||
return workspace, nil
|
return workspace, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -787,7 +787,7 @@ func (q *fakeQuerier) GetWorkspaceAppsByAgentIDs(_ context.Context, ids []uuid.U
|
|||||||
apps := make([]database.WorkspaceApp, 0)
|
apps := make([]database.WorkspaceApp, 0)
|
||||||
for _, app := range q.workspaceApps {
|
for _, app := range q.workspaceApps {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
if app.AgentID.String() == id.String() {
|
if app.AgentID == id {
|
||||||
apps = append(apps, app)
|
apps = append(apps, app)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -836,7 +836,7 @@ func (q *fakeQuerier) GetWorkspaceBuildByID(_ context.Context, id uuid.UUID) (da
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, history := range q.workspaceBuilds {
|
for _, history := range q.workspaceBuilds {
|
||||||
if history.ID.String() == id.String() {
|
if history.ID == id {
|
||||||
return history, nil
|
return history, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -848,7 +848,7 @@ func (q *fakeQuerier) GetWorkspaceCountByUserID(_ context.Context, id uuid.UUID)
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
var count int64
|
var count int64
|
||||||
for _, workspace := range q.workspaces {
|
for _, workspace := range q.workspaces {
|
||||||
if workspace.OwnerID.String() == id.String() {
|
if workspace.OwnerID == id {
|
||||||
if workspace.Deleted {
|
if workspace.Deleted {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -864,7 +864,7 @@ func (q *fakeQuerier) GetWorkspaceBuildByJobID(_ context.Context, jobID uuid.UUI
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, build := range q.workspaceBuilds {
|
for _, build := range q.workspaceBuilds {
|
||||||
if build.JobID.String() == jobID.String() {
|
if build.JobID == jobID {
|
||||||
return build, nil
|
return build, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -953,7 +953,7 @@ func (q *fakeQuerier) GetWorkspaceBuildsByWorkspaceID(_ context.Context,
|
|||||||
if workspaceBuild.CreatedAt.Before(params.Since) {
|
if workspaceBuild.CreatedAt.Before(params.Since) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if workspaceBuild.WorkspaceID.String() == params.WorkspaceID.String() {
|
if workspaceBuild.WorkspaceID == params.WorkspaceID {
|
||||||
history = append(history, workspaceBuild)
|
history = append(history, workspaceBuild)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1006,7 +1006,7 @@ func (q *fakeQuerier) GetWorkspaceBuildByWorkspaceIDAndBuildNumber(_ context.Con
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, workspaceBuild := range q.workspaceBuilds {
|
for _, workspaceBuild := range q.workspaceBuilds {
|
||||||
if workspaceBuild.WorkspaceID.String() != arg.WorkspaceID.String() {
|
if workspaceBuild.WorkspaceID != arg.WorkspaceID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if workspaceBuild.BuildNumber != arg.BuildNumber {
|
if workspaceBuild.BuildNumber != arg.BuildNumber {
|
||||||
@ -1121,7 +1121,7 @@ func (q *fakeQuerier) GetTemplateByID(_ context.Context, id uuid.UUID) (database
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, template := range q.templates {
|
for _, template := range q.templates {
|
||||||
if template.ID.String() == id.String() {
|
if template.ID == id {
|
||||||
return template, nil
|
return template, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1217,7 +1217,7 @@ func (q *fakeQuerier) GetTemplateVersionsByTemplateID(_ context.Context, arg dat
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, templateVersion := range q.templateVersions {
|
for _, templateVersion := range q.templateVersions {
|
||||||
if templateVersion.TemplateID.UUID.String() != arg.TemplateID.String() {
|
if templateVersion.TemplateID.UUID != arg.TemplateID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
version = append(version, templateVersion)
|
version = append(version, templateVersion)
|
||||||
@ -1305,7 +1305,7 @@ func (q *fakeQuerier) GetTemplateVersionByID(_ context.Context, templateVersionI
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, templateVersion := range q.templateVersions {
|
for _, templateVersion := range q.templateVersions {
|
||||||
if templateVersion.ID.String() != templateVersionID.String() {
|
if templateVersion.ID != templateVersionID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return templateVersion, nil
|
return templateVersion, nil
|
||||||
@ -1318,7 +1318,7 @@ func (q *fakeQuerier) GetTemplateVersionByJobID(_ context.Context, jobID uuid.UU
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, templateVersion := range q.templateVersions {
|
for _, templateVersion := range q.templateVersions {
|
||||||
if templateVersion.JobID.String() != jobID.String() {
|
if templateVersion.JobID != jobID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return templateVersion, nil
|
return templateVersion, nil
|
||||||
@ -1332,7 +1332,7 @@ func (q *fakeQuerier) GetParameterSchemasByJobID(_ context.Context, jobID uuid.U
|
|||||||
|
|
||||||
parameters := make([]database.ParameterSchema, 0)
|
parameters := make([]database.ParameterSchema, 0)
|
||||||
for _, parameterSchema := range q.parameterSchemas {
|
for _, parameterSchema := range q.parameterSchemas {
|
||||||
if parameterSchema.JobID.String() != jobID.String() {
|
if parameterSchema.JobID != jobID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
parameters = append(parameters, parameterSchema)
|
parameters = append(parameters, parameterSchema)
|
||||||
@ -1685,7 +1685,7 @@ func (q *fakeQuerier) GetProvisionerDaemonByID(_ context.Context, id uuid.UUID)
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, provisionerDaemon := range q.provisionerDaemons {
|
for _, provisionerDaemon := range q.provisionerDaemons {
|
||||||
if provisionerDaemon.ID.String() != id.String() {
|
if provisionerDaemon.ID != id {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return provisionerDaemon, nil
|
return provisionerDaemon, nil
|
||||||
@ -1711,7 +1711,7 @@ func (q *fakeQuerier) GetWorkspaceResourceByID(_ context.Context, id uuid.UUID)
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, resource := range q.provisionerJobResources {
|
for _, resource := range q.provisionerJobResources {
|
||||||
if resource.ID.String() == id.String() {
|
if resource.ID == id {
|
||||||
return resource, nil
|
return resource, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1724,7 +1724,7 @@ func (q *fakeQuerier) GetWorkspaceResourcesByJobID(_ context.Context, jobID uuid
|
|||||||
|
|
||||||
resources := make([]database.WorkspaceResource, 0)
|
resources := make([]database.WorkspaceResource, 0)
|
||||||
for _, resource := range q.provisionerJobResources {
|
for _, resource := range q.provisionerJobResources {
|
||||||
if resource.JobID.String() != jobID.String() {
|
if resource.JobID != jobID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
resources = append(resources, resource)
|
resources = append(resources, resource)
|
||||||
@ -1791,7 +1791,7 @@ func (q *fakeQuerier) GetWorkspaceResourceMetadataByResourceID(_ context.Context
|
|||||||
|
|
||||||
metadata := make([]database.WorkspaceResourceMetadatum, 0)
|
metadata := make([]database.WorkspaceResourceMetadatum, 0)
|
||||||
for _, metadatum := range q.provisionerJobResourceMetadata {
|
for _, metadatum := range q.provisionerJobResourceMetadata {
|
||||||
if metadatum.WorkspaceResourceID.String() == id.String() {
|
if metadatum.WorkspaceResourceID == id {
|
||||||
metadata = append(metadata, metadatum)
|
metadata = append(metadata, metadatum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1805,7 +1805,7 @@ func (q *fakeQuerier) GetWorkspaceResourceMetadataByResourceIDs(_ context.Contex
|
|||||||
metadata := make([]database.WorkspaceResourceMetadatum, 0)
|
metadata := make([]database.WorkspaceResourceMetadatum, 0)
|
||||||
for _, metadatum := range q.provisionerJobResourceMetadata {
|
for _, metadatum := range q.provisionerJobResourceMetadata {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
if metadatum.WorkspaceResourceID.String() == id.String() {
|
if metadatum.WorkspaceResourceID == id {
|
||||||
metadata = append(metadata, metadatum)
|
metadata = append(metadata, metadatum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1820,7 +1820,7 @@ func (q *fakeQuerier) GetProvisionerJobsByIDs(_ context.Context, ids []uuid.UUID
|
|||||||
jobs := make([]database.ProvisionerJob, 0)
|
jobs := make([]database.ProvisionerJob, 0)
|
||||||
for _, job := range q.provisionerJobs {
|
for _, job := range q.provisionerJobs {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
if id.String() == job.ID.String() {
|
if id == job.ID {
|
||||||
jobs = append(jobs, job)
|
jobs = append(jobs, job)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -1852,7 +1852,7 @@ func (q *fakeQuerier) GetProvisionerLogsByIDBetween(_ context.Context, arg datab
|
|||||||
|
|
||||||
logs := make([]database.ProvisionerJobLog, 0)
|
logs := make([]database.ProvisionerJobLog, 0)
|
||||||
for _, jobLog := range q.provisionerJobLogs {
|
for _, jobLog := range q.provisionerJobLogs {
|
||||||
if jobLog.JobID.String() != arg.JobID.String() {
|
if jobLog.JobID != arg.JobID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !arg.CreatedBefore.IsZero() && jobLog.CreatedAt.After(arg.CreatedBefore) {
|
if !arg.CreatedBefore.IsZero() && jobLog.CreatedAt.After(arg.CreatedBefore) {
|
||||||
@ -2663,7 +2663,7 @@ func (q *fakeQuerier) UpdateGitSSHKey(_ context.Context, arg database.UpdateGitS
|
|||||||
defer q.mutex.Unlock()
|
defer q.mutex.Unlock()
|
||||||
|
|
||||||
for index, key := range q.gitSSHKey {
|
for index, key := range q.gitSSHKey {
|
||||||
if key.UserID.String() != arg.UserID.String() {
|
if key.UserID != arg.UserID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
key.UpdatedAt = arg.UpdatedAt
|
key.UpdatedAt = arg.UpdatedAt
|
||||||
@ -2726,7 +2726,7 @@ func (q *fakeQuerier) DeleteGitSSHKey(_ context.Context, userID uuid.UUID) error
|
|||||||
defer q.mutex.Unlock()
|
defer q.mutex.Unlock()
|
||||||
|
|
||||||
for index, key := range q.gitSSHKey {
|
for index, key := range q.gitSSHKey {
|
||||||
if key.UserID.String() != userID.String() {
|
if key.UserID != userID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
q.gitSSHKey[index] = q.gitSSHKey[len(q.gitSSHKey)-1]
|
q.gitSSHKey[index] = q.gitSSHKey[len(q.gitSSHKey)-1]
|
||||||
@ -3039,7 +3039,7 @@ func (q *fakeQuerier) InsertGroup(_ context.Context, arg database.InsertGroupPar
|
|||||||
defer q.mutex.RUnlock()
|
defer q.mutex.RUnlock()
|
||||||
|
|
||||||
for _, group := range q.groups {
|
for _, group := range q.groups {
|
||||||
if group.OrganizationID.String() == arg.OrganizationID.String() &&
|
if group.OrganizationID == arg.OrganizationID &&
|
||||||
group.Name == arg.Name {
|
group.Name == arg.Name {
|
||||||
return database.Group{}, errDuplicateKey
|
return database.Group{}, errDuplicateKey
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user