Merge pull request #14157 from Budibase/fix/default-table-dupes

Default table - in-memory/on-disk representation duplicates
This commit is contained in:
Michael Drury 2024-07-12 14:25:38 +01:00 committed by GitHub
commit b7703428a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 2 deletions

View File

@ -127,9 +127,14 @@ function mapTable(table: Table): SQLiteTables {
// nothing exists, need to iterate though existing tables
async function buildBaseDefinition(): Promise<PreSaveSQLiteDefinition> {
const tables = await tablesSdk.getAllInternalTables()
const defaultTables = DEFAULT_TABLES
for (const defaultTable of DEFAULT_TABLES) {
// the default table doesn't exist in Couch, use the in-memory representation
if (!tables.find(table => table._id === defaultTable._id)) {
tables.push(defaultTable)
}
}
const definition = sql.designDoc.base("tableId")
for (let table of tables.concat(defaultTables)) {
for (let table of tables) {
definition.sql.tables = {
...definition.sql.tables,
...mapTable(table),