Don't return collections outside of cache (#7020)

Fixes #6602
This commit is contained in:
Rijk van Zanten
2021-07-28 00:57:31 +02:00
committed by GitHub
parent 628e4ead58
commit f81dfda20f

View File

@@ -207,6 +207,11 @@ export class CollectionsService {
const collections: Collection[] = [];
/**
* The collections as known in the schema cache.
*/
const knownCollections = Object.keys(this.schema.collections);
for (const table of tablesInDatabase) {
const collection: Collection = {
collection: table.name,
@@ -214,7 +219,12 @@ export class CollectionsService {
schema: table,
};
collections.push(collection);
// By only returning collections that are known in the schema cache, we prevent weird
// situations where the collections endpoint returns different info from every other
// collection
if (knownCollections.includes(table.name)) {
collections.push(collection);
}
}
return collections;
@@ -266,6 +276,8 @@ export class CollectionsService {
const collections: Collection[] = [];
const knownCollections = Object.keys(this.schema.collections);
for (const table of tables) {
const collection: Collection = {
collection: table.name,
@@ -273,7 +285,12 @@ export class CollectionsService {
schema: table,
};
collections.push(collection);
// By only returning collections that are known in the schema cache, we prevent weird
// situations where the collections endpoint returns different info from every other
// collection
if (knownCollections.includes(table.name)) {
collections.push(collection);
}
}
return collections;