@tursodatabase/database 0.4.0-pre.9 → 0.4.0

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.
@@ -1,6 +1,16 @@
1
1
  import { unlinkSync } from "node:fs";
2
2
  import { expect, test } from 'vitest';
3
3
  import { Database } from './compat.js';
4
+ test('insert returning test', () => {
5
+ const db = new Database(':memory:');
6
+ db.prepare(`create table t (x);`).run();
7
+ const x1 = db.prepare(`insert into t values (1), (2) returning x`).get();
8
+ const x2 = db.prepare(`insert into t values (3), (4) returning x`).get();
9
+ expect(x1).toEqual({ x: 1 });
10
+ expect(x2).toEqual({ x: 3 });
11
+ const all = db.prepare(`select * from t`).all();
12
+ expect(all).toEqual([{ x: 1 }, { x: 2 }, { x: 3 }, { x: 4 }]);
13
+ });
4
14
  test('in-memory db', () => {
5
15
  const db = new Database(":memory:");
6
16
  db.exec("CREATE TABLE t(x)");
@@ -99,6 +99,16 @@ test('avg-bug', async () => {
99
99
  expect(await db.prepare(`select avg("null_only") from "aggregate_table";`).get()).toEqual({ 'avg (aggregate_table.null_only)': null });
100
100
  expect(await db.prepare(`select avg(distinct "b") from "aggregate_table";`).get()).toEqual({ 'avg (DISTINCT aggregate_table.b)': 42.5 });
101
101
  });
102
+ test('insert returning test', async () => {
103
+ const db = await connect(':memory:');
104
+ await db.prepare(`create table t (x);`).run();
105
+ const x1 = await db.prepare(`insert into t values (1), (2) returning x`).get();
106
+ const x2 = await db.prepare(`insert into t values (3), (4) returning x`).get();
107
+ expect(x1).toEqual({ x: 1 });
108
+ expect(x2).toEqual({ x: 3 });
109
+ const all = await db.prepare(`select * from t`).all();
110
+ expect(all).toEqual([{ x: 1 }, { x: 2 }, { x: 3 }, { x: 4 }]);
111
+ });
102
112
  test('offset-bug', async () => {
103
113
  const db = await connect(":memory:");
104
114
  await db.exec(`CREATE TABLE users (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tursodatabase/database",
3
- "version": "0.4.0-pre.9",
3
+ "version": "0.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tursodatabase/turso"
@@ -47,15 +47,15 @@
47
47
  ]
48
48
  },
49
49
  "dependencies": {
50
- "@tursodatabase/database-common": "^0.4.0-pre.9"
50
+ "@tursodatabase/database-common": "^0.4.0"
51
51
  },
52
52
  "imports": {
53
53
  "#index": "./index.js"
54
54
  },
55
55
  "optionalDependencies": {
56
- "@tursodatabase/database-linux-x64-gnu": "0.4.0-pre.9",
57
- "@tursodatabase/database-win32-x64-msvc": "0.4.0-pre.9",
58
- "@tursodatabase/database-darwin-arm64": "0.4.0-pre.9",
59
- "@tursodatabase/database-linux-arm64-gnu": "0.4.0-pre.9"
56
+ "@tursodatabase/database-linux-x64-gnu": "0.4.0",
57
+ "@tursodatabase/database-win32-x64-msvc": "0.4.0",
58
+ "@tursodatabase/database-darwin-arm64": "0.4.0",
59
+ "@tursodatabase/database-linux-arm64-gnu": "0.4.0"
60
60
  }
61
61
  }