diff --git a/packages/server/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap b/packages/server/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap index dfe5f78c46..27c8615a46 100644 --- a/packages/server/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +++ b/packages/server/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap @@ -44,7 +44,7 @@ Object { exports[`viewBuilder Filter creates a view with multiple filters and conjunctions 1`] = ` Object { "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\\"]); } }", diff --git a/packages/server/src/api/controllers/view/viewBuilder.js b/packages/server/src/api/controllers/view/viewBuilder.js index b0f39b2f1f..6e2e5c8527 100644 --- a/packages/server/src/api/controllers/view/viewBuilder.js +++ b/packages/server/src/api/controllers/view/viewBuilder.js @@ -126,7 +126,7 @@ function viewTemplate({ field, tableId, groupBy, filters = [], calculation }) { delete filters[0].conjunction } const parsedFilters = parseFilterExpression(filters) - const filterExpression = parsedFilters ? `&& ${parsedFilters}` : "" + const filterExpression = parsedFilters ? `&& (${parsedFilters})` : "" const emitExpression = parseEmitExpression(field, groupBy)