Open djsavvy opened 6 months ago
I'm also facing this issue right now. I was following the guide:
const db = new Database('apps.sqlite')
const query = db.query(`create table foo;`)
I get the error:
6 | const query = db.query(`create table foo;`)
^
SQLiteError: near ";": syntax error
errno: 1
at prepare (bun:sqlite:249:19)
at query (bun:sqlite:256:15)
at /home/alabhya/Desktop/quickstart/index.ts:6:15
I can't figure out what I'm doing wrong based on the error message.
We store the byteOffset
in the SQLiteError
object, so all we need to do is add some more text
What is the problem this feature would solve?
Currently, if a query string has a syntax error, it's quite hard to tell what the syntax error actually is.
Consider the following repro script:
(The error is the extra comma at the end).
This is the output of
bun sqlite_error_repro.tsx
:Seems harmless enough, but I ran into this error with a much longer, multi-line query, and I had no idea where the syntax error was. In fact, since it was my first time using Bun with sqlite (or at all), I didn't even know where to look. I assumed it was a typescript syntax error and spent a while trying random things.
In contrast, consider what
sqlite3
prints when presented with the same line:What is the feature you are proposing to solve the problem?
More detailed error messages for syntax errors. I see that there is prior art for this w.r.t. runtime errors (#871, closed by #7906). Having the same feature ported over to sqlite syntax errors would be a big QoL improvement.
What alternatives have you considered?
No response