@cap-js/sqlite 1.6.0 → 1.7.0
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 +13 -0
- package/lib/SQLiteService.js +7 -11
- package/package.json +2 -2
- /package/lib/{func.js → cql-functions.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@
|
|
|
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.7.0](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.6.0...sqlite-v1.7.0) (2024-05-08)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
* select decimals as strings if cds.env.features.string_decimals ([#616](https://github.com/cap-js/cds-dbs/issues/616)) ([39addbf](https://github.com/cap-js/cds-dbs/commit/39addbfe01da757d86a4d65e62eda86e59fc9b87))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
* Change `sql` property to `query` for errors ([#611](https://github.com/cap-js/cds-dbs/issues/611)) ([585577a](https://github.com/cap-js/cds-dbs/commit/585577a9817e7749fb71958c26c4bfa20981c663))
|
|
18
|
+
* Improved placeholders and limit clause ([#567](https://github.com/cap-js/cds-dbs/issues/567)) ([d5d5dbb](https://github.com/cap-js/cds-dbs/commit/d5d5dbb7219bcef6134440715cf756fdd439f076))
|
|
19
|
+
|
|
7
20
|
## [1.6.0](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.5.1...sqlite-v1.6.0) (2024-03-22)
|
|
8
21
|
|
|
9
22
|
|
package/lib/SQLiteService.js
CHANGED
|
@@ -80,7 +80,7 @@ class SQLiteService extends SQLService {
|
|
|
80
80
|
stream: (..._) => this._stream(stmt, ..._),
|
|
81
81
|
}
|
|
82
82
|
} catch (e) {
|
|
83
|
-
e.message += ' in:\n' + (e.
|
|
83
|
+
e.message += ' in:\n' + (e.query = sql)
|
|
84
84
|
throw e
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -167,7 +167,8 @@ class SQLiteService extends SQLService {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
val(v) {
|
|
170
|
-
if (
|
|
170
|
+
if (typeof v.val === 'boolean') v.val = v.val ? 1 : 0
|
|
171
|
+
else if (Buffer.isBuffer(v.val)) v.val = v.val.toString('base64')
|
|
171
172
|
// intercept DateTime values and convert to Date objects to compare ISO Strings
|
|
172
173
|
else if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d{1,9})?(Z|[+-]\d{2}(:?\d{2})?)$/.test(v.val)) {
|
|
173
174
|
const date = new Date(v.val)
|
|
@@ -189,12 +190,10 @@ class SQLiteService extends SQLService {
|
|
|
189
190
|
// Used for INSERT statements
|
|
190
191
|
static InputConverters = {
|
|
191
192
|
...super.InputConverters,
|
|
192
|
-
|
|
193
193
|
// The following allows passing in ISO strings with non-zulu
|
|
194
194
|
// timezones and converts them into zulu dates and times
|
|
195
195
|
Date: e => `strftime('%Y-%m-%d',${e})`,
|
|
196
196
|
Time: e => `strftime('%H:%M:%S',${e})`,
|
|
197
|
-
|
|
198
197
|
// Both, DateTimes and Timestamps are canonicalized to ISO strings with
|
|
199
198
|
// ms precision to allow safe comparisons, also to query {val}s in where clauses
|
|
200
199
|
DateTime: e => `ISO(${e})`,
|
|
@@ -203,34 +202,31 @@ class SQLiteService extends SQLService {
|
|
|
203
202
|
|
|
204
203
|
static OutputConverters = {
|
|
205
204
|
...super.OutputConverters,
|
|
206
|
-
|
|
207
205
|
// Structs and arrays are stored as JSON strings; the ->'$' unwraps them.
|
|
208
206
|
// Otherwise they would be added as strings to json_objects.
|
|
209
207
|
Association: expr => `${expr}->'$'`,
|
|
210
208
|
struct: expr => `${expr}->'$'`,
|
|
211
209
|
array: expr => `${expr}->'$'`,
|
|
212
|
-
|
|
213
210
|
// SQLite has no booleans so we need to convert 0 and 1
|
|
214
211
|
boolean: expr => `CASE ${expr} when 1 then 'true' when 0 then 'false' END ->'$'`,
|
|
215
|
-
|
|
216
212
|
// DateTimes are returned without ms added by InputConverters
|
|
217
213
|
DateTime: e => `substr(${e},0,20)||'Z'`,
|
|
218
|
-
|
|
219
214
|
// Timestamps are returned with ms, as written by InputConverters.
|
|
220
215
|
// And as cds.builtin.classes.Timestamp inherits from DateTime we need
|
|
221
216
|
// to override the DateTime converter above
|
|
222
217
|
Timestamp: undefined,
|
|
223
|
-
|
|
224
218
|
// int64 is stored as native int64 for best comparison
|
|
225
219
|
// Reading int64 as string to not loose precision
|
|
226
220
|
Int64: expr => `CAST(${expr} as TEXT)`,
|
|
227
|
-
|
|
221
|
+
// REVISIT: always cast to string in next major
|
|
222
|
+
// Reading decimal as string to not loose precision
|
|
223
|
+
Decimal: cds.env.features.string_decimals ? expr => `CAST(${expr} as TEXT)` : undefined,
|
|
228
224
|
// Binary is not allowed in json objects
|
|
229
225
|
Binary: expr => `${expr} || ''`,
|
|
230
226
|
}
|
|
231
227
|
|
|
232
228
|
// Used for SQL function expressions
|
|
233
|
-
static Functions = { ...super.Functions, ...require('./
|
|
229
|
+
static Functions = { ...super.Functions, ...require('./cql-functions') }
|
|
234
230
|
|
|
235
231
|
// Used for CREATE TABLE statements
|
|
236
232
|
static TypeMap = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/sqlite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"test": "jest --silent"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@cap-js/db-service": "^1.
|
|
33
|
+
"@cap-js/db-service": "^1.9.0",
|
|
34
34
|
"better-sqlite3": "^9.3.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
File without changes
|