Skip to content

Conversation

@BobdenOs
Copy link
Contributor

This PR adds support for another SQLite driver sql.js is a browser orientated driver which compiles SQLite to wasm.

Enabling the possibility to run cds with @cap-js/sqlite in more environments.

For example better-sqlite3 cannot be loaded into the default npm promoted online environment runkit:
https://runkit.com/bobdenos/cds-test

Error: Could not locate the bindings file. Tried:
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/build/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/build/Release/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/Debug/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/out/Release/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/Release/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/build/default/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/compiled/18.11.0/linux/x64/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
 → /app/available_modules/1713909839000/@cap-js/sqlite/node_modules/better-sqlite3/lib/binding/node-v108-linux-x64/better_sqlite3.node

There are some limitations with sql.js when comparing to better-sqlite3. Which is mostly that it uses more memory and is around 50% slower for running the @cap-js/sqlite tests. Where better-sqlite3 takes ~10 seconds to run all tests. It takes sql.js ~14 seconds, but all current tests are green. Which should be good enough for experimentation scenarios.

Copy link
Member

@patricebender patricebender left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool :) Should we run the tests with sql.js as optional tests as part of the PRs? Alternatively we could also run them after merge. What do you think?

@BobdenOs
Copy link
Contributor Author

Verification that the Test WASM job actually uses the fallback driver: log

const init = initSqlJs({})

class WasmSqlite {
constructor(database) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get rid of this warning?

@petermuessig
Copy link

@BobdenOs @danjoa @patricebender are there any further interests on your side to enable this feature for the @cap-js/sqlite package? This feature would be quite interesting - maybe even as a standalone @cap-js/sql.js package to allow to run CAP in a webcontainer. SQLite doesn't work here as it requires native bindings and with sql.js we could run it inside a webcontainer. Or do you have anything available here - if yes, I would be highly interested in this for the UI5 tutorials to run against a webcontainer based environment in the browser. THX!

@BobdenOs
Copy link
Contributor Author

@petermuessig the current state should be up-to-date again.

Currently the only blocker is that the sql.js compilation flags doesn't include the native math functions (test, PR).

@petermuessig
Copy link

@BobdenOs thanks for the information. As said in our chat, I'll verify the workaround you provided for me so far to check whether I can run UI5 applications against the CDS server running on sql.js in the web container. I will let you know whether all works fine... BIG THX again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants