diff --git a/example/src/tests/blob.spec.ts b/example/src/tests/blob.spec.ts index aa3b2b59..7002130a 100644 --- a/example/src/tests/blob.spec.ts +++ b/example/src/tests/blob.spec.ts @@ -48,7 +48,7 @@ export function blobTests() { const result = await db.execute('SELECT content FROM BlobTable'); - const finalUint8 = new Uint8Array(result.rows?.[0].content); + const finalUint8 = new Uint8Array(result.rows[0]!.content as any); expect(finalUint8[0]).to.equal(42); }); @@ -63,7 +63,7 @@ export function blobTests() { const result = await db.execute('SELECT content FROM BlobTable'); - const finalUint8 = new Uint8Array(result.rows?.[0].content); + const finalUint8 = new Uint8Array(result.rows[0]!.content as any); expect(finalUint8[0]).to.equal(42); }); @@ -78,7 +78,7 @@ export function blobTests() { const result = await db.execute('SELECT content FROM BlobTable'); - const finalUint8 = new Uint8Array(result.rows?.[0].content); + const finalUint8 = new Uint8Array(result.rows[0]!.content as any); expect(finalUint8[0]).to.equal(42); }); @@ -95,7 +95,7 @@ export function blobTests() { const result = await db.execute('SELECT content FROM BlobTable'); - const finalUint8 = new Uint8Array(result.rows?.[0].content); + const finalUint8 = new Uint8Array(result.rows[0]!.content as any); expect(finalUint8[0]).to.equal(46); }); @@ -112,7 +112,7 @@ export function blobTests() { const result = await db.execute('SELECT content FROM BlobTable'); - const finalUint8 = new Uint8Array(result.rows?.[0].content); + const finalUint8 = new Uint8Array(result.rows[0]!.content as any); expect(finalUint8[0]).to.equal(52); }); }); diff --git a/example/src/tests/dbsetup.spec.ts b/example/src/tests/dbsetup.spec.ts index 1b4f8ead..dbbc7ac1 100644 --- a/example/src/tests/dbsetup.spec.ts +++ b/example/src/tests/dbsetup.spec.ts @@ -45,7 +45,7 @@ export function dbSetupTests() { const res = await db.execute('select sqlite_version();'); - expect(res.rows?.[0]['sqlite_version()']).to.equal(expectedVersion); + expect(res.rows[0]!['sqlite_version()']).to.equal(expectedVersion); db.close(); }); diff --git a/example/src/tests/preparedStatements.spec.ts b/example/src/tests/preparedStatements.spec.ts index 7b3dfcb6..f97e23ab 100644 --- a/example/src/tests/preparedStatements.spec.ts +++ b/example/src/tests/preparedStatements.spec.ts @@ -57,7 +57,7 @@ export function preparedStatementsTests() { expect(results.rows?.length).to.equal(3); results = await statement.execute(); - expect(results.rows?.length).to.equal(3); + expect(results.rows.length).to.equal(3); }); it('prepared statement, rebind select', async () => { @@ -65,11 +65,11 @@ export function preparedStatementsTests() { statement.bind([1]); let results = await statement.execute(); - expect(results.rows?.[0].name === 'Oscar'); + expect(results.rows[0]!.name === 'Oscar'); statement.bind([2]); results = await statement.execute(); - expect(results.rows?.[0].name === 'Pablo'); + expect(results.rows[0]!.name === 'Pablo'); }); it('prepared statement, rebind insert', async () => { diff --git a/example/src/tests/queries.spec.ts b/example/src/tests/queries.spec.ts index 55ab6d2c..e27660e2 100644 --- a/example/src/tests/queries.spec.ts +++ b/example/src/tests/queries.spec.ts @@ -204,7 +204,7 @@ export function queriesTests() { const sumRes = await db.execute('SELECT SUM(age) as sum FROM User;'); // expect(sumRes.metadata?.[0]?.type).to.equal('UNKNOWN'); - expect(sumRes.rows?.[0].sum).to.equal(age + age2); + expect(sumRes.rows[0]!.sum).to.equal(age + age2); // MAX(networth), MIN(networth) const maxRes = await db.execute( @@ -218,8 +218,8 @@ export function queriesTests() { const maxNetworth = Math.max(networth, networth2); const minNetworth = Math.min(networth, networth2); - expect(maxRes.rows?.[0].max).to.equal(maxNetworth); - expect(minRes.rows?.[0].min).to.equal(minNetworth); + expect(maxRes.rows[0]!.max).to.equal(maxNetworth); + expect(minRes.rows[0]!.min).to.equal(minNetworth); }); it('Executes all the statements in a single string', async () => { @@ -235,13 +235,13 @@ export function queriesTests() { "SELECT name FROM sqlite_master WHERE type='table' AND name='T1';", ); - expect(t1name.rows?.[0].name).to.equal('T1'); + expect(t1name.rows[0]!.name).to.equal('T1'); let t2name = await db.execute( "SELECT name FROM sqlite_master WHERE type='table' AND name='T2';", ); - expect(t2name.rows?.[0].name).to.equal('T2'); + expect(t2name.rows[0]!.name).to.equal('T2'); }); it('Failed insert', async () => { @@ -360,7 +360,7 @@ export function queriesTests() { [id], ); - actual.push(results.rows?.[0].networth); + actual.push(results.rows[0]!.networth); }); promises.push(promised); @@ -583,9 +583,9 @@ export function queriesTests() { }, ]); - res.rows![0].name = 'quack_changed'; + res.rows[0]!.name = 'quack_changed'; - expect(res.rows![0].name).to.eq('quack_changed'); + expect(res.rows[0]!.name).to.eq('quack_changed'); }); it('DumbHostObject allows to write new props', async () => { @@ -612,9 +612,9 @@ export function queriesTests() { }, ]); - res.rows![0].myWeirdProp = 'quack_changed'; + res.rows[0]!.myWeirdProp = 'quack_changed'; - expect(res.rows![0].myWeirdProp).to.eq('quack_changed'); + expect(res.rows[0]!.myWeirdProp).to.eq('quack_changed'); }); it('Execute raw should return just an array of objects', async () => { diff --git a/example/src/tests/reactive.spec.ts b/example/src/tests/reactive.spec.ts index 75249775..31c86f13 100644 --- a/example/src/tests/reactive.spec.ts +++ b/example/src/tests/reactive.spec.ts @@ -51,7 +51,7 @@ export function reactiveTests() { table: 'User', }, ], - callback: data => { + callback: _data => { fullSelectRan = true; }, }); diff --git a/src/index.ts b/src/index.ts index 48e7ab0a..01963067 100644 --- a/src/index.ts +++ b/src/index.ts @@ -59,7 +59,7 @@ export type QueryResult = { insertId?: number; rowsAffected: number; res?: any[]; - rows: any[]; + rows: Array>; // An array of intermediate results, just values without column names rawRows?: any[]; columnNames?: string[];