|
8 | 8 | * AUTO-GENERATED - Do not edit. Run 'npm run sync:tests' to regenerate. |
9 | 9 | */ |
10 | 10 |
|
11 | | -"use strict"; |
12 | | -const assert = require("node:assert"); |
| 11 | +'use strict'; |
| 12 | +const assert = require('node:assert'); |
13 | 13 | const { DatabaseSync } = require("@photostructure/sqlite"); |
14 | | -const { suite, test } = require("node:test"); |
| 14 | +const { suite, test } = require('node:test'); |
15 | 15 |
|
16 | | -suite("StatementSync.prototype.columns()", () => { |
17 | | - test("returns column metadata for core SQLite types", () => { |
18 | | - const db = new DatabaseSync(":memory:"); |
| 16 | +suite('StatementSync.prototype.columns()', () => { |
| 17 | + test('returns column metadata for core SQLite types', () => { |
| 18 | + const db = new DatabaseSync(':memory:'); |
19 | 19 | db.exec(`CREATE TABLE test ( |
20 | 20 | col1 INTEGER, |
21 | 21 | col2 REAL, |
22 | 22 | col3 TEXT, |
23 | 23 | col4 BLOB, |
24 | 24 | col5 NULL |
25 | 25 | )`); |
26 | | - const stmt = db.prepare("SELECT col1, col2, col3, col4, col5 FROM test"); |
| 26 | + const stmt = db.prepare('SELECT col1, col2, col3, col4, col5 FROM test'); |
27 | 27 | assert.deepStrictEqual(stmt.columns(), [ |
28 | 28 | { |
29 | 29 | __proto__: null, |
30 | | - column: "col1", |
31 | | - database: "main", |
32 | | - name: "col1", |
33 | | - table: "test", |
34 | | - type: "INTEGER", |
| 30 | + column: 'col1', |
| 31 | + database: 'main', |
| 32 | + name: 'col1', |
| 33 | + table: 'test', |
| 34 | + type: 'INTEGER', |
35 | 35 | }, |
36 | 36 | { |
37 | 37 | __proto__: null, |
38 | | - column: "col2", |
39 | | - database: "main", |
40 | | - name: "col2", |
41 | | - table: "test", |
42 | | - type: "REAL", |
| 38 | + column: 'col2', |
| 39 | + database: 'main', |
| 40 | + name: 'col2', |
| 41 | + table: 'test', |
| 42 | + type: 'REAL', |
43 | 43 | }, |
44 | 44 | { |
45 | 45 | __proto__: null, |
46 | | - column: "col3", |
47 | | - database: "main", |
48 | | - name: "col3", |
49 | | - table: "test", |
50 | | - type: "TEXT", |
| 46 | + column: 'col3', |
| 47 | + database: 'main', |
| 48 | + name: 'col3', |
| 49 | + table: 'test', |
| 50 | + type: 'TEXT', |
51 | 51 | }, |
52 | 52 | { |
53 | 53 | __proto__: null, |
54 | | - column: "col4", |
55 | | - database: "main", |
56 | | - name: "col4", |
57 | | - table: "test", |
58 | | - type: "BLOB", |
| 54 | + column: 'col4', |
| 55 | + database: 'main', |
| 56 | + name: 'col4', |
| 57 | + table: 'test', |
| 58 | + type: 'BLOB', |
59 | 59 | }, |
60 | 60 | { |
61 | 61 | __proto__: null, |
62 | | - column: "col5", |
63 | | - database: "main", |
64 | | - name: "col5", |
65 | | - table: "test", |
| 62 | + column: 'col5', |
| 63 | + database: 'main', |
| 64 | + name: 'col5', |
| 65 | + table: 'test', |
66 | 66 | type: null, |
67 | 67 | }, |
68 | 68 | ]); |
69 | 69 | }); |
70 | 70 |
|
71 | | - test("supports statements using multiple tables", () => { |
72 | | - const db = new DatabaseSync(":memory:"); |
| 71 | + test('supports statements using multiple tables', () => { |
| 72 | + const db = new DatabaseSync(':memory:'); |
73 | 73 | db.exec(` |
74 | 74 | CREATE TABLE test1 (value1 INTEGER); |
75 | 75 | CREATE TABLE test2 (value2 INTEGER); |
76 | 76 | `); |
77 | | - const stmt = db.prepare("SELECT value1, value2 FROM test1, test2"); |
| 77 | + const stmt = db.prepare('SELECT value1, value2 FROM test1, test2'); |
78 | 78 | assert.deepStrictEqual(stmt.columns(), [ |
79 | 79 | { |
80 | 80 | __proto__: null, |
81 | | - column: "value1", |
82 | | - database: "main", |
83 | | - name: "value1", |
84 | | - table: "test1", |
85 | | - type: "INTEGER", |
| 81 | + column: 'value1', |
| 82 | + database: 'main', |
| 83 | + name: 'value1', |
| 84 | + table: 'test1', |
| 85 | + type: 'INTEGER', |
86 | 86 | }, |
87 | 87 | { |
88 | 88 | __proto__: null, |
89 | | - column: "value2", |
90 | | - database: "main", |
91 | | - name: "value2", |
92 | | - table: "test2", |
93 | | - type: "INTEGER", |
| 89 | + column: 'value2', |
| 90 | + database: 'main', |
| 91 | + name: 'value2', |
| 92 | + table: 'test2', |
| 93 | + type: 'INTEGER', |
94 | 94 | }, |
95 | 95 | ]); |
96 | 96 | }); |
97 | 97 |
|
98 | | - test("supports column aliases", () => { |
99 | | - const db = new DatabaseSync(":memory:"); |
| 98 | + test('supports column aliases', () => { |
| 99 | + const db = new DatabaseSync(':memory:'); |
100 | 100 | db.exec(`CREATE TABLE test (value INTEGER)`); |
101 | | - const stmt = db.prepare("SELECT value AS foo FROM test"); |
| 101 | + const stmt = db.prepare('SELECT value AS foo FROM test'); |
102 | 102 | assert.deepStrictEqual(stmt.columns(), [ |
103 | 103 | { |
104 | 104 | __proto__: null, |
105 | | - column: "value", |
106 | | - database: "main", |
107 | | - name: "foo", |
108 | | - table: "test", |
109 | | - type: "INTEGER", |
| 105 | + column: 'value', |
| 106 | + database: 'main', |
| 107 | + name: 'foo', |
| 108 | + table: 'test', |
| 109 | + type: 'INTEGER', |
110 | 110 | }, |
111 | 111 | ]); |
112 | 112 | }); |
113 | 113 |
|
114 | | - test("supports column expressions", () => { |
115 | | - const db = new DatabaseSync(":memory:"); |
| 114 | + test('supports column expressions', () => { |
| 115 | + const db = new DatabaseSync(':memory:'); |
116 | 116 | db.exec(`CREATE TABLE test (value INTEGER)`); |
117 | | - const stmt = db.prepare("SELECT value + 1, value FROM test"); |
| 117 | + const stmt = db.prepare('SELECT value + 1, value FROM test'); |
118 | 118 | assert.deepStrictEqual(stmt.columns(), [ |
119 | 119 | { |
120 | 120 | __proto__: null, |
121 | 121 | column: null, |
122 | 122 | database: null, |
123 | | - name: "value + 1", |
| 123 | + name: 'value + 1', |
124 | 124 | table: null, |
125 | 125 | type: null, |
126 | 126 | }, |
127 | 127 | { |
128 | 128 | __proto__: null, |
129 | | - column: "value", |
130 | | - database: "main", |
131 | | - name: "value", |
132 | | - table: "test", |
133 | | - type: "INTEGER", |
| 129 | + column: 'value', |
| 130 | + database: 'main', |
| 131 | + name: 'value', |
| 132 | + table: 'test', |
| 133 | + type: 'INTEGER', |
134 | 134 | }, |
135 | 135 | ]); |
136 | 136 | }); |
137 | 137 |
|
138 | | - test("supports subqueries", () => { |
139 | | - const db = new DatabaseSync(":memory:"); |
| 138 | + test('supports subqueries', () => { |
| 139 | + const db = new DatabaseSync(':memory:'); |
140 | 140 | db.exec(`CREATE TABLE test (value INTEGER)`); |
141 | | - const stmt = db.prepare("SELECT * FROM (SELECT * FROM test)"); |
| 141 | + const stmt = db.prepare('SELECT * FROM (SELECT * FROM test)'); |
142 | 142 | assert.deepStrictEqual(stmt.columns(), [ |
143 | 143 | { |
144 | 144 | __proto__: null, |
145 | | - column: "value", |
146 | | - database: "main", |
147 | | - name: "value", |
148 | | - table: "test", |
149 | | - type: "INTEGER", |
| 145 | + column: 'value', |
| 146 | + database: 'main', |
| 147 | + name: 'value', |
| 148 | + table: 'test', |
| 149 | + type: 'INTEGER', |
150 | 150 | }, |
151 | 151 | ]); |
152 | 152 | }); |
153 | 153 |
|
154 | | - test("supports statements that do not return data", () => { |
155 | | - const db = new DatabaseSync(":memory:"); |
156 | | - db.exec("CREATE TABLE test (value INTEGER)"); |
157 | | - const stmt = db.prepare("INSERT INTO test (value) VALUES (?)"); |
| 154 | + test('supports statements that do not return data', () => { |
| 155 | + const db = new DatabaseSync(':memory:'); |
| 156 | + db.exec('CREATE TABLE test (value INTEGER)'); |
| 157 | + const stmt = db.prepare('INSERT INTO test (value) VALUES (?)'); |
158 | 158 | assert.deepStrictEqual(stmt.columns(), []); |
159 | 159 | }); |
160 | 160 |
|
161 | | - test("throws if the statement is finalized", () => { |
162 | | - const db = new DatabaseSync(":memory:"); |
163 | | - db.exec("CREATE TABLE test (value INTEGER)"); |
164 | | - const stmt = db.prepare("SELECT value FROM test"); |
| 161 | + test('throws if the statement is finalized', () => { |
| 162 | + const db = new DatabaseSync(':memory:'); |
| 163 | + db.exec('CREATE TABLE test (value INTEGER)'); |
| 164 | + const stmt = db.prepare('SELECT value FROM test'); |
165 | 165 | db.close(); |
166 | 166 | assert.throws(() => { |
167 | 167 | stmt.columns(); |
|
0 commit comments