Merge pull request #12361 from Budibase/fix/12154-further-fix-app-user-grid

Further fixes for app user grid
This commit is contained in:
Michael Drury 2023-11-10 12:08:01 +00:00 committed by GitHub
commit 8db9c10cee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View File

@ -10,6 +10,7 @@ import {
DatabaseDeleteIndexOpts, DatabaseDeleteIndexOpts,
Document, Document,
isDocument, isDocument,
RowResponse,
} from "@budibase/types" } from "@budibase/types"
import { getCouchInfo } from "./connections" import { getCouchInfo } from "./connections"
import { directCouchUrlCall } from "./utils" import { directCouchUrlCall } from "./utils"
@ -127,12 +128,19 @@ export class DatabaseImpl implements Database {
keys: ids, keys: ids,
include_docs: true, include_docs: true,
}) })
const NOT_FOUND = "not_found" const rowUnavailable = (row: RowResponse<T>) => {
const rows = response.rows.filter(row => row.error !== NOT_FOUND) // row is deleted - key lookup can return this
if (row.doc == null || ("deleted" in row.value && row.value.deleted)) {
return true
}
return row.error === "not_found"
}
const rows = response.rows.filter(row => !rowUnavailable(row))
const someMissing = rows.length !== response.rows.length const someMissing = rows.length !== response.rows.length
// some were filtered out - means some missing // some were filtered out - means some missing
if (!opts?.allowMissing && someMissing) { if (!opts?.allowMissing && someMissing) {
const missing = response.rows.filter(row => row.error === NOT_FOUND) const missing = response.rows.filter(row => rowUnavailable(row))
const missingIds = missing.map(row => row.key).join(", ") const missingIds = missing.map(row => row.key).join(", ")
throw new Error(`Unable to get documents: ${missingIds}`) throw new Error(`Unable to get documents: ${missingIds}`)
} }

View File

@ -28,7 +28,6 @@ const DEFAULT_SELECT_DB = SelectableDatabase.DEFAULT
// for testing just generate the client once // for testing just generate the client once
let CLOSED = false let CLOSED = false
let CLIENTS: { [key: number]: any } = {} let CLIENTS: { [key: number]: any } = {}
0
let CONNECTED = false let CONNECTED = false
// mock redis always connected // mock redis always connected