@cap-js/sqlite 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +3 -3
- package/lib/SQLiteService.js +26 -26
- package/lib/sql.js.js +3 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@
|
|
|
4
4
|
- The format is based on [Keep a Changelog](http://keepachangelog.com/).
|
|
5
5
|
- This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [2.2.1](https://github.com/cap-js/cds-dbs/compare/sqlite-v2.2.0...sqlite-v2.2.1) (2026-04-22)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
* sqlite generated key is named lastInsertRowid ([#1501](https://github.com/cap-js/cds-dbs/issues/1501)) ([a4d3437](https://github.com/cap-js/cds-dbs/commit/a4d34378297c8afdb13abb7e664165012c36eb8f))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Dependencies
|
|
16
|
+
|
|
17
|
+
* The following workspace dependencies were updated
|
|
18
|
+
* dependencies
|
|
19
|
+
* @cap-js/db-service bumped from ^2.9.0 to ^2.10.0
|
|
20
|
+
|
|
7
21
|
## [2.2.0](https://github.com/cap-js/cds-dbs/compare/sqlite-v2.1.3...sqlite-v2.2.0) (2026-03-09)
|
|
8
22
|
|
|
9
23
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ If you want to use SQLite for development, all you need to do is to install the
|
|
|
10
10
|
npm add @cap-js/sqlite -D
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Learn more about setup and usage in the [respective database guide](https://cap.cloud.sap/docs/guides/databases
|
|
13
|
+
Learn more about setup and usage in the [respective database guide](https://cap.cloud.sap/docs/guides/databases/sqlite).
|
|
14
14
|
|
|
15
15
|
## Support
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ This project is open to feature requests/suggestions, bug reports etc. via [GitH
|
|
|
18
18
|
|
|
19
19
|
## Contribution
|
|
20
20
|
|
|
21
|
-
Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md).
|
|
21
|
+
Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our [Contribution Guidelines](../CONTRIBUTING.md).
|
|
22
22
|
|
|
23
23
|
## Versioning
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ All notable changes are documented in [CHANGELOG.md](CHANGELOG.md).
|
|
|
27
27
|
|
|
28
28
|
## Code of Conduct
|
|
29
29
|
|
|
30
|
-
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](CODE_OF_CONDUCT.md) at all times.
|
|
30
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its [Code of Conduct](../CODE_OF_CONDUCT.md) at all times.
|
|
31
31
|
|
|
32
32
|
## Licensing
|
|
33
33
|
|
package/lib/SQLiteService.js
CHANGED
|
@@ -30,23 +30,28 @@ class SQLiteService extends SQLService {
|
|
|
30
30
|
return {
|
|
31
31
|
options: this.options.pool || {},
|
|
32
32
|
create: async tenant => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
try {
|
|
34
|
+
if (!sqlite) loadSQLite(this.options.driver || this.options.credentials?.driver)
|
|
35
|
+
const database = this.url4(tenant)
|
|
36
|
+
const dbc = new sqlite(database, this.options.client || {})
|
|
37
|
+
await dbc.ready
|
|
38
|
+
|
|
39
|
+
const deterministic = { deterministic: true }
|
|
40
|
+
dbc.function('session_context', key => dbc[$session][key])
|
|
41
|
+
dbc.function('regexp', deterministic, (re, x) => (RegExp(re).test(x) ? 1 : 0))
|
|
42
|
+
dbc.function('ISO', deterministic, d => d && new Date(d).toISOString())
|
|
43
|
+
dbc.function('year', deterministic, d => d === null ? null : toDate(d).getUTCFullYear())
|
|
44
|
+
dbc.function('month', deterministic, d => d === null ? null : toDate(d).getUTCMonth() + 1)
|
|
45
|
+
dbc.function('day', deterministic, d => d === null ? null : toDate(d).getUTCDate())
|
|
46
|
+
dbc.function('hour', deterministic, d => d === null ? null : toDate(d, true).getUTCHours())
|
|
47
|
+
dbc.function('minute', deterministic, d => d === null ? null : toDate(d, true).getUTCMinutes())
|
|
48
|
+
dbc.function('second', deterministic, d => d === null ? null : toDate(d, true).getUTCSeconds())
|
|
49
|
+
if (database !== ':memory:') dbc.pragma?.('journal_mode = WAL') || dbc.exec('PRAGMA journal_mode = WAL')
|
|
50
|
+
return dbc
|
|
51
|
+
} catch (err) {
|
|
52
|
+
Promise.reject(err)
|
|
53
|
+
await new Promise(() => { })
|
|
54
|
+
}
|
|
50
55
|
},
|
|
51
56
|
destroy: dbc => dbc.close(),
|
|
52
57
|
validate: dbc => dbc.open,
|
|
@@ -310,15 +315,10 @@ function loadSQLite(driver) {
|
|
|
310
315
|
return
|
|
311
316
|
}
|
|
312
317
|
|
|
313
|
-
try {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
sqlite = require(drivers.node)
|
|
318
|
-
} catch {
|
|
319
|
-
// When failing to load better-sqlite3 it fallsback to sql.js (wasm version of sqlite)
|
|
320
|
-
sqlite = require(drivers['sql.js'])
|
|
321
|
-
}
|
|
318
|
+
try { sqlite = require(drivers['better-sqlite3']) }
|
|
319
|
+
catch {
|
|
320
|
+
try { sqlite = require(drivers.node) }
|
|
321
|
+
catch { sqlite = require(drivers['sql.js']) }
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
package/lib/sql.js.js
CHANGED
|
@@ -26,7 +26,9 @@ class WasmSqlite {
|
|
|
26
26
|
try {
|
|
27
27
|
stmt.bind(params)
|
|
28
28
|
stmt.step()
|
|
29
|
-
|
|
29
|
+
const changes = stmt.db.getRowsModified(stmt)
|
|
30
|
+
const lastInsertRowid = stmt.db.exec('SELECT last_insert_rowid()')[0]?.values[0][0]
|
|
31
|
+
return { changes, lastInsertRowid }
|
|
30
32
|
} catch (err) {
|
|
31
33
|
if (err.message.indexOf('NOT NULL constraint failed:') === 0) {
|
|
32
34
|
err.code = 'SQLITE_CONSTRAINT_NOTNULL'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/sqlite",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "CDS database service for SQLite",
|
|
5
5
|
"homepage": "https://github.com/cap-js/cds-dbs/tree/main/sqlite#cds-database-service-for-sqlite",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"better-sqlite3": "^12.0.0",
|
|
30
|
-
"@cap-js/db-service": "^2.
|
|
30
|
+
"@cap-js/db-service": "^2.10.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@sap/cds": ">=9.8",
|