deepbase-sqlite 3.4.11 → 3.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepbase-sqlite",
3
- "version": "3.4.11",
3
+ "version": "3.4.12",
4
4
  "description": "⚡ DeepBase SQLite - SQLite database driver",
5
5
  "type": "module",
6
6
  "main": "src/index.cjs",
@@ -17,7 +17,7 @@
17
17
  "better-sqlite3": "^11.8.1"
18
18
  },
19
19
  "peerDependencies": {
20
- "deepbase": "^3.4.11"
20
+ "deepbase": "^3.4.12"
21
21
  },
22
22
  "scripts": {
23
23
  "test": "mocha test/test.js"
@@ -25,6 +25,8 @@ export class SqliteDriver extends DeepBaseDriver {
25
25
  }
26
26
 
27
27
  async connect() {
28
+ if (this._connected) return;
29
+
28
30
  if (!fs.existsSync(this.path)) {
29
31
  fs.mkdirSync(this.path, { recursive: true });
30
32
  }
@@ -54,6 +56,7 @@ export class SqliteDriver extends DeepBaseDriver {
54
56
  this.db.close();
55
57
  this.db = null;
56
58
  }
59
+ this._connected = false;
57
60
  }
58
61
 
59
62
  async get(...args) {
package/test/test.js CHANGED
@@ -388,6 +388,20 @@ describe('SqliteDriver', function() {
388
388
  const result = await db.get('before');
389
389
  assert.strictEqual(result, 'disconnect');
390
390
  });
391
+
392
+ it('should be a no-op when already connected', async function() {
393
+ await db.set('key', 'value');
394
+
395
+ // connect again while already connected
396
+ await db.connect();
397
+
398
+ // data and operations should be unaffected
399
+ const result = await db.get('key');
400
+ assert.strictEqual(result, 'value');
401
+
402
+ await db.set('key2', 'value2');
403
+ assert.strictEqual(await db.get('key2'), 'value2');
404
+ });
391
405
  });
392
406
 
393
407
  describe('Singleton Pattern', function() {