nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
106.51k stars 29.02k forks source link

Provide information about sqlite version in node:sqlite #54135

Open flapenguin opened 1 month ago

flapenguin commented 1 month ago

What is the problem this feature will solve?

SQLite is constantly improving. Each version adds something new https://www.sqlite.org/chronology.html Currently it is not clear what version of sqlite baseline you can safely use.

E.g. last version 3.46.0 added json_pretty function. Imagine that node:sqlite was added couple of years ago, libraries won't be able to tell if they can use it or even any json_* function.

What is the feature you are proposing to solve the problem?

  1. Add require('node:sqlite').version field, so libraries can check version if needed process.versions.sqlite can be used as suggested in the comments https://github.com/nodejs/node/issues/54135#issuecomment-2260125892
  2. Specify sqlite version in documentation with a direct link to sqlite release page
  3. Specify in documentation that sqlite version won't decrease in any future release (i.e. node:sqlite is backward compatible)

What alternatives have you considered?

You can get version in runtime

❯ node --experimental-sqlite
Welcome to Node.js v22.5.1.
> new (require('node:sqlite').DatabaseSync)(':memory:').prepare('select sqlite_version()').get()
{ 'sqlite_version()': '3.46.0' }

You can do feature testing for specific functions in runtime

❯ node --experimental-sqlite
Welcome to Node.js v22.5.1.
> > new (require('node:sqlite').DatabaseSync)(':memory:').prepare('select * from pragma_function_list where name="json_pretty"').get()
{
  name: 'json_pretty',
  builtin: 1,
  type: 's',
  enc: 'utf8',
  narg: 1,
  flags: 2099200
}

But libraries should have some better api for this IMO

merceyz commented 1 month ago

Note that you can get the version from process.versions.sqlite https://nodejs.org/docs/latest/api/process.html#processversions.

flapenguin commented 1 month ago

Note that you can get the version from process.versions.sqlite https://nodejs.org/docs/latest/api/process.html#processversions.

Awesome. I think that concludes part of the issue about getting version in runtime.

cjihrig commented 1 month ago

Specify in documentation that sqlite version won't decrease in any future release

I'm not sure that we should explicitly say that in the docs since we don't say it for any of our other dependencies. In general we only update versions, but if we had a reason (security for example) we should be able to move backward if needed. We also have multiple release lines, which could confuse people if they see an older version on an LTS line.

Specify sqlite version in documentation with a direct link to sqlite release page

I'm not sure that we should do this either. For example, V8 is a much more important dependency for Node.js, and we don't specify the version of V8 in the docs as far as I know.