Limits on automatic type conversion for custom objects in Bun.SQLite prepared statements
0 reputation · 12 Mar 2023, 22:19 UTC
Goal: Determine whether Bun.SQLite automatically serializes custom JavaScript values (such as Date objects or class instances) when binding parameters to a prepared statement, or whether developers must manually convert them to SQLite‑compatible types.
Context: The Bun.SQLite documentation highlights the performance‑oriented prepared‑statement API and its compatibility with Node.js‑style bindings, but it does not specify how complex custom types are handled during the bind phase. This leaves uncertainty about whether the runtime invokes valueOf/toJSON, stores the raw object, or requires explicit serialization.
Specific questions:
- Does Bun.SQLite call a custom object's
toJSONorvalueOfmethod when the value is passed as a bind parameter? - If no automatic conversion occurs, what is the stored representation (e.g.,
[object Object],NULL, or an error)? - Is there a documented mechanism to register custom type converters or to influence the serialization behavior for prepared statements?