@tursodatabase/database 0.8.3-pre.2 → 0.8.4-pre.2

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.
@@ -29,6 +29,30 @@ test('in-memory-db-async', async () => {
29
29
  const rows = await stmt.all([1]);
30
30
  expect(rows).toEqual([{ x: 1 }, { x: 3 }]);
31
31
  });
32
+ test('concurrent calls on one prepared statement use their own parameters', async () => {
33
+ const db = await connect(":memory:");
34
+ await db.exec("CREATE TABLE items (key TEXT PRIMARY KEY, value TEXT NOT NULL)");
35
+ await db.exec("INSERT INTO items VALUES ('first', 'first value'), ('second', 'second value')");
36
+ const select = await db.prepare("SELECT value FROM items WHERE key = ?");
37
+ const rows = await Promise.all([select.get('first'), select.get('second')]);
38
+ expect(rows).toEqual([{ value: 'first value' }, { value: 'second value' }]);
39
+ const all = await Promise.all([select.all('first'), select.all('second')]);
40
+ expect(all).toEqual([[{ value: 'first value' }], [{ value: 'second value' }]]);
41
+ const collect = async (key) => {
42
+ const out = [];
43
+ for await (const row of select.iterate(key)) {
44
+ out.push(row);
45
+ }
46
+ return out;
47
+ };
48
+ const iterated = await Promise.all([collect('first'), collect('second')]);
49
+ expect(iterated).toEqual([[{ value: 'first value' }], [{ value: 'second value' }]]);
50
+ await db.exec("CREATE TABLE w (k TEXT)");
51
+ const insert = await db.prepare("INSERT INTO w VALUES (?)");
52
+ const results = await Promise.all([insert.run('a'), insert.run('b')]);
53
+ expect(results.map(r => r.changes)).toEqual([1, 1]);
54
+ expect(await db.all("SELECT k FROM w ORDER BY k")).toEqual([{ k: 'a' }, { k: 'b' }]);
55
+ });
32
56
  test('busy timeout gives up on time when the write lock is never released', async () => {
33
57
  const path = `test-${(Math.random() * 10000) | 0}.db`;
34
58
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tursodatabase/database",
3
- "version": "0.8.3-pre.2",
3
+ "version": "0.8.4-pre.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tursodatabase/turso"
@@ -49,15 +49,15 @@
49
49
  ]
50
50
  },
51
51
  "dependencies": {
52
- "@tursodatabase/database-common": "^0.8.3-pre.2"
52
+ "@tursodatabase/database-common": "^0.8.4-pre.2"
53
53
  },
54
54
  "imports": {
55
55
  "#index": "./index.js"
56
56
  },
57
57
  "optionalDependencies": {
58
- "@tursodatabase/database-linux-x64-gnu": "0.8.3-pre.2",
59
- "@tursodatabase/database-win32-x64-msvc": "0.8.3-pre.2",
60
- "@tursodatabase/database-darwin-arm64": "0.8.3-pre.2",
61
- "@tursodatabase/database-linux-arm64-gnu": "0.8.3-pre.2"
58
+ "@tursodatabase/database-linux-x64-gnu": "0.8.4-pre.2",
59
+ "@tursodatabase/database-win32-x64-msvc": "0.8.4-pre.2",
60
+ "@tursodatabase/database-darwin-arm64": "0.8.4-pre.2",
61
+ "@tursodatabase/database-linux-arm64-gnu": "0.8.4-pre.2"
62
62
  }
63
63
  }