E-SQL-006
.prepare() is removed in Bun.SQL.
Verified behaviour, 2026-07-26 against v0.7.1. This code does not reliably surface as a compile-time error. The compile-time diagnostic is raised only from the SQL-rewrite path that matches the backtick form ?{`…`}.prepare(); on the bare form the build exits 0 and the compiler instead emits a runtime throw carrying this message into the generated JavaScript. In the probe below the build succeeded and the error text was found in the emitted bundle. Treat .prepare() as a runtime failure you must catch by running the code, not by compiling it. Reported upstream.
What it means
Bun.SQL caches prepared statements internally, so an explicit .prepare() step has no purpose and was removed. Queries run as a bare ?{…} block or through .all() / .get() / .run().
Minimal reproducer
This is the exact source compiled against the linked compiler to establish the behaviour described above. Read the callout at the top of this page before using it — it does not produce E-SQL-006.
<program db="./app.db" title="p">
<schema>
users {
id: integer primary key
email: text not null
}
</>
<db src="./app.db" tables="users"/>
function load() {
return ?{`SELECT * FROM users`}.prepare()
}
<button onclick=load()>load</button>
</>
How to fix
-
Drop
.prepare(). Use the bare?{…}form, or the terminal method matching the shape you want —.all()for rows,.get()for one,.run()for a write. - Do not add caching of your own. Statement caching is the driver's job and already happening.
Related
Specification
Normative text: §44.3, §8.6, §34. Spec lives at compiler/SPEC.md .