Fixing issue discovered by test with 1: syntax being required for relationship based filters.
This commit is contained in:
parent
0561ca6e1b
commit
a5c5e2ffcd
|
@ -55,8 +55,8 @@ function buildInternalFieldList(
|
||||||
return fieldList
|
return fieldList
|
||||||
}
|
}
|
||||||
|
|
||||||
function tableInFilter(name: string) {
|
function tableNameInFieldRegex(tableName: string) {
|
||||||
return `:${name}.`
|
return new RegExp(`^${tableName}.|:${tableName}.`, "g")
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanupFilters(filters: SearchFilters, tables: Table[]) {
|
function cleanupFilters(filters: SearchFilters, tables: Table[]) {
|
||||||
|
@ -72,15 +72,13 @@ function cleanupFilters(filters: SearchFilters, tables: Table[]) {
|
||||||
// relationship, switch to table ID
|
// relationship, switch to table ID
|
||||||
const tableRelated = tables.find(
|
const tableRelated = tables.find(
|
||||||
table =>
|
table =>
|
||||||
table.originalName && key.includes(tableInFilter(table.originalName))
|
table.originalName &&
|
||||||
|
key.match(tableNameInFieldRegex(table.originalName))
|
||||||
)
|
)
|
||||||
if (tableRelated && tableRelated.originalName) {
|
if (tableRelated && tableRelated.originalName) {
|
||||||
filter[
|
// only replace the first, not replaceAll
|
||||||
key.replace(
|
filter[key.replace(tableRelated.originalName, tableRelated._id!)] =
|
||||||
tableInFilter(tableRelated.originalName),
|
filter[key]
|
||||||
tableInFilter(tableRelated._id!)
|
|
||||||
)
|
|
||||||
] = filter[key]
|
|
||||||
delete filter[key]
|
delete filter[key]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue