From 291273f51a1fdd1bd9e6e9f285cf49a4e3ef7df4 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Thu, 23 Oct 2025 18:21:59 +0200 Subject: [PATCH 1/6] chore: remove node.js only marker for most standard functions most of the standard database functions are also supported by the java runtime. Hence this section needed to be updated. Date / Aggregation / SAP HANA functions are still a todo for Java. Once the BLIs are implemented, we can also unlock those sections for Java. --- guides/databases.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/guides/databases.md b/guides/databases.md index 06f943fc58..0e19e665ef 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -921,12 +921,12 @@ Instead, they protect the integrity of your data in the database layer against p ## Standard Database Functions -A specified set of standard functions - inspired by [OData](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_StringandCollectionFunctions) and [SAP HANA](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/alphabetical-list-of-functions?locale=en-US) - is supported in a **database-agnostic**, hence portable way, and translated to the best-possible native SQL functions or polyfills during runtime (currently only Node.js) and for your CDL files. +A specified set of standard functions - inspired by [OData](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_StringandCollectionFunctions) and [SAP HANA](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/alphabetical-list-of-functions?locale=en-US) - is supported in a **database-agnostic**, hence portable way, and translated to the best-possible native SQL functions or polyfills during runtime and for your CDL files. ### OData standard functions -The `@sap/cds-compiler` and all CAP Node.js database services come with out of the box support for common OData functions. +The `@sap/cds-compiler` and all CAP (Node.js & Java) database services come with out of the box support for common OData functions. ::: warning Case Sensitivity The OData function mappings are case-sensitive and must be written as in the list below. @@ -1021,6 +1021,8 @@ For example, `startsWith` instead of `startswith` will be passed as-is to the da If you provide more than one argument, the `round` function may behave differently depending on the database. ::: +
+ #### Date and Time Functions - `year(x)`, `month(x)`, `day(x)`, `hour(x)`, `minute(x)`, `second(x)` @@ -1064,6 +1066,8 @@ For the SAP HANA functions, both usages are allowed: all-lowercase as given abov - `nano100_between` Computes the time difference between two dates to the precision of 0.1 microseconds. ([link](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/nano100-between-function-datetime?locale=en-US)) +
+ ### Special Runtime Functions In addition to the OData and SAP HANA standard functions, the **CAP runtimes** provides special functions that are only available for runtime queries: From c492216b8777ff9ffe7a3048cde366207f7eb054 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Thu, 23 Oct 2025 18:26:04 +0200 Subject: [PATCH 2/6] better wording --- guides/databases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index 0e19e665ef..db2ae96920 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -921,7 +921,7 @@ Instead, they protect the integrity of your data in the database layer against p ## Standard Database Functions -A specified set of standard functions - inspired by [OData](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_StringandCollectionFunctions) and [SAP HANA](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/alphabetical-list-of-functions?locale=en-US) - is supported in a **database-agnostic**, hence portable way, and translated to the best-possible native SQL functions or polyfills during runtime and for your CDL files. +A specified set of standard functions - inspired by [OData](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_StringandCollectionFunctions) and [SAP HANA](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/alphabetical-list-of-functions?locale=en-US) - is supported in a **database-agnostic**, hence portable way. The functions are translated to the best-possible native SQL functions or polyfills during runtime and also during compilation of your CDL files. ### OData standard functions From af6dc7c83637b088bd26a75a9e5581c7415bc6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20G=C3=B6rler?= Date: Thu, 23 Oct 2025 20:27:44 +0200 Subject: [PATCH 3/6] Update databases.md --- guides/databases.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/guides/databases.md b/guides/databases.md index db2ae96920..00febd059a 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -1040,11 +1040,14 @@ For example, `startsWith` instead of `startswith` will be passed as-is to the da - `mindatetime()` Returns the earliest possible point in time: `'0001-01-01T00:00:00.000Z'`. + + #### Aggregate Functions - `min(x)`, `max(x)`, `sum(x)`, `average(x)`, `count(x)`, `countdistinct(x)` Standard aggregate functions used to calculate minimum, maximum, sum, average, count, and distinct count of values. +
### SAP HANA Functions @@ -1066,11 +1069,9 @@ For the SAP HANA functions, both usages are allowed: all-lowercase as given abov - `nano100_between` Computes the time difference between two dates to the precision of 0.1 microseconds. ([link](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/nano100-between-function-datetime?locale=en-US)) -
- ### Special Runtime Functions -In addition to the OData and SAP HANA standard functions, the **CAP runtimes** provides special functions that are only available for runtime queries: +In addition to the OData and SAP HANA standard functions, the **CAP runtime** provides special functions that are only available for runtime queries: - `search(x, y)` Checks whether `y` is contained in any element of `x` (fuzzy matching may apply). @@ -1083,6 +1084,8 @@ In addition to the OData and SAP HANA standard functions, the **CAP runtimes** p - `now()` Returns the current timestamp. + + ## Using Native Features { #native-db-functions} In general, the CDS 2 SQL compiler doesn't 'understand' SQL functions but translates them to SQL generically as long as they follow the standard call syntax of `function(param1, param2)`. This allows you to use native database functions inside your CDS models. @@ -1195,4 +1198,4 @@ Once you have 2 non-HANA local databases, you need to have 2 distinct database c -CAP samples demonstrate this in [@capire/bookstore](https://github.com/capire/bookstore/tree/main/db). \ No newline at end of file +CAP samples demonstrate this in [@capire/bookstore](https://github.com/capire/bookstore/tree/main/db). From 90d9092fff0756d1d0f3f8a01e263c9407577af1 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 27 Oct 2025 12:16:27 +0100 Subject: [PATCH 4/6] Update guides/databases.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Adrian Görler --- guides/databases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index 00febd059a..07420cee55 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -921,7 +921,7 @@ Instead, they protect the integrity of your data in the database layer against p ## Standard Database Functions -A specified set of standard functions - inspired by [OData](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_StringandCollectionFunctions) and [SAP HANA](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/alphabetical-list-of-functions?locale=en-US) - is supported in a **database-agnostic**, hence portable way. The functions are translated to the best-possible native SQL functions or polyfills during runtime and also during compilation of your CDL files. +A specified set of standard functions - inspired by [OData](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_StringandCollectionFunctions) and [SAP HANA](https://help.sap.com/docs/hana-cloud-database/sap-hana-cloud-sap-hana-database-sql-reference-guide/alphabetical-list-of-functions?locale=en-US) - is supported in a **database-agnostic**, hence portable way. The functions are translated to the best-possible database-specific SQL expressions at runtime and also during compilation of your CDL files. ### OData standard functions From d84964090e58d8d5b3f9448ab9e2ea9cd833af58 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 27 Oct 2025 12:16:35 +0100 Subject: [PATCH 5/6] Update guides/databases.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: René Jeglinsky --- guides/databases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index 07420cee55..ebe68165b4 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -926,7 +926,7 @@ A specified set of standard functions - inspired by [OData](https://docs.oasis-o ### OData standard functions -The `@sap/cds-compiler` and all CAP (Node.js & Java) database services come with out of the box support for common OData functions. +The `@sap/cds-compiler` and all CAP database services (Node.js & Java) come with out of the box support for common OData functions. ::: warning Case Sensitivity The OData function mappings are case-sensitive and must be written as in the list below. From 7f32884f26566d436f33a14d64ca2b32ceae1721 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 27 Oct 2025 12:17:19 +0100 Subject: [PATCH 6/6] Update guides/databases.md --- guides/databases.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index ebe68165b4..784069076a 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -926,7 +926,7 @@ A specified set of standard functions - inspired by [OData](https://docs.oasis-o ### OData standard functions -The `@sap/cds-compiler` and all CAP database services (Node.js & Java) come with out of the box support for common OData functions. +The `@sap/cds-compiler` and the database services come with out of the box support for common OData functions. ::: warning Case Sensitivity The OData function mappings are case-sensitive and must be written as in the list below.