fix schema upgrade in memoryidb backend

This commit is contained in:
Florian Dold 2020-11-16 14:32:06 +01:00
parent 292160f7e9
commit deaeb17c02
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -72,7 +72,6 @@ interface Index {
interface Database { interface Database {
committedObjectStores: { [name: string]: ObjectStore }; committedObjectStores: { [name: string]: ObjectStore };
modifiedObjectStores: { [name: string]: ObjectStore };
committedSchema: Schema; committedSchema: Schema;
/** /**
* Was the transaction deleted during the running transaction? * Was the transaction deleted during the running transaction?
@ -326,7 +325,6 @@ export class MemoryBackend implements Backend {
committedObjectStores: objectStores, committedObjectStores: objectStores,
committedSchema: structuredClone(schema), committedSchema: structuredClone(schema),
connectionCookie: undefined, connectionCookie: undefined,
modifiedObjectStores: {},
txLevel: TransactionLevel.Disconnected, txLevel: TransactionLevel.Disconnected,
txRestrictObjectStores: undefined, txRestrictObjectStores: undefined,
}; };
@ -448,7 +446,6 @@ export class MemoryBackend implements Backend {
committedSchema: schema, committedSchema: schema,
deleted: false, deleted: false,
committedObjectStores: {}, committedObjectStores: {},
modifiedObjectStores: {},
txLevel: TransactionLevel.Disconnected, txLevel: TransactionLevel.Disconnected,
connectionCookie: undefined, connectionCookie: undefined,
txRestrictObjectStores: undefined, txRestrictObjectStores: undefined,
@ -782,7 +779,6 @@ export class MemoryBackend implements Backend {
indexes: {}, indexes: {},
}; };
myConn.objectStoreMap[name] = { store: newObjectStore, indexMap: {} }; myConn.objectStoreMap[name] = { store: newObjectStore, indexMap: {} };
db.modifiedObjectStores[name] = newObjectStore;
} }
createIndex( createIndex(
@ -820,9 +816,6 @@ export class MemoryBackend implements Backend {
originalName: indexName, originalName: indexName,
}; };
myConn.objectStoreMap[objectStoreName].indexMap[indexName] = newIndex; myConn.objectStoreMap[objectStoreName].indexMap[indexName] = newIndex;
db.modifiedObjectStores[objectStoreName].modifiedIndexes[
indexName
] = newIndex;
const schema = myConn.modifiedSchema; const schema = myConn.modifiedSchema;
if (!schema) { if (!schema) {
throw Error("no schema in versionchange tx"); throw Error("no schema in versionchange tx");
@ -1530,7 +1523,6 @@ export class MemoryBackend implements Backend {
if (db.txLevel < TransactionLevel.Read) { if (db.txLevel < TransactionLevel.Read) {
throw Error("only allowed while running a transaction"); throw Error("only allowed while running a transaction");
} }
db.modifiedObjectStores = {};
db.txLevel = TransactionLevel.Connected; db.txLevel = TransactionLevel.Connected;
db.txRestrictObjectStores = undefined; db.txRestrictObjectStores = undefined;
myConn.modifiedSchema = structuredClone(db.committedSchema); myConn.modifiedSchema = structuredClone(db.committedSchema);