fix: game version filter in search using quotes instead of backticks (#6415)

This commit is contained in:
Truman Gao
2026-06-16 12:22:52 -06:00
committed by GitHub
parent 3679d2c786
commit b5f7406998
2 changed files with 15 additions and 14 deletions
+10 -10
View File
@@ -484,7 +484,7 @@ export function useSearch(
}
orGroups[field].push(val)
} else {
parts.push(`${field} = ${enquoteNonBools(val)}`)
parts.push(`${field} = ${formatSearchFilterValue(val)}`)
}
}
}
@@ -492,15 +492,15 @@ export function useSearch(
for (const [field, values] of Object.entries(orGroups)) {
if (values.length === 1) {
const val = values[0]
parts.push(`${field} = ${enquoteNonBools(val)}`)
parts.push(`${field} = ${formatSearchFilterValue(val)}`)
} else {
const quoted = values.map(enquoteNonBools).join(', ')
const quoted = values.map(formatSearchFilterValue).join(', ')
parts.push(`${field} IN [${quoted}]`)
}
}
for (const [field, values] of Object.entries(negativeByType)) {
const quoted = values.map(enquoteNonBools).join(', ')
const quoted = values.map(formatSearchFilterValue).join(', ')
parts.push(`${field} NOT IN [${quoted}]`)
}
@@ -514,11 +514,11 @@ export function useSearch(
for (const envGroup of getEnvironmentFilterGroups(client, server)) {
if (envGroup.length === 1) {
const [field, val] = envGroup[0].split(':')
parts.push(`${field} = ${enquoteNonBools(val)}`)
parts.push(`${field} = ${formatSearchFilterValue(val)}`)
} else if (envGroup.length > 1) {
const conditions = envGroup.map((f) => {
const [field, val] = f.split(':')
return `${field} = ${enquoteNonBools(val)}`
return `${field} = ${formatSearchFilterValue(val)}`
})
parts.push(`(${conditions.join(' OR ')})`)
}
@@ -527,9 +527,9 @@ export function useSearch(
// Project types
const mappedProjectTypes = projectTypes.value.map(mapProjectTypeToSearch)
if (mappedProjectTypes.length === 1) {
parts.push(`project_types = ${enquoteNonBools(mappedProjectTypes[0])}`)
parts.push(`project_types = ${formatSearchFilterValue(mappedProjectTypes[0])}`)
} else if (mappedProjectTypes.length > 1) {
const quoted = mappedProjectTypes.map(enquoteNonBools).join(', ')
const quoted = mappedProjectTypes.map(formatSearchFilterValue).join(', ')
parts.push(`project_types IN [${quoted}]`)
}
@@ -792,11 +792,11 @@ function getEnvironmentFilterGroups(client: boolean, server: boolean): string[][
return groups
}
function enquoteNonBools(value: string): string {
export function formatSearchFilterValue(value: string): string {
if (value === 'true' || value === 'false') {
return value
}
return `"${value}"`
return `\`${value}\``
}
function getOptionValue(option: FilterOption, negative?: boolean): string {
+5 -4
View File
@@ -6,6 +6,7 @@ import { useRoute } from 'vue-router'
import { defineMessage, LOCALES, useVIntl } from '../composables/i18n'
import type { FilterType, FilterValue, SortType, Tags } from './search'
import { formatSearchFilterValue } from './search'
import { formatCategory, formatCategoryHeader } from './tag-messages'
export const SERVER_REGIONS = {
@@ -363,11 +364,11 @@ export function useServerSearch(opts: {
const included = matched.filter((f) => !f.negative)
const excluded = matched.filter((f) => f.negative)
if (included.length > 0) {
const values = included.map((f) => `"${f.option}"`).join(', ')
const values = included.map((f) => formatSearchFilterValue(f.option)).join(', ')
parts.push(`${field} IN [${values}]`)
}
if (excluded.length > 0) {
const values = excluded.map((f) => `"${f.option}"`).join(', ')
const values = excluded.map((f) => formatSearchFilterValue(f.option)).join(', ')
parts.push(`${field} NOT IN [${values}]`)
}
}
@@ -389,11 +390,11 @@ export function useServerSearch(opts: {
.map((filter) => filter.projectId)
if (includedProjectIds.length > 0) {
const values = includedProjectIds.map((projectId) => `"${projectId}"`).join(', ')
const values = includedProjectIds.map(formatSearchFilterValue).join(', ')
parts.push(`project_id IN [${values}]`)
}
if (excludedProjectIds.length > 0) {
const values = excludedProjectIds.map((projectId) => `"${projectId}"`).join(', ')
const values = excludedProjectIds.map(formatSearchFilterValue).join(', ')
parts.push(`project_id NOT IN [${values}]`)
}