From 83a0091f17e45ae7581b895dea399c15222ffc44 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 3 Jun 2024 14:23:20 +0200 Subject: [PATCH 1/9] fix: `!= null` is translated to `is not null` but `!= ` is not ``` > q = SELECT`from ${Books} { ID, title} where ID != null` > q.toSQL() { sql: `SELECT json_insert('{}','$."ID"',ID,'$."title"',title) as _json_ FROM (SELECT Books.ID,Books.title FROM sap_capire_bookshop_Books as Books WHERE Books.ID is not NULL)`, values: [] } ``` but for non-`null` comparisons, `!=` is translated to `<>`: ``` > q = SELECT`from ${Books} { ID, title} where ID != 207` > q.toSQL() { sql: `SELECT json_insert('{}','$."ID"',ID,'$."title"',title) as _json_ FROM (SELECT Books.ID,Books.title FROM sap_capire_bookshop_Books as Books WHERE Books.ID <> ?)`, values: [ 207 ] } ``` --- guides/databases-sqlite.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/databases-sqlite.md b/guides/databases-sqlite.md index 64fb37243..19efc4534 100644 --- a/guides/databases-sqlite.md +++ b/guides/databases-sqlite.md @@ -389,7 +389,7 @@ SELECT.one.localized(Books) The new database services guarantee identical behavior of these logic operators: - `==`, `=` — with `= null` being translated to `is null` -- `!=`, `<>` — with `!=` translated to `IS NOT` in SQLite +- `!=`, `<>` — with `!= null` being translated to `is not null` * `<`, `>`, `<=`, `>=`, `IN`, `LIKE` — are supported as is in standard SQL From 1d6c6400fc0b7408fe158cf1c294be0b026eb371 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 3 Jun 2024 14:24:42 +0200 Subject: [PATCH 2/9] Update guides/databases-sqlite.md --- guides/databases-sqlite.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/guides/databases-sqlite.md b/guides/databases-sqlite.md index 19efc4534..df7512eb2 100644 --- a/guides/databases-sqlite.md +++ b/guides/databases-sqlite.md @@ -389,7 +389,9 @@ SELECT.one.localized(Books) The new database services guarantee identical behavior of these logic operators: - `==`, `=` — with `= null` being translated to `is null` -- `!=`, `<>` — with `!= null` being translated to `is not null` +- `!=`, `<>` + + with `!= null` being translated to `is not null` + + in all other cases, `!=` is translated to `<>` * `<`, `>`, `<=`, `>=`, `IN`, `LIKE` — are supported as is in standard SQL From 62bdcd5a2980b7d72508b2edcb4a8a60be3ec5be Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Thu, 6 Jun 2024 15:21:24 +0200 Subject: [PATCH 3/9] adapt and move common sections to generic db section --- guides/databases-sqlite.md | 84 -------------------------------------- guides/databases.md | 79 +++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 84 deletions(-) diff --git a/guides/databases-sqlite.md b/guides/databases-sqlite.md index df7512eb2..5ee47064c 100644 --- a/guides/databases-sqlite.md +++ b/guides/databases-sqlite.md @@ -382,90 +382,6 @@ SELECT.from.localized(Books) SELECT.one.localized(Books) ``` - - -### Standard Operators {.impl .node} - -The new database services guarantee identical behavior of these logic operators: - -- `==`, `=` — with `= null` being translated to `is null` -- `!=`, `<>` - + with `!= null` being translated to `is not null` - + in all other cases, `!=` is translated to `<>` - -* `<`, `>`, `<=`, `>=`, `IN`, `LIKE` — are supported as is in standard SQL - -In particular, the translation of `!=` to `IS NOT` in SQLite — or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. - -> These operators are available for runtime queries, but not in CDS files. - - -### Standard Functions {.impl .node} - -A specified set of standard functions is now supported in a **database-agnostic**, hence portable way, and translated to database-specific variants or polyfills. These functions are by and large the same as specified in OData: - -* `concat(x,y,...)` — concatenates the given strings -* `contains(x,y)` — checks whether `y` is contained in `x`, may be fuzzy -* `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy -* `startswith(x,y)` — checks whether `y` starts with `x` -* `endswith(x,y)` — checks whether `y` ends with `x` -* `matchesPattern(x,y)` — checks whether `x` matches regex `y` -* `substring(x,i,n)` — extracts a substring from `x` starting at `i` with length `n` 1 -* `indexof(x,y)` — returns the (zero-based) index of the first occurrence of `y` in `x` -* `length(x)` — returns the length of string `x` -* `tolower(x)` — returns all-lowercased `x` -* `toupper(x)` — returns all-uppercased `x` -* `ceiling(x)` — returns ceiled `x` -* `session_context(v)` — with standard variable names → [see below](#session-variables) -* `year` `month`, `day`, `hour`, `minute`, `second` — return parts of a datetime - -> 1 Argument `n` is optional. -> These functions are only supported within runtime queries, but not in CDS files. - -The database service implementation translates these to the best-possible native SQL functions, thus enhancing the extent of **portable** queries. - -CQL query: - -```sql -SELECT from Books where search((title,descr),'y') -``` - -Translated native SQLite query: - -```sql -SELECT * from sap_capire_bookshop_Books - WHERE ifnull(instr(lower(title),lower('y')),0) - OR ifnull(instr(lower(descr),lower('y')),0) -``` - -> Note: only single values are supported for the second argument `y`. - -::: warning Case-sensitive - -You have to write these functions exactly as given; all-uppercase usages aren't supported. - -::: - - - -### SAP HANA Functions {.impl .node} - -In addition to the standard functions, which all new database services support, the new SQLite service also supports these common SAP HANA functions, to further increase the scope for portable testing: - -- `years_between` -- `months_between` -- `days_between` -- `seconds_between` -- `nano100_between` - -With open source and the new database service architecture, we also have methods in place to enhance this list by custom implementation. - -> Both usages are allowed here: all-lowercase as given above, as well as all-uppercase. - - - - - ### Session Variables {.impl .node} The new SQLite service can leverage [*better-sqlite*](https://www.npmjs.com/package/better-sqlite3)'s user-defined functions to support *session context* variables. In particular, the pseudo variables `$user.id`, `$user.locale`, `$valid.from`, and `$valid.to` are available in native SQL queries as shown below: diff --git a/guides/databases.md b/guides/databases.md index 1248fb389..76ba7c668 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -327,6 +327,85 @@ Select.from(AUTHOR) +### Standard Operators {.impl .node} + +The new database services guarantee identical behavior of these logic operators: + +`<`, `>`, `<=`, `>=`, `<>`, `=`, `IN`, `LIKE` — are supported as is in standard SQL. + +With special mappings for the following boolean operators: + +| Operator | `@cap-js/sqlite` | `@cap-js/hana` | `@cap-js/postgres` | +|-----------|------------------|----------------|---------------------| +| `= NULL` | `is NULL` | `is NULL` | `is NULL` | +| `!=` | `<>` | `!=` | `<>` | +| `!= NULL` | `is not NULL` | `is not NULL` | `is not NULL` | + + +In particular, the translation of `!=` to `IS NOT` in SQLite — or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. + +> These operators are available for runtime queries, but not in CDS files. + + +### Standard Functions {.impl .node} + +A specified set of standard functions is now supported in a **database-agnostic**, hence portable way, and translated to database-specific variants or polyfills. These functions are by and large the same as specified in OData: + +* `concat(x,y,...)` — concatenates the given strings +* `contains(x,y)` — checks whether `y` is contained in `x`, may be fuzzy +* `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy +* `startswith(x,y)` — checks whether `y` starts with `x` +* `endswith(x,y)` — checks whether `y` ends with `x` +* `matchesPattern(x,y)` — checks whether `x` matches regex `y` +* `substring(x,i,n)` — extracts a substring from `x` starting at `i` with length `n` 1 +* `indexof(x,y)` — returns the (zero-based) index of the first occurrence of `y` in `x` +* `length(x)` — returns the length of string `x` +* `tolower(x)` — returns all-lowercased `x` +* `toupper(x)` — returns all-uppercased `x` +* `ceiling(x)` — returns ceiled `x` +* `session_context(v)` — with standard variable names → [see below](#session-variables) +* `year` `month`, `day`, `hour`, `minute`, `second` — return parts of a datetime + +> 1 Argument `n` is optional. +> These functions are only supported within runtime queries, but not in CDS files. + +The database service implementation translates these to the best-possible native SQL functions, thus enhancing the extent of **portable** queries. + +CQL query: + +```sql +SELECT from Books where search((title,descr),'y') +``` + +Translated native SQLite query: + +```sql +SELECT * from sap_capire_bookshop_Books + WHERE ifnull(instr(lower(title),lower('y')),0) + OR ifnull(instr(lower(descr),lower('y')),0) +``` + +> Note: only single values are supported for the second argument `y`. + +::: warning Case-sensitive + +You have to write these functions exactly as given; all-uppercase usages aren't supported. + +::: + +### SAP HANA Functions {.impl .node} + +In addition to the standard functions, which all `@cap-js` database services support, `@cap-js/sqlite` and `@cap-js/postgres` also support these common SAP HANA functions, to further increase the scope for portable testing: + +- `years_between` +- `months_between` +- `days_between` +- `seconds_between` +- `nano100_between` + +With open source and the new database service architecture, we also have methods in place to enhance this list by custom implementation. + +> Both usages are allowed here: all-lowercase as given above, as well as all-uppercase. ### Native DB Queries From 1af530bd01c8754d3ca4ad930213a02402ef7eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Thu, 6 Jun 2024 20:27:19 +0200 Subject: [PATCH 4/9] 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 5f84a866c..8a7d9b3ff 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -363,7 +363,7 @@ A specified set of standard functions is now supported in a **database-agnostic* * `tolower(x)` — returns all-lowercased `x` * `toupper(x)` — returns all-uppercased `x` * `ceiling(x)` — returns ceiled `x` -* `session_context(v)` — with standard variable names → [see below](#session-variables) +* `session_context(v)` — with standard variable names → [see Session Variables](/guides/databases-sqlite#session-variables) * `year` `month`, `day`, `hour`, `minute`, `second` — return parts of a datetime > 1 Argument `n` is optional. From 9e7124cbf9d0edb683c3cfcf7484cd0295c4faf9 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Tue, 23 Jul 2024 18:09:13 +0200 Subject: [PATCH 5/9] move sections, apply some fixes --- guides/databases-sqlite.md | 21 ----------- guides/databases.md | 71 +++++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 48 deletions(-) diff --git a/guides/databases-sqlite.md b/guides/databases-sqlite.md index 5ee47064c..4cfbfcb44 100644 --- a/guides/databases-sqlite.md +++ b/guides/databases-sqlite.md @@ -382,27 +382,6 @@ SELECT.from.localized(Books) SELECT.one.localized(Books) ``` -### Session Variables {.impl .node} - -The new SQLite service can leverage [*better-sqlite*](https://www.npmjs.com/package/better-sqlite3)'s user-defined functions to support *session context* variables. In particular, the pseudo variables `$user.id`, `$user.locale`, `$valid.from`, and `$valid.to` are available in native SQL queries as shown below: - -```sql -SELECT session_context('$user.id') -SELECT session_context('$user.locale') -SELECT session_context('$valid.from') -SELECT session_context('$valid.to') -``` - -Among other things, this allows us to get rid of static helper views for localized data like `localized_de_sap_capire_Books`. - -::: tip Portable API - -The API shown below, which includes the function `session_context()` and specific pseudo variable names, is supported by **all** new database services, that is, *SQLite*, *PostgreSQL* and *SAP HANA*. This allows you to write respective code once and run it on all these databases. - -::: - - - ### Using Lean Draft {.impl .node} The old implementation was overly polluted with draft handling. But as draft is actually a Fiori UI concept, none of that should show up in database layers. Hence, we eliminated all draft handling from the new database service implementations, and implemented draft in a modular, non-intrusive way — called *'Lean Draft'*. The most important change is that we don't do expensive UNIONs anymore but work with single (cheap) selects. diff --git a/guides/databases.md b/guides/databases.md index 8a7d9b3ff..45e29dc01 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -329,44 +329,47 @@ Select.from(AUTHOR) ### Standard Operators {.impl .node} -The new database services guarantee identical behavior of these logic operators: +The database services guarantee identical behavior of these logic operators: -`<`, `>`, `<=`, `>=`, `<>`, `=`, `IN`, `LIKE` — are supported as is in standard SQL. +* `==`, `=` — with `=` null being translated to is `null` +* `!=`, `<>` — with `!=` translated to `IS NOT` in SQLite, or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA +* `<`, `>`, `<=`, `>=`, `IN`, `LIKE` — are supported as is in standard SQL -With special mappings for the following boolean operators: - -| Operator | `@cap-js/sqlite` | `@cap-js/hana` | `@cap-js/postgres` | -|-----------|------------------|----------------|---------------------| -| `= NULL` | `is NULL` | `is NULL` | `is NULL` | -| `!=` | `<>` | `!=` | `<>` | -| `!= NULL` | `is not NULL` | `is not NULL` | `is not NULL` | - - -In particular, the translation of `!=` to `IS NOT` in SQLite — or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. +With special mappings for the boolean operators `= NULL`, `!=` and `!= NULL`, +In particular, the translation of `!=` to `IS NOT` in SQLite — or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. > These operators are available for runtime queries, but not in CDS files. ### Standard Functions {.impl .node} -A specified set of standard functions is now supported in a **database-agnostic**, hence portable way, and translated to database-specific variants or polyfills. These functions are by and large the same as specified in OData: +A specified set of standard functions is supported in a **database-agnostic**, hence portable way, and translated to database-specific variants or polyfills. +These functions are by large the same as specified in OData: -* `concat(x,y,...)` — concatenates the given strings +* `concat(x,y,...)` — concatenates the given strings or numbers +* `trim(x)` — removes whitespaces * `contains(x,y)` — checks whether `y` is contained in `x`, may be fuzzy -* `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy * `startswith(x,y)` — checks whether `y` starts with `x` * `endswith(x,y)` — checks whether `y` ends with `x` -* `matchesPattern(x,y)` — checks whether `x` matches regex `y` -* `substring(x,i,n)` — extracts a substring from `x` starting at `i` with length `n` 1 -* `indexof(x,y)` — returns the (zero-based) index of the first occurrence of `y` in `x` +* `matchespattern(x,y)` — checks whether `x` matches regex `y` +* `substring(x,i,n?)` 1 — extracts a substring from `x` starting at `i` (may be negative) with length `n` (optional; may be negative) +* `indexof(x,y)` 1 — returns the index of the first occurrence of `y` in `x` * `length(x)` — returns the length of string `x` * `tolower(x)` — returns all-lowercased `x` * `toupper(x)` — returns all-uppercased `x` -* `ceiling(x)` — returns ceiled `x` -* `session_context(v)` — with standard variable names → [see Session Variables](/guides/databases-sqlite#session-variables) -* `year` `month`, `day`, `hour`, `minute`, `second` — return parts of a datetime +* `ceiling(x)` — rounds the input numeric parameter up to the nearest numeric value +* `floor(x)` — rounds the input numeric parameter down to the nearest numeric value +* `round(x)` — rounds the input numeric parameter to the nearest numeric value. + The mid-point between two integers is rounded away from zero, i.e. 0.5 is rounded to 1 and ‑0.5 is rounded to -1. +* `year` `month`, `day`, `hour`, `minute`, `second`, `fractionalseconds`, `time`, `date` — return parts of a datetime +* `maxdatetime`, `mindatetime` — return the maximum or minimum datetime +* `now()` — returns the current datetime +* `totalseconds(x)` — returns the total seconds of a datetime +* `min(x)` `max(x)` `sum(x)` `avg(x)` `count(x)`, `countdistinct(x)` — aggregate functions +* `search(xs,y)` 2 — checks whether `y` is contained in any of `xs`, may be fuzzy (see [Searching Data](/guides/providing-services#searching-data)) +* `session_context(v)` 2 — with standard variable names → [see Session Variables](/guides/databases#session-variables) +> 1 These functions work zero-based. E.g., `substring('abcdef', 1, 3)` returns 'bcd' -> 1 Argument `n` is optional. > These functions are only supported within runtime queries, but not in CDS files. The database service implementation translates these to the best-possible native SQL functions, thus enhancing the extent of **portable** queries. @@ -397,17 +400,31 @@ You have to write these functions exactly as given; all-uppercase usages aren't In addition to the standard functions, which all `@cap-js` database services support, `@cap-js/sqlite` and `@cap-js/postgres` also support these common SAP HANA functions, to further increase the scope for portable testing: -- `years_between` -- `months_between` -- `days_between` -- `seconds_between` -- `nano100_between` +* `years_between` +* `months_between` +* `days_between` +* `seconds_between` +* `nano100_between` With open source and the new database service architecture, we also have methods in place to enhance this list by custom implementation. > Both usages are allowed here: all-lowercase as given above, as well as all-uppercase. +### Session Variables {.impl .node} + +The API shown below, which includes the function `session_context()` and specific pseudo variable names, is supported by **all** new database services, that is, *SQLite*, *PostgreSQL* and *SAP HANA*. +This allows you to write respective code once and run it on all these databases: + +```sql +SELECT session_context('$user.id') +SELECT session_context('$user.locale') +SELECT session_context('$valid.from') +SELECT session_context('$valid.to') +``` + +Among other things, this allows us to get rid of static helper views for localized data like `localized_de_sap_capire_Books`. + ### Native DB Queries If required you can also use native database features by executing native SQL queries: From 78989814b06ff884e73bb58bad0fa95ae6b6f643 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Thu, 25 Jul 2024 11:32:52 +0200 Subject: [PATCH 6/9] more improvements --- guides/databases.md | 65 +++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/guides/databases.md b/guides/databases.md index c998b4084..37a1a1bac 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -329,25 +329,26 @@ Select.from(AUTHOR) ### Standard Operators {.impl .node} -The database services guarantee identical behavior of these logic operators: +The database services guarantee identical behavior of these operators: -* `==`, `=` — with `=` null being translated to is `null` +* `==`, `=` — with `=` null being translated to `is null` * `!=`, `<>` — with `!=` translated to `IS NOT` in SQLite, or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA * `<`, `>`, `<=`, `>=`, `IN`, `LIKE` — are supported as is in standard SQL +* `||` — concatenation operator -With special mappings for the boolean operators `= NULL`, `!=` and `!= NULL`, In particular, the translation of `!=` to `IS NOT` in SQLite — or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. > These operators are available for runtime queries, but not in CDS files. -### Standard Functions {.impl .node} +### Functions Mappings for Runtime Queries {.impl .node} A specified set of standard functions is supported in a **database-agnostic**, hence portable way, and translated to database-specific variants or polyfills. -These functions are by large the same as specified in OData: +Note that these functions are only supported within runtime queries, but not in CDS files. +This set of functions are by large the same as specified in OData: * `concat(x,y,...)` — concatenates the given strings or numbers -* `trim(x)` — removes whitespaces +* `trim(x)` — removes leading and trailing whitespaces * `contains(x,y)` — checks whether `y` is contained in `x`, may be fuzzy * `startswith(x,y)` — checks whether `y` starts with `x` * `endswith(x,y)` — checks whether `y` ends with `x` @@ -361,54 +362,30 @@ These functions are by large the same as specified in OData: * `floor(x)` — rounds the input numeric parameter down to the nearest numeric value * `round(x)` — rounds the input numeric parameter to the nearest numeric value. The mid-point between two integers is rounded away from zero, i.e. 0.5 is rounded to 1 and ‑0.5 is rounded to -1. -* `year` `month`, `day`, `hour`, `minute`, `second`, `fractionalseconds`, `time`, `date` — return parts of a datetime -* `maxdatetime`, `mindatetime` — return the maximum or minimum datetime +* `year(x)` `month(x)`, `day(x)`, `hour(x)`, `minute(x)`, `second(x)`, `fractionalseconds(x)`, `time(x)`, `date(x)` — + returns parts of a datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` +* `maxdatetime(x)`, `mindatetime(x)` — return the maximum or minimum datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` +* `totalseconds(x)` — returns the total seconds of a datetime a given `cds.DateTime` / `cds.Time` * `now()` — returns the current datetime -* `totalseconds(x)` — returns the total seconds of a datetime * `min(x)` `max(x)` `sum(x)` `avg(x)` `count(x)`, `countdistinct(x)` — aggregate functions -* `search(xs,y)` 2 — checks whether `y` is contained in any of `xs`, may be fuzzy (see [Searching Data](/guides/providing-services#searching-data)) -* `session_context(v)` 2 — with standard variable names → [see Session Variables](/guides/databases#session-variables) +* `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy → [see Searching Data](../guides/providing-services#searching-data) +* `session_context(v)` — with standard variable names → [see Session Variables](#session-variables) > 1 These functions work zero-based. E.g., `substring('abcdef', 1, 3)` returns 'bcd' -> These functions are only supported within runtime queries, but not in CDS files. - -The database service implementation translates these to the best-possible native SQL functions, thus enhancing the extent of **portable** queries. - -CQL query: - -```sql -SELECT from Books where search((title,descr),'y') -``` - -Translated native SQLite query: - -```sql -SELECT * from sap_capire_bookshop_Books - WHERE ifnull(instr(lower(title),lower('y')),0) - OR ifnull(instr(lower(descr),lower('y')),0) -``` - -> Note: only single values are supported for the second argument `y`. - -::: warning Case-sensitive - -You have to write these functions exactly as given; all-uppercase usages aren't supported. - -::: - -### SAP HANA Functions {.impl .node} +> You have to write these functions exactly as given; all-uppercase usages aren't supported. In addition to the standard functions, which all `@cap-js` database services support, `@cap-js/sqlite` and `@cap-js/postgres` also support these common SAP HANA functions, to further increase the scope for portable testing: -* `years_between` -* `months_between` -* `days_between` -* `seconds_between` -* `nano100_between` +* `years_between` — Computes the number of years between two specified dates. +* `months_between` — Computes the number of months between two specified dates. +* `days_between` — Computes the number of days between two specified dates. +* `seconds_between` — Computes the number of seconds between two specified dates. +* `nano100_between` — Computes the time difference between two dates to the precision of 0.1 microseconds. +The database service implementation translates these to the best-possible native SQL functions, thus enhancing the extent of **portable** queries. With open source and the new database service architecture, we also have methods in place to enhance this list by custom implementation. -> Both usages are allowed here: all-lowercase as given above, as well as all-uppercase. +> For the SAP HANA functions, both usages are allowed: all-lowercase as given above, as well as all-uppercase. ### Session Variables {.impl .node} From a6e84e4b6309fb62e69fde0ee43e7997e3dc369d Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Tue, 3 Sep 2024 15:20:38 +0200 Subject: [PATCH 7/9] 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 37a1a1bac..97eb6129f 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -365,7 +365,7 @@ This set of functions are by large the same as specified in OData: * `year(x)` `month(x)`, `day(x)`, `hour(x)`, `minute(x)`, `second(x)`, `fractionalseconds(x)`, `time(x)`, `date(x)` — returns parts of a datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` * `maxdatetime(x)`, `mindatetime(x)` — return the maximum or minimum datetime for a given `cds.DateTime` / `cds.Date` / `cds.Time` -* `totalseconds(x)` — returns the total seconds of a datetime a given `cds.DateTime` / `cds.Time` +* `totalseconds(x)` — returns the total seconds of a datetime for a given `cds.DateTime` / `cds.Time` * `now()` — returns the current datetime * `min(x)` `max(x)` `sum(x)` `avg(x)` `count(x)`, `countdistinct(x)` — aggregate functions * `search(xs,y)` — checks whether `y` is contained in any of `xs`, may be fuzzy → [see Searching Data](../guides/providing-services#searching-data) From 93287be295268f5f39385b3dd3ea2b2fd2acc4f4 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 7 Oct 2024 15:44:44 +0200 Subject: [PATCH 8/9] dont mention concat operator --- guides/databases.md | 1 - 1 file changed, 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index 4f29c4164..c571d6f0b 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -332,7 +332,6 @@ The database services guarantee identical behavior of these operators: * `==`, `=` — with `=` null being translated to `is null` * `!=`, `<>` — with `!=` translated to `IS NOT` in SQLite, or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA * `<`, `>`, `<=`, `>=`, `IN`, `LIKE` — are supported as is in standard SQL -* `||` — concatenation operator In particular, the translation of `!=` to `IS NOT` in SQLite — or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. From fff118cfb42244b720023588d42d14beb5d5a791 Mon Sep 17 00:00:00 2001 From: Patrice Bender Date: Mon, 7 Oct 2024 16:15:00 +0200 Subject: [PATCH 9/9] improve RT only disclaimer --- guides/databases.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/guides/databases.md b/guides/databases.md index c571d6f0b..0691ba7d1 100644 --- a/guides/databases.md +++ b/guides/databases.md @@ -335,7 +335,9 @@ The database services guarantee identical behavior of these operators: In particular, the translation of `!=` to `IS NOT` in SQLite — or to `IS DISTINCT FROM` in standard SQL, or to an equivalent polyfill in SAP HANA — greatly improves the portability of your code. -> These operators are available for runtime queries, but not in CDS files. +::: warning Runtime Only +The operator mappings are available for runtime queries only, but not in CDS files. +::: ### Functions Mappings for Runtime Queries {.impl .node} @@ -384,6 +386,10 @@ With open source and the new database service architecture, we also have methods > For the SAP HANA functions, both usages are allowed: all-lowercase as given above, as well as all-uppercase. +::: warning Runtime Only +The function mappings are available for runtime queries only, but not in CDS files. +::: + ### Session Variables {.impl .node}