Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@cap-js/db-service

cap-js591.3kSEE LICENSE1.20.0TypeScript support: included

CDS base database service

CAP, CDS

readme

CDS base database service

Welcome to the base database service for SAP Cloud Application Programming Model Node.js. This service forms the core of all supported databases and is the base of our streamlined database architecture.

Find documentation at https://cap.cloud.sap/docs/guides/databases

Support

This project is open to feature requests/suggestions, bug reports etc. via GitHub issues.

Contribution

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.

Versioning

This library follows Semantic Versioning. All notable changes are documented in CHANGELOG.md.

Code of Conduct

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 at all times.

Licensing

Copyright 2024 SAP SE or an SAP affiliate company and cds-dbs contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.

changelog

Changelog

1.20.0 (2025-04-17)

Added

Fixed

  • expand: proper subquery from construction (#1126) (e343e79), closes #1114 #1112
  • Improved support for special characters in column names (#1141) (ba04697)
  • infer: for localized queries, use localized.<entity> as _target (#1140) (b08707b)

1.19.1 (2025-04-01)

Fixed

  • scoped queries: wrap filter in xpr if needed (#1105) (8f44df3)

1.19.0 (2025-03-31)

Added

Fixed

1.18.0 (2025-03-04)

Added

  • query modifiers on expand ref are propagated to subquery (#1049) (39fbadf)
  • support query modifiers at leaf of from ref (#1050) (500a666)

Fixed

  • <expand>[@odata](https://github.com/odata).count queries (#966) (6607a84)
  • align debug log format of stmt values (#1052) (93af0fe)
  • expand + groupby may return null, dont attach .element (#1042) (cf2e0a2)

1.17.2 (2025-02-09)

Fixed

  • replace polynomial regex with simple string op (#1015) (3fe6e6b)

1.17.1 (2025-02-04)

Fixed

  • deep update resulting in deep delete of sub-element (#1006) (ef2f817)
  • nested $self reference to other column (#1009) (41a76d8)

1.17.0 (2025-01-28)

Added

Fixed

  • UPDATE: no assocs in list which matches subquery results (4bcb88a)
  • UPDATE: only perform subselect matching if necessary (#989) (4bcb88a)
  • contains not evaluting to bool (#980) (760484b)
  • nested ternary in calculated element (#981) (5f4a1fe)
  • reject virtual elements in all expressions (#972) (d0c949d)
  • starts endswith for null values (#975) (f0330bc)
  • use "$$value$$" as internal column name for UPSERT (#976) (8c86b86)

1.16.2 (2024-12-18)

Fixed

1.16.1 (2024-12-16)

Fixed

1.16.0 (2024-11-25)

Changed

  • single column in search function is also treated as CQN list (#898) (f6593e6)

Fixed

  • foreignKeys aspect on association may not be set (#903) (732a2f3)
  • insert on uuid with default value (#911) (545e489)
  • session_context, current_date, current_time and current_timestamp are treated as SAP HANA functions and are callable in upper case (#910) (50ebd10)
  • wrap values in array if it is object, so it can be spreaded (#882) (11f3e8b)

1.15.1 (2024-11-18)

Fixed

1.15.0 (2024-11-14)

Added

  • enable path expressions in infix filter after exists predicate (#875) (7e50359)

Fixed

1.14.1 (2024-10-28)

Fixed

  • deep delete for views (#496) (82154ef)
  • properly support default, cds.on.insert and cds.on.update for UPSERT queries (#425) (338e9f5)
  • SELECT cds.hana.BINARY (#870) (33c3ebe)

1.14.0 (2024-10-15)

Added

  • assoc-like calc elements after exists predicate (#831) (05f7d75)

Fixed

  • Improved behavioral consistency between the database services (#837) (b6f7187)
  • Treat assoc-like calculated elements as unmanaged assocs (#830) (cbe0df7)

1.13.0 (2024-10-01)

Added

Fixed

  • deep-queries: properly return insert result (#803) (8d800e2)
  • dont use virtual key for UPDATE … where (&lt;key&gt;) in <subquery> (#800) (d25af70)
  • reject all path expressions w/o foreign keys (#806) (cd271a8)

1.12.1 (2024-09-03)

Fixed

  • deep groupby expand queries (#768) (5423cf3)
  • deep: prevent false unique constraint errors and combine delete queries (#781) (01de95f)
  • logging: from changes in @sap/cds (#791) (1e8bf06)
  • prepend aliases to refs within function args in on conditions (#795) (9b34314), closes #779
  • prevent $search queries from throwing (#772) (cdf4d37)

1.12.0 (2024-07-25)

Fixed

Changed

1.11.0 (2024-07-08)

Added

  • search: enable deep search with path expressions (#590) (e9e9461)

Changed

  • search interprets only first search term instead of raising an error (#707) (0b9108c)

Fixed

  • optimize foreign key access for expand with aggregations (#734) (77b7978)

1.10.3 (2024-07-05)

Fixed

  • rewrite assoc chains if intermediate assoc is not fk (#715) (3873f9a)
  • Support expand with group by clause (#721) (90c9e6a)

1.10.2 (2024-06-25)

Fixed

1.10.1 (2024-06-19)

Fixed

  • Only check first row if no changes required (#552) (39b0b85)

1.10.0 (2024-05-29)

Added

1.9.2 (2024-05-28)

Fixed

  • do not prepend table alias to session variables (#656) (24e8b19)

1.9.1 (2024-05-16)

Fixed

  • dont mistake non-key access with foreign key (#642) (2cd2349)

1.9.0 (2024-05-08)

Added

Fixed

  • order by: reject non-fk traversals of own columns in order by (#599) (3288d63)
  • Align all quote functions with @sap/cds-compiler (#619) (42e9828)
  • assign artificial alias if selecting from anonymous subquery (#608) (e1a7711)
  • avoid spread operator (#630) (a39fb65)
  • flat update with arbitrary where clauses (#598) (f108798)
  • improved = and != with val null (#626) (cbcfe3b)
  • Improved placeholders and limit clause (#567) (d5d5dbb)
  • multiple result responses (#602) (bf0bed4)
  • only consider persisted columns for simple operations (#592) (6e31bda)

Changed

1.8.0 (2024-04-12)

Added

Fixed

  • expand: Only accept on structures, assocs or table aliases (#551) (3248512)
  • order by: for localized sorting, prepend table alias (#546) (a273a92)
  • etag with stream_compat (#562) (b0a3a41)
  • exclude cds.LargeBinary from wildcard expansion (#577) (6661d63)
  • Reduce insert queries for deep update (#568) (55e5114)
  • Reduced count query complexity when possible (#553) (3331f02)

1.7.0 (2024-03-22)

Added

  • also support lowercase matchespattern function (#528) (6ea574e)
  • forUpdate and forShareLock (#148) (99a1170)
  • hana: drop prepared statements after end of transaction (#537) (b1f864e)
  • hana: Add views with parameters support (#488) (3790ec0)
  • orderby: allow to disable collations with @cds.collate: false (#492) (820f971)

Fixed

  • cqn2sql: Smart quoting of columns inside UPSERT rows (#519) (78fe10b)
  • Getting rid of quirks mode (#514) (c9aa6e8)
  • issue with reused select cqns (#505) (916d175)
  • joins without columns are rejected (#535) (eb9beda)
  • search: dont search non string aggregations (#527) (c87900c)
  • search: search on aggregated results in HAVING clause (#524) (61d348e)

1.6.4 (2024-02-28)

Fixed

  • cqn2sql: smart quoting also for update statements (#475) (1688f77)
  • INSERT with first undefined value (#484) (c21e3c4)
  • Allow SELECT.join queries again with full infer call (#469) (5329ec0)
  • optimize foreign key access in a join relevant path (#481) (5e30de4), closes #479

1.6.3 (2024-02-20)

Fixed

  • cqn4sql: be robust against $self.<element>; references (#471) (2921b0e)
  • infer: Always use srv.model (#451) (41cf4a2)
  • Throw 'new Error' instead of string on $search with multiple words (#472) (51be94d)

1.6.2 (2024-02-16)

Fixed

  • ** infer:** unique alias for scoped subqueries (#465) (5dbaa8e)
  • Allow only for array of arrays as data for plain SQL (#449) (22e1c43)
  • dont insert structured elements (#461) (f3f688d)
  • ignore virtual keys in UPSERT(#463) (49adbf3)
  • INSERT entries containing undefined values (#453) (d3aad75)
  • select without columns from unknown entity (#466) (eb857de)

1.6.1 (2024-02-05)

Fixed

  • consider leafs in ref with filter (→ .id) for alias calculation (#440) (3e2ef24)

1.6.0 (2024-02-02)

Added

  • Add fallback for @cap-js/hana for unknown entities (#403) (e7dd6de)
  • SELECT returns binaries as Buffers (#416) (d4240d5)
  • SELECT returns LargeBinaries as streams unless feature flag "stream_compat" is set (#251) (8165a4a)
  • strict mode to validate input for INSERT, UPDATE and UPSERT (#384) (4644483)
  • Support Readable Streams inside INSERT.entries (#343) (f6faf89)

Fixed

1.5.1 (2023-12-20)

Fixed

  • cqn2sql: supporting calculated elements (#387) (2153fb9)
  • do not rely on db constraints for deep delete (#390) (9623af6)

Performance Improvements

1.5.0 (2023-12-06)

Added

  • Improved connection pool for HANAService (#349) (1c284e6)

Fixed

  • localized: refs in subqueries in from are translated (#366) (cfe4897)
  • wrong odata count in filter with groupby (#352) (70690a1)

1.4.0 (2023-11-20)

Added

  • UPDATE/DELETE: Enable path expressions for improved data manipulation (#325) (94f0776)
  • temporal data: add time slice key to conflict clause (#249) (67b8edf)
  • use place holders for update and delete (#323) (81472b9)

Fixed

  • align time function behavior (#322) (c3ab40a)
  • calculated elements: path expressions in func.args within xpr (#321) (cee25e3)
  • Disconnect db service on shutdown (#327) (8471bda)
  • non-fk access in filter conditions are properly rejected (#336) (4c948fe)
  • search: check calculated columns at any depth (#310) (8fd6153)

1.3.2 (2023-10-13)

Fixed

  • preserve $count for result of SELECT queries (#280) (23bef24)

1.3.1 (2023-10-10)

Fixed

  • Error message for search with multiple arguments. #265

Version 1.3.0 - 2023-10-06

Changed

  • INSERT.into(...).rows/values() is not allowed anymore without specifying .columns(...). #209
  • Deep deletion uses correlated subqueries instead of materializing the to be deleted object before. #212

Fixed

  • Various fixes for calculated elements on read. #220 #223 #233
  • Don't release to pool connections twice. #243
  • Syntax error in matchesPattern function. #237
  • SELECTs with more than 50 columns does not return null values. #238 #261

Version 1.2.1 - 2023-09-08

Fixed

  • Association expansion in infix filters. #213

Version 1.2.0 - 2023-09-06

Added

  • support for calculated elements on read. #113 #123
  • support for managed associations with default values. #193
  • introduced new operator == which translates to IS NOT DISTINCT FROM. #164

Fixed

  • resolved a type error which occured in some cases for deeply nested expands. #173
  • path expression traversing non-foreign-key fields within infix filters are now properly rejected for exists predicates. #181
  • CQL functions: In the args of the concat function an xpr is now wrapped in parentheses. #196
  • Make UPDATE and ofarray typed column compatible. #184
  • Ensure that INSERT with rows always inserts into the correct column. #193
  • Allow DateTime columns to compare against their returned value. #206
  • Deep Insert using backlink associations as key #199.

Version 1.1.0 - 2023-08-01

Fixed

  • UPDATE with path expressions do not end up in a dump anymore. Instead, a proper error message is emitted.
  • UPDATE is only noop if it does not include an element annotated with `@cds.on.update`.
  • SELECT with '*' that is not expanded creates now a clearer error when the column name is required.
  • SELECT with plain SQL statements will return correct result regardless of casing.
  • View resolving for streams.

Version 1.0.1 - 2023-07-03

Fixed

  • Paths addressing a column of the query via $self.<column> in group by / order by, having or where are now correctly substituted.
  • Mapping for OData average function to ANSI SQL compliant avg function.

Version 1.0.0 - 2023-06-23

  • Initial Release