@cap-js/sqlite 1.10.0 → 1.11.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 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
+ ## [1.11.1](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.11.0...sqlite-v1.11.1) (2025-05-28)
8
+
9
+
10
+ ### Fixed
11
+
12
+ * close dependency ranges to cds^8 ([#1214](https://github.com/cap-js/cds-dbs/issues/1214)) ([a4156e8](https://github.com/cap-js/cds-dbs/commit/a4156e8db4bba8688457fe635d76aa0f1ac38d1e))
13
+
14
+ ## [1.11.0](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.10.0...sqlite-v1.11.0) (2025-04-17)
15
+
16
+
17
+ ### Added
18
+
19
+ * Result set streaming ([#702](https://github.com/cap-js/cds-dbs/issues/702)) ([2fe02ea](https://github.com/cap-js/cds-dbs/commit/2fe02eafd02993e5697efbdab90ad997fb2c9e00))
20
+
7
21
  ## [1.10.0](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.9.0...sqlite-v1.10.0) (2025-03-31)
8
22
 
9
23
 
@@ -74,7 +74,7 @@ class SQLiteService extends SQLService {
74
74
  run: (..._) => this._run(stmt, ..._),
75
75
  get: (..._) => stmt.get(..._),
76
76
  all: (..._) => stmt.all(..._),
77
- stream: (..._) => this._stream(stmt, ..._),
77
+ stream: (..._) => this._allStream(stmt, ..._),
78
78
  }
79
79
  } catch (e) {
80
80
  e.message += ' in:\n' + (e.query = sql)
@@ -95,7 +95,8 @@ class SQLiteService extends SQLService {
95
95
  return stmt.run(binding_params)
96
96
  }
97
97
 
98
- async *_iterator(rs, one) {
98
+ async *_iteratorRaw(rs, one) {
99
+ const pageSize = (1 << 16)
99
100
  // Allow for both array and iterator result sets
100
101
  const first = Array.isArray(rs) ? { done: !rs[0], value: rs[0] } : rs.next()
101
102
  if (first.done) return
@@ -106,21 +107,44 @@ class SQLiteService extends SQLService {
106
107
  return
107
108
  }
108
109
 
109
- yield '['
110
+ let buffer = '[' + first.value[0]
110
111
  // Print first value as stand alone to prevent comma check inside the loop
111
- yield first.value[0]
112
112
  for (const row of rs) {
113
- yield `,${row[0]}`
113
+ buffer += `,${row[0]}`
114
+ if (buffer.length > pageSize) {
115
+ yield buffer
116
+ buffer = ''
117
+ }
114
118
  }
115
- yield ']'
119
+ buffer += ']'
120
+ yield buffer
121
+ }
122
+
123
+ async *_iteratorObjectMode(rs) {
124
+ for (const row of rs) {
125
+ yield JSON.parse(row[0])
126
+ }
127
+ }
128
+
129
+ async _allStream(stmt, binding_params, one, objectMode) {
130
+ stmt = stmt.constructor.name === 'Statement' ? stmt : stmt.__proto__
131
+ stmt.raw(true)
132
+ const get = stmt.get(binding_params)
133
+ if (!get) return []
134
+ const rs = stmt.iterate(binding_params)
135
+ const stream = Readable.from(objectMode ? this._iteratorObjectMode(rs) : this._iteratorRaw(rs, one), { objectMode })
136
+ const close = () => rs.return() // finish result set when closed early
137
+ stream.on('error', close)
138
+ stream.on('close', close)
139
+ return stream
116
140
  }
117
141
 
118
- pragma (pragma, options) {
119
- if (!this.dbc) return this.begin('pragma') .then (tx => {
120
- try { return tx.pragma (pragma, options) }
142
+ pragma(pragma, options) {
143
+ if (!this.dbc) return this.begin('pragma').then(tx => {
144
+ try { return tx.pragma(pragma, options) }
121
145
  finally { tx.release() }
122
146
  })
123
- return this.dbc.pragma (pragma, options)
147
+ return this.dbc.pragma(pragma, options)
124
148
  }
125
149
 
126
150
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@cap-js/sqlite",
3
- "version": "1.10.0",
3
+ "version": "1.11.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": {
7
7
  "type": "git",
8
- "url": "https://github.com/cap-js/cds-dbs"
8
+ "url": "git+https://github.com/cap-js/cds-dbs.git"
9
9
  },
10
10
  "bugs": {
11
11
  "url": "https://github.com/cap-js/cds-dbs/issues"
@@ -26,11 +26,11 @@
26
26
  "test": "cds-test"
27
27
  },
28
28
  "dependencies": {
29
- "@cap-js/db-service": "^1.19.0",
29
+ "@cap-js/db-service": "^1.20.0",
30
30
  "better-sqlite3": "^11.0.0"
31
31
  },
32
32
  "peerDependencies": {
33
- "@sap/cds": ">=7.6"
33
+ "@sap/cds": ">=7.6 <9"
34
34
  },
35
35
  "cds": {
36
36
  "requires": {