From b88f9aaa14b96ab11b68b690bd39f57d7b5307fa Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 1 Mar 2023 19:01:13 +0000 Subject: [PATCH] Fix for #9739 - there was an issue with the mango syntax, when working with multi attachment columns it was using an AND comparator instead of OR, it should be searching for rows that contain any attachment column, not all attachment columns. --- packages/backend-core/src/migrations/migrations.ts | 6 +++++- packages/server/src/sdk/app/rows/attachments.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/migrations/migrations.ts b/packages/backend-core/src/migrations/migrations.ts index 2e3524775f..48d3b14a4a 100644 --- a/packages/backend-core/src/migrations/migrations.ts +++ b/packages/backend-core/src/migrations/migrations.ts @@ -86,7 +86,11 @@ export const runMigration = async ( count++ const lengthStatement = length > 1 ? `[${count}/${length}]` : "" - const db = getDB(dbName) + const db = getDB(dbName, { skip_setup: true }) + // DB doesn't exist - no-op required + if (!(await db.exists())) { + continue + } try { const doc = await getMigrationsDoc(db) diff --git a/packages/server/src/sdk/app/rows/attachments.ts b/packages/server/src/sdk/app/rows/attachments.ts index 67f58f8f2c..bd04f64146 100644 --- a/packages/server/src/sdk/app/rows/attachments.ts +++ b/packages/server/src/sdk/app/rows/attachments.ts @@ -13,13 +13,13 @@ function generateAttachmentFindParams( ) { const params: CouchFindOptions = { selector: { + $or: attachmentCols.map(col => ({ [col]: { $exists: true } })), _id: { $regex: `^${DocumentType.ROW}${SEPARATOR}${tableId}`, }, }, limit: FIND_LIMIT, } - attachmentCols.forEach(col => (params.selector[col] = { $exists: true })) if (bookmark) { params.bookmark = bookmark }