Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fixing some $like searches on projects (#8695)
Browse files Browse the repository at this point in the history
Some functions that were searching on project names via $like: %<name>%
were returning hits that it shouldn't have gotten, e.g. finds on `project-name`
getting hits on projects `project-name` and `project-name-avatars`. If the bad
hits happened to come first in the array because their ID happened to come first,
this would result in unwanted behavior like patching the wrong project.

Removed the %'s in these queries, which match additional characters. We
only use $like for case-insensitivity purposes.
  • Loading branch information
barankyle authored Sep 8, 2023
1 parent f909830 commit 44f46af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/server-core/src/projects/project/project-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ export const checkProjectDestinationMatch = async (
const projectExists = await app.service(projectPath).find({
query: {
name: {
$like: '%' + sourceContent.name + '%'
$like: sourceContent.name
}
}
})
Expand Down Expand Up @@ -1468,7 +1468,7 @@ export const updateProject = async (
const existingProjectResult = await app.service(projectPath)._find({
query: {
name: {
$like: `%${projectName}%`
$like: projectName
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion packages/server-core/src/projects/project/project.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class ProjectService<T = ProjectType, ServiceParams extends Params = Proj
const result = (await super._find({
query: {
name: {
$like: `${projectName}%`
$like: projectName
}
}
})) as Paginated<ProjectType>
Expand Down

0 comments on commit 44f46af

Please sign in to comment.