@cap-js/sqlite 1.2.0 → 1.3.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 CHANGED
@@ -4,6 +4,18 @@
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
+ ## Version 1.3.0 - 2023-10-06
8
+
9
+ ### Fixed
10
+
11
+ - `CURRENT_TIMESTAMP` in view definition preserves the timezone. #254
12
+
13
+ ## Version 1.2.1 - 2023-09-08
14
+
15
+ ### Fixed
16
+
17
+ - Adapt implementation to comply with implication of SQLite version 3.43 which is included in `better-sqlite3@8.6.0`. #210
18
+
7
19
  ## Version 1.2.0 - 2023-09-06
8
20
 
9
21
  ### Changed
package/README.md CHANGED
@@ -2,5 +2,31 @@
2
2
 
3
3
  Welcome to the new SQLite database service for [SAP Cloud Application Programming Model](https://cap.cloud.sap) Node.js, based on new, streamlined database architecture and [*better-sqlite* driver](https://www.npmjs.com/package/better-sqlite3) .
4
4
 
5
- Find documentation at https://cap.cloud.sap/docs/guides/databases-sqlite.
5
+ ## Setup
6
6
 
7
+ In general, all you need to do is to install one of the database packages, as follows:
8
+
9
+ Using SQLite for development:
10
+
11
+ ```sh
12
+ npm add @cap-js/sqlite -D
13
+ ```
14
+
15
+ Learn more about setup and usage in the [respective database guide](https://cap.cloud.sap/docs/guides/databases-sqlite).
16
+
17
+
18
+ ## Support
19
+
20
+ This project is open to feature requests/suggestions, bug reports etc. via [GitHub issues](https://github.com/cap-js/cds-dbs/issues).
21
+
22
+ ## Contribution
23
+
24
+ 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).
25
+
26
+ ## Code of Conduct
27
+
28
+ 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.
29
+
30
+ ## Licensing
31
+
32
+ Copyright 2023 SAP SE or an SAP affiliate company and cds-dbs contributors. Please see our [LICENSE](LICENSE) for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available [via the REUSE tool](https://api.reuse.software/info/github.com/cap-js/cds-dbs).
@@ -15,6 +15,7 @@ class SQLiteService extends SQLService {
15
15
  dbc.function('session_context', key => dbc[$session][key])
16
16
  dbc.function('regexp', { deterministic: true }, (re, x) => (RegExp(re).test(x) ? 1 : 0))
17
17
  dbc.function('ISO', { deterministic: true }, d => d && new Date(d).toISOString())
18
+ dbc.function('json_merge', { varargs: true, deterministic: true }, (...args) => args.join('').replace(/}{/g, ','))
18
19
  if (!dbc.memory) dbc.pragma('journal_mode = WAL')
19
20
  return dbc
20
21
  },
@@ -123,6 +124,17 @@ class SQLiteService extends SQLService {
123
124
  return this.dbc.exec(sql)
124
125
  }
125
126
 
127
+ onPlainSQL({ query, data }, next) {
128
+ if (typeof query === 'string') {
129
+ // REVISIT: this is a hack the target of $now might not be a timestamp or date time
130
+ // Add input converter to CURRENT_TIMESTAMP inside views using $now
131
+ if (/^CREATE VIEW.* CURRENT_TIMESTAMP[( ]/is.test(query)) {
132
+ query = query.replace(/CURRENT_TIMESTAMP/gi, "STRFTIME('%Y-%m-%dT%H:%M:%fZ','NOW')")
133
+ }
134
+ }
135
+ return super.onPlainSQL({ query, data }, next)
136
+ }
137
+
126
138
  static CQN2SQL = class CQN2SQLite extends SQLService.CQN2SQL {
127
139
 
128
140
  column_alias4(x, q) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/sqlite",
3
- "version": "1.2.0",
3
+ "version": "1.3.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.2.0",
33
+ "@cap-js/db-service": "^1.3.0",
34
34
  "better-sqlite3": "^8"
35
35
  },
36
36
  "peerDependencies": {