gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-wallet-webex] 05/10: do not ignore database version


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] 05/10: do not ignore database version
Date: Sat, 17 Aug 2019 01:54:38 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository wallet-webex.

commit 6a57ad5fe2492173bcebada357af705048fce6f7
Author: Florian Dold <address@hidden>
AuthorDate: Fri Aug 16 23:06:51 2019 +0200

    do not ignore database version
---
 packages/idb-bridge/package.json              |  2 +-
 packages/idb-bridge/src/MemoryBackend.test.ts |  3 ++-
 packages/idb-bridge/src/MemoryBackend.ts      | 19 +++++++------------
 packages/idb-bridge/tsconfig.json             |  1 +
 4 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/packages/idb-bridge/package.json b/packages/idb-bridge/package.json
index a91b5f26..5816b717 100644
--- a/packages/idb-bridge/package.json
+++ b/packages/idb-bridge/package.json
@@ -1,6 +1,6 @@
 {
   "name": "idb-bridge",
-  "version": "0.0.4",
+  "version": "0.0.5",
   "description": "IndexedDB implementation that uses SQLite3 as storage",
   "main": "./build/index.js",
   "types": "./build/index.d.ts",
diff --git a/packages/idb-bridge/src/MemoryBackend.test.ts 
b/packages/idb-bridge/src/MemoryBackend.test.ts
index 41bf1986..7f9c1440 100644
--- a/packages/idb-bridge/src/MemoryBackend.test.ts
+++ b/packages/idb-bridge/src/MemoryBackend.test.ts
@@ -312,7 +312,7 @@ test("export", async t => {
   const backend = new MemoryBackend();
   const idb = new BridgeIDBFactory(backend);
 
-  const request = idb.open("library");
+  const request = idb.open("library", 42);
   request.onupgradeneeded = () => {
     const db = request.result;
     const store = db.createObjectStore("books", { keyPath: "isbn" });
@@ -344,5 +344,6 @@ test("export", async t => {
   
t.assert(exportedData.databases["library"].objectStores["books"].records.length 
=== 3);
   t.deepEqual(exportedData, exportedData2);
 
+  t.is(exportedData.databases["library"].schema.databaseVersion, 42);
   t.pass();
 });
\ No newline at end of file
diff --git a/packages/idb-bridge/src/MemoryBackend.ts 
b/packages/idb-bridge/src/MemoryBackend.ts
index 4154435a..b904dd04 100644
--- a/packages/idb-bridge/src/MemoryBackend.ts
+++ b/packages/idb-bridge/src/MemoryBackend.ts
@@ -107,7 +107,7 @@ interface MemoryBackendDump {
 interface Connection {
   dbName: string;
 
-  modifiedSchema: Schema | undefined;
+  modifiedSchema: Schema;
 
   /**
    * Has the underlying database been deleted?
@@ -491,6 +491,8 @@ export class MemoryBackend implements Backend {
 
     this.connectionsByTransaction[transactionCookie] = myConn;
 
+    myConn.modifiedSchema.databaseVersion = newVersion;
+
     return { transactionCookie };
   }
 
@@ -525,10 +527,7 @@ export class MemoryBackend implements Backend {
     if (!db) {
       throw Error("db not found");
     }
-    if (myConn.modifiedSchema) {
-      return myConn.modifiedSchema;
-    }
-    return db.committedSchema;
+    return myConn.modifiedSchema;
   }
 
   renameIndex(
@@ -827,9 +826,7 @@ export class MemoryBackend implements Backend {
       );
     }
 
-    const schema = myConn.modifiedSchema
-      ? myConn.modifiedSchema
-      : db.committedSchema;
+    const schema = myConn.modifiedSchema;
     const objectStore = myConn.objectStoreMap[objectStoreName];
 
     if (!objectStore.modifiedData) {
@@ -1264,9 +1261,7 @@ export class MemoryBackend implements Backend {
     if (db.txLevel < TransactionLevel.Write) {
       throw Error("only allowed while running a transaction");
     }
-    const schema = myConn.modifiedSchema
-      ? myConn.modifiedSchema
-      : db.committedSchema;
+    const schema = myConn.modifiedSchema;
     const objectStore = myConn.objectStoreMap[storeReq.objectStoreName];
 
     if (!objectStore.modifiedData) {
@@ -1421,7 +1416,7 @@ export class MemoryBackend implements Backend {
       throw Error("only allowed while running a transaction");
     }
 
-    db.committedSchema = myConn.modifiedSchema || db.committedSchema;
+    db.committedSchema = structuredClone(myConn.modifiedSchema);
     db.txLevel = TransactionLevel.Connected;
 
     db.committedIndexes = {};
diff --git a/packages/idb-bridge/tsconfig.json 
b/packages/idb-bridge/tsconfig.json
index 017afdae..8baf78ac 100644
--- a/packages/idb-bridge/tsconfig.json
+++ b/packages/idb-bridge/tsconfig.json
@@ -10,6 +10,7 @@
         "strict": true,
         "incremental": true,
         "sourceMap": true,
+        "typeRoots": ["./node_modules"],
         "types": []
     },
     "include": ["src/**/*"]

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]