@cap-js/postgres 1.12.0 → 1.13.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 +14 -0
- package/cds-plugin.js +17 -5
- package/lib/PostgresService.js +14 -11
- 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
|
+
## [1.13.0](https://github.com/cap-js/cds-dbs/compare/postgres-v1.12.0...postgres-v1.13.0) (2025-03-31)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
* **collate:** only collate if locale is provided ([#1060](https://github.com/cap-js/cds-dbs/issues/1060)) ([dedd768](https://github.com/cap-js/cds-dbs/commit/dedd768c085aa29be0e38db11f11678ff55d5b7b))
|
|
13
|
+
* **forUpdate:** ignore locked ([#1074](https://github.com/cap-js/cds-dbs/issues/1074)) ([163480b](https://github.com/cap-js/cds-dbs/commit/163480b245b18a2829cd871c2f053c82bcc1abef))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
* consider `nulls first | last` on `orderBy` ([#1064](https://github.com/cap-js/cds-dbs/issues/1064)) ([c6bed60](https://github.com/cap-js/cds-dbs/commit/c6bed60f0d93b9f4a73c976727f30172707c60d9)), closes [#1062](https://github.com/cap-js/cds-dbs/issues/1062)
|
|
19
|
+
* Persist assert_integrity feature ([#1032](https://github.com/cap-js/cds-dbs/issues/1032)) ([2956279](https://github.com/cap-js/cds-dbs/commit/2956279777ac94330c98373d8bca32cf0f8e967e))
|
|
20
|
+
|
|
7
21
|
## [1.12.0](https://github.com/cap-js/cds-dbs/compare/postgres-v1.11.1...postgres-v1.12.0) (2025-03-04)
|
|
8
22
|
|
|
9
23
|
|
package/cds-plugin.js
CHANGED
|
@@ -25,11 +25,23 @@ cds.build?.register?.('postgres', class PostgresBuildPlugin extends cds.build.Pl
|
|
|
25
25
|
if (fs.existsSync(path.join(this.task.src, 'package.json'))) {
|
|
26
26
|
promises.push(this.copy(path.join(this.task.src, 'package.json')).to('package.json'))
|
|
27
27
|
} else {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
28
|
+
const packageJson = {
|
|
29
|
+
dependencies: {
|
|
30
|
+
'@sap/cds': '^8',
|
|
31
|
+
'@cap-js/postgres': '^1'
|
|
32
|
+
},
|
|
33
|
+
scripts: {
|
|
34
|
+
start: 'cds-deploy'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const assertIntegrity = cds.env?.features?.assert_integrity
|
|
38
|
+
if (assertIntegrity) {
|
|
39
|
+
packageJson.cds ??= {}
|
|
40
|
+
packageJson.cds.features ??= {}
|
|
41
|
+
packageJson.cds.features.assert_integrity = assertIntegrity
|
|
42
|
+
}
|
|
43
|
+
promises.push(
|
|
44
|
+
this.write(packageJson).to('package.json')
|
|
33
45
|
)
|
|
34
46
|
}
|
|
35
47
|
promises.push(this.write(cds.compile.to.json(model)).to(path.join('db', 'csn.json')))
|
package/lib/PostgresService.js
CHANGED
|
@@ -344,14 +344,15 @@ GROUP BY k
|
|
|
344
344
|
|
|
345
345
|
static CQN2SQL = class CQN2Postgres extends SQLService.CQN2SQL {
|
|
346
346
|
_orderBy(orderBy, localized, locale) {
|
|
347
|
-
return orderBy.map(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
(c.element?.[this.class._localized] ? ` COLLATE "${locale}"` : '') +
|
|
352
|
-
(c.sort?.toLowerCase() === 'desc' || c.sort === -1 ? ' DESC
|
|
353
|
-
:
|
|
354
|
-
|
|
347
|
+
return orderBy.map(c => {
|
|
348
|
+
const nulls = c.nulls || (c.sort?.toLowerCase() === 'desc' || c.sort === -1 ? 'LAST' : 'FIRST')
|
|
349
|
+
const o = localized
|
|
350
|
+
? this.expr(c) +
|
|
351
|
+
(c.element?.[this.class._localized] && locale ? ` COLLATE "${locale}"` : '') +
|
|
352
|
+
(c.sort?.toLowerCase() === 'desc' || c.sort === -1 ? ' DESC' : ' ASC')
|
|
353
|
+
: this.expr(c) + (c.sort?.toLowerCase() === 'desc' || c.sort === -1 ? ' DESC' : ' ASC')
|
|
354
|
+
return o + ' NULLS ' + (nulls.toLowerCase() === 'first' ? 'FIRST' : 'LAST')
|
|
355
|
+
})
|
|
355
356
|
}
|
|
356
357
|
|
|
357
358
|
orderBy(orderBy) {
|
|
@@ -465,9 +466,11 @@ GROUP BY k
|
|
|
465
466
|
// Postgres does not support locking columns only tables which makes of unapplicable
|
|
466
467
|
// Postgres does not support "wait n" it only supports "nowait"
|
|
467
468
|
forUpdate(update) {
|
|
468
|
-
const { wait } = update
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
const { wait, ignoreLocked } = update
|
|
470
|
+
let sql = 'FOR UPDATE'
|
|
471
|
+
if (wait === 0) sql += ' NOWAIT'
|
|
472
|
+
if (ignoreLocked) sql += ' SKIP LOCKED'
|
|
473
|
+
return sql
|
|
471
474
|
}
|
|
472
475
|
|
|
473
476
|
forShareLock(lock) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cap-js/postgres",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "CDS database service for Postgres",
|
|
5
5
|
"homepage": "https://github.com/cap-js/cds-dbs/tree/main/postgres#cds-database-service-for-postgres",
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"start": "docker compose -f pg-stack.yml up -d"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@cap-js/db-service": "^1.
|
|
30
|
+
"@cap-js/db-service": "^1.19.0",
|
|
31
31
|
"pg": "^8"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|