| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 754271a commit cb8bc34
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2946,7 +2946,7 @@ BaseObjectPtr<StatementSync> SQLTagStore::PrepareStatement( | |||
| 2946 | 2946 | session->database_->connection_, sql.data(), sql.size(), &s, 0); | |
| 2947 | 2947 | ||
| 2948 | 2948 | if (r != SQLITE_OK) { | |
| 2949 | - THROW_ERR_SQLITE_ERROR(isolate, "Failed to prepare statement"); | ||
| 2949 | + THROW_ERR_SQLITE_ERROR(isolate, session->database_.get()); | ||
| 2950 | 2950 | sqlite3_finalize(s); | |
| 2951 | 2951 | return BaseObjectPtr<StatementSync>(); | |
| 2952 | 2952 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -102,3 +102,25 @@ test('TagStore capacity, size, and clear', () => { | |||
| 102 | 102 | test('sql.db returns the associated DatabaseSync instance', () => { | |
| 103 | 103 | assert.strictEqual(sql.db, db); | |
| 104 | 104 | }); | |
| 105 | + | ||
| 106 | + test('sql error messages are descriptive', () => { | ||
| 107 | + assert.strictEqual(sql.run`INSERT INTO foo (text) VALUES (${'test'})`.changes, 1); | ||
| 108 | + | ||
| 109 | + // Test with non-existent column | ||
| 110 | + assert.throws(() => { | ||
| 111 | + const result = sql.get`SELECT nonexistent_column FROM foo`; | ||
| 112 | + assert.fail(`Expected error, got: ${JSON.stringify(result)}`); | ||
| 113 | + }, { | ||
| 114 | + code: 'ERR_SQLITE_ERROR', | ||
| 115 | + message: /no such column/i, | ||
| 116 | + }); | ||
| 117 | + | ||
| 118 | + // Test with non-existent table | ||
| 119 | + assert.throws(() => { | ||
| 120 | + const result = sql.get`SELECT * FROM nonexistent_table`; | ||
| 121 | + assert.fail(`Expected error, got: ${JSON.stringify(result)}`); | ||
| 122 | + }, { | ||
| 123 | + code: 'ERR_SQLITE_ERROR', | ||
| 124 | + message: /no such table/i, | ||
| 125 | + }); | ||
| 126 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments