@cap-js/sqlite 1.5.0 → 1.5.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 +7 -0
- package/lib/SQLiteService.js +7 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
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.5.1](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.5.0...sqlite-v1.5.1) (2024-02-16)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
* **`sqlite`:** Retain Error object for unique constraint violation ([#446](https://github.com/cap-js/cds-dbs/issues/446)) ([d27ee79](https://github.com/cap-js/cds-dbs/commit/d27ee79b4c4eea8522bf5dd2a288638f54029567))
|
|
13
|
+
|
|
7
14
|
## [1.5.0](https://github.com/cap-js/cds-dbs/compare/sqlite-v1.4.0...sqlite-v1.5.0) (2024-02-02)
|
|
8
15
|
|
|
9
16
|
|
package/lib/SQLiteService.js
CHANGED
|
@@ -191,7 +191,8 @@ class SQLiteService extends SQLService {
|
|
|
191
191
|
|
|
192
192
|
// Structs and arrays are stored as JSON strings; the ->'$' unwraps them.
|
|
193
193
|
// Otherwise they would be added as strings to json_objects.
|
|
194
|
-
|
|
194
|
+
Association: expr => `${expr}->'$'`,
|
|
195
|
+
struct: expr => `${expr}->'$'`,
|
|
195
196
|
array: expr => `${expr}->'$'`,
|
|
196
197
|
|
|
197
198
|
// SQLite has no booleans so we need to convert 0 and 1
|
|
@@ -244,7 +245,7 @@ class SQLiteService extends SQLService {
|
|
|
244
245
|
try {
|
|
245
246
|
return await super.onINSERT(req)
|
|
246
247
|
} catch (err) {
|
|
247
|
-
throw _not_unique(err, 'ENTITY_ALREADY_EXISTS')
|
|
248
|
+
throw _not_unique(err, 'ENTITY_ALREADY_EXISTS')
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
251
|
|
|
@@ -252,13 +253,13 @@ class SQLiteService extends SQLService {
|
|
|
252
253
|
try {
|
|
253
254
|
return await super.onUPDATE(req)
|
|
254
255
|
} catch (err) {
|
|
255
|
-
throw _not_unique(err, 'UNIQUE_CONSTRAINT_VIOLATION')
|
|
256
|
+
throw _not_unique(err, 'UNIQUE_CONSTRAINT_VIOLATION')
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
260
|
|
|
260
261
|
// function _not_null (err) {
|
|
261
|
-
// if (err.code === "SQLITE_CONSTRAINT_NOTNULL") return Object.assign ({
|
|
262
|
+
// if (err.code === "SQLITE_CONSTRAINT_NOTNULL") return Object.assign (err, {
|
|
262
263
|
// code: 'MUST_NOT_BE_NULL',
|
|
263
264
|
// target: /\.(.*?)$/.exec(err.message)[1], // here we are even constructing OData responses, with .target
|
|
264
265
|
// message: 'Value is required',
|
|
@@ -267,11 +268,12 @@ class SQLiteService extends SQLService {
|
|
|
267
268
|
|
|
268
269
|
function _not_unique(err, code) {
|
|
269
270
|
if (err.message.match(/unique constraint/i))
|
|
270
|
-
return Object.assign({
|
|
271
|
+
return Object.assign(err, {
|
|
271
272
|
originalMessage: err.message, // FIXME: required because of next line
|
|
272
273
|
message: code, // FIXME: misusing message as code
|
|
273
274
|
code: 400, // FIXME: misusing code as (http) status
|
|
274
275
|
})
|
|
276
|
+
return err
|
|
275
277
|
}
|
|
276
278
|
|
|
277
279
|
module.exports = SQLiteService
|
package/package.json
CHANGED