Skip to content

Commit 8626fd7

Browse files
committed
readme updates, add test for failing queries
1 parent 4869ea9 commit 8626fd7

4 files changed

Lines changed: 44 additions & 3 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# sqlite
22

3+
🚧 A Work in Progress. Do Not Use 🚧
4+
35
[![Build Status](https://travis-ci.com/sqlite-js/sqlite.svg?branch=master)](https://travis-ci.com/sqlite-js/sqlite)
46

57
An experimental SQLite library for Node using Neon
@@ -48,3 +50,11 @@ await Promise.all([
4850
const updateTables = await db.statement('UPDATE tbl SET name = ? WHERE email = ?');
4951
await updateTables('john', 'john@gmail.com');
5052
```
53+
54+
## Local Development
55+
```bash
56+
git clone https://github.com/sqlite-js/sqlite
57+
cd sqlite
58+
yarn
59+
yarn test
60+
```

native/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ declare_types! {
9191
.enumerate()
9292
.for_each(|(i, obj)| {
9393
let js_string = cx.string(obj);
94-
js_array.set(&mut cx, i as u32, js_string);
94+
js_array.set(&mut cx, i as u32, js_string).unwrap();
9595
});
9696

9797
Ok(js_array.upcast())
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`basic should execute query statements 1`] = `
4+
Array [
5+
"john",
6+
]
7+
`;
8+
9+
exports[`basic should format errors 1`] = `"internal error in Neon module: called \`Result::unwrap()\` on an \`Err\` value: SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some(\\"no such column: asdfasdf\\"))"`;

test/basic.spec.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,33 @@ describe('basic', () => {
2525
VALUES ("john");
2626
`);
2727

28-
conn.execute(`
28+
expect(
29+
await conn.execute(`
2930
SELECT *
3031
FROM contacts;
31-
`);
32+
`)
33+
).toMatchSnapshot();
3234

3335
conn.execute('DROP TABLE contacts;');
3436
});
37+
38+
it('should format errors', async () => {
39+
const conn = new Sqlite();
40+
41+
await conn.create({
42+
verbose: true,
43+
database: path.join(__dirname, 'test.db')
44+
});
45+
46+
conn.execute('DROP TABLE IF EXISTS contacts;');
47+
48+
conn.execute('CREATE TABLE contacts (t VARCHAR PRIMARY KEY);');
49+
50+
expect(() => {
51+
conn.execute(`
52+
INSERT INTO contacts (t)
53+
VALUES (asdfasdf);
54+
`);
55+
}).toThrowErrorMatchingSnapshot();
56+
});
3557
});

0 commit comments

Comments
 (0)