@cap-js/postgres 1.10.5 → 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,25 @@
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/postgres-v1.11.0...postgres-v1.11.1) (2025-02-09)
8
+
9
+
10
+ ### Fixed
11
+
12
+ * postgres build plugin w `--production` ([#1018](https://github.com/cap-js/cds-dbs/issues/1018)) ([aafffc9](https://github.com/cap-js/cds-dbs/commit/aafffc99cb509380e5ae7738376e4d30ce5d66f2))
13
+
14
+ ## [1.11.0](https://github.com/cap-js/cds-dbs/compare/postgres-v1.10.5...postgres-v1.11.0) (2025-01-28)
15
+
16
+
17
+ ### Added
18
+
19
+ * support for cds.Map ([#889](https://github.com/cap-js/cds-dbs/issues/889)) ([cde7514](https://github.com/cap-js/cds-dbs/commit/cde7514df20396383e0179ffce838596e3706bb2))
20
+
21
+
22
+ ### Fixed
23
+
24
+ * starts endswith for null values ([#975](https://github.com/cap-js/cds-dbs/issues/975)) ([f0330bc](https://github.com/cap-js/cds-dbs/commit/f0330bc334fd3a8ed5377afcdd04b731baa8c753))
25
+
7
26
  ## [1.10.5](https://github.com/cap-js/cds-dbs/compare/postgres-v1.10.4...postgres-v1.10.5) (2024-12-16)
8
27
 
9
28
 
@@ -4,6 +4,7 @@ const cds = require('@sap/cds')
4
4
  const crypto = require('crypto')
5
5
  const { Writable, Readable } = require('stream')
6
6
  const sessionVariableMap = require('./session.json')
7
+ const SANITIZE_VALUES = process.env.NODE_ENV === 'production' && cds.env.log.sanitize_values !== false
7
8
 
8
9
  class PostgresService extends SQLService {
9
10
  init() {
@@ -329,7 +330,7 @@ GROUP BY k
329
330
  try {
330
331
  return await super.onINSERT(req)
331
332
  } catch (err) {
332
- throw _not_unique(err, 'ENTITY_ALREADY_EXISTS')
333
+ throw _not_unique(err, 'ENTITY_ALREADY_EXISTS', req.data)
333
334
  }
334
335
  }
335
336
 
@@ -337,7 +338,7 @@ GROUP BY k
337
338
  try {
338
339
  return await super.onUPDATE(req)
339
340
  } catch (err) {
340
- throw _not_unique(err, 'UNIQUE_CONSTRAINT_VIOLATION')
341
+ throw _not_unique(err, 'UNIQUE_CONSTRAINT_VIOLATION', req.data)
341
342
  }
342
343
  }
343
344
 
@@ -512,6 +513,7 @@ GROUP BY k
512
513
  Time: () => 'TIME',
513
514
  DateTime: () => 'TIMESTAMP',
514
515
  Timestamp: () => 'TIMESTAMP',
516
+ Map: () => 'JSONB',
515
517
 
516
518
  // HANA Types
517
519
  'cds.hana.CLOB': () => 'BYTEA',
@@ -542,6 +544,7 @@ GROUP BY k
542
544
  DecimalFloat: (e, t) => e[0] === '$' ? e : `CAST(${e} as decimal${t.precision && t.scale ? `(${t.precision},${t.scale})` : ''})`,
543
545
  Binary: e => e[0] === '$' ? e : `DECODE(${e},'base64')`,
544
546
  LargeBinary: e => e[0] === '$' ? e : `DECODE(${e},'base64')`,
547
+ Map: e => e[0] === '$' ? e : `CAST(${e} as jsonb)`,
545
548
 
546
549
  // HANA Types
547
550
  'cds.hana.CLOB': e => e[0] === '$' ? e : `DECODE(${e},'base64')`,
@@ -867,13 +870,14 @@ class ParameterStream extends Writable {
867
870
  }
868
871
  }
869
872
 
870
- function _not_unique(err, code) {
873
+ function _not_unique(err, code, data) {
871
874
  if (err.code === '23505')
872
875
  return Object.assign(err, {
873
876
  originalMessage: err.message, // FIXME: required because of next line
874
877
  message: code, // FIXME: misusing message as code
875
878
  code: 400, // FIXME: misusing code as (http) status
876
879
  })
880
+ if (data) err.values = SANITIZE_VALUES ? ['***'] : data
877
881
  return err
878
882
  }
879
883
 
@@ -10,8 +10,8 @@ const StandardFunctions = {
10
10
  countdistinct: x => `count(distinct ${x.val || x || '*'})`,
11
11
  contains: (...args) => `(coalesce(strpos(${args}),0) > 0)`,
12
12
  indexof: (x, y) => `strpos(${x},${y}) - 1`, // strpos is 1 indexed
13
- startswith: (x, y) => `strpos(${x},${y}) = 1`, // strpos is 1 indexed
14
- endswith: (x, y) => `substr(${x},length(${x}) + 1 - length(${y})) = ${y}`,
13
+ startswith: (x, y) => `coalesce(strpos(${x},${y}) = 1,false)`, // strpos is 1 indexed
14
+ endswith: (x, y) => `coalesce(substr(${x},length(${x}) + 1 - length(${y})) = ${y},false)`,
15
15
  matchesPattern: (x, y) => `regexp_like(${x}, ${y})`,
16
16
  matchespattern: (x, y) => `regexp_like(${x}, ${y})`,
17
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/postgres",
3
- "version": "1.10.5",
3
+ "version": "1.11.1",
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": {
@@ -23,11 +23,11 @@
23
23
  "CHANGELOG.md"
24
24
  ],
25
25
  "scripts": {
26
- "test": "npm start && cds-test $(../test/find)",
26
+ "test": "npm start && cds-test",
27
27
  "start": "docker compose -f pg-stack.yml up -d"
28
28
  },
29
29
  "dependencies": {
30
- "@cap-js/db-service": "^1.14.1",
30
+ "@cap-js/db-service": "^1.17.0",
31
31
  "pg": "^8"
32
32
  },
33
33
  "peerDependencies": {
@@ -59,6 +59,7 @@
59
59
  },
60
60
  "postgres": {
61
61
  "impl": "@cap-js/postgres",
62
+ "kind": "postgres",
62
63
  "dialect": "postgres",
63
64
  "vcap": {
64
65
  "label": "postgresql-db"