Consider using `node:sqlite`
Deno (and node.js) now have built in support for sqlite3 with the same module. The benefit of using this built in module is that real sqlite will be used whereas x/sqlite that is currently used has weaker consistency guarantees. This might also allow this gleam library to work on node.js.
Could be good!
Hello!
I’m currently developing a new JavaScript FFI for sqlight.
This FFI is compatible with the node:sqlite module for both Node.js and Deno, and all tests pass using the following commands.
gleam test --target javascript --runtime node
gleam test --target javascript --runtime deno
Since this FFI relies on the node:sqlite package for Node.js and Deno and introduces breaking changes, it only works with Node.js v22.5 or later and Deno v2.2 or later.
You can check out the code on this branch.
To use it, add the following configuration to your gleam.toml file:
[dependencies]
sqlight = { git = "https://github.com/Comamoca/sqlight", ref = "feature/node-sqlite" }
Very cool! Would you like to make a PR?
I had a quick look at the code and there's a fairly serious bug in the numbered parameters bit- it can edit the content of strings within the SQL! select '?hello?';
Thanks for pointing that out! I’ll fix the issue and open a PR over the weekend.
I investigated the FFI bug over the weekend, and reached the following conclusions.
Regarding the substitution process of ? which caused the bug, this has been fixed in Node.js's node:sqlite, so I have removed the corresponding processing. Therefore, the bug should be resolved.
https://github.com/Comamoca/sqlight/commit/8a04d3f6bf92df40a51f10619ccd84a1bd1bd32e
As a result, the tests are currently failing in Deno, but this is because Deno has not yet incorporated the latest node:sqlite.
I plan to create a PR once I confirm that Deno has incorporated the latest node:sqlite.
I will likely be able to submit the PR within the year.