Merge pull request #3142 from Budibase/scope-or-view

Scope view filters to table always
This commit is contained in:
Rory Powell 2021-10-26 16:17:14 +01:00 committed by GitHub
commit 073f8ade1f
2 changed files with 2 additions and 2 deletions

View File

@ -44,7 +44,7 @@ Object {
exports[`viewBuilder Filter creates a view with multiple filters and conjunctions 1`] = ` exports[`viewBuilder Filter creates a view with multiple filters and conjunctions 1`] = `
Object { Object {
"map": "function (doc) { "map": "function (doc) {
if (doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" && doc[\\"Name\\"] === \\"Test\\" || doc[\\"Yes\\"] > \\"Value\\") { if (doc.tableId === \\"14f1c4e94d6a47b682ce89d35d4c78b0\\" && (doc[\\"Name\\"] === \\"Test\\" || doc[\\"Yes\\"] > \\"Value\\")) {
emit(doc[\\"_id\\"], doc[\\"undefined\\"]); emit(doc[\\"_id\\"], doc[\\"undefined\\"]);
} }
}", }",

View File

@ -126,7 +126,7 @@ function viewTemplate({ field, tableId, groupBy, filters = [], calculation }) {
delete filters[0].conjunction delete filters[0].conjunction
} }
const parsedFilters = parseFilterExpression(filters) const parsedFilters = parseFilterExpression(filters)
const filterExpression = parsedFilters ? `&& ${parsedFilters}` : "" const filterExpression = parsedFilters ? `&& (${parsedFilters})` : ""
const emitExpression = parseEmitExpression(field, groupBy) const emitExpression = parseEmitExpression(field, groupBy)