-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: standard database functions everywhere #1750
base: main
Are you sure you want to change the base?
Conversation
The cds-compiler and the node database services now are on-par with regard to the supported standard database functions. With this change we move the standard database function section out of the "runtime" part. Once CAP Java closed the gap, we can remove the disclaimer that this is only available for cds-compiler + node database services
#### String Functions | ||
|
||
- `concat(x, y, ...)` | ||
Concatenates the given strings or numbers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- not available in CAP Java
- do you support the concat operator (
||
) ? - https://github.wdf.sap.corp/cds-java/home/issues/1998
- returns
String
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we support the concat operator
Concatenates the given strings or numbers. | ||
|
||
- `trim(x)` | ||
Removes leading and trailing whitespaces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- not available in CAP Java
- returns
String
Removes leading and trailing whitespaces. | ||
|
||
- `contains(x, y)` | ||
Checks whether `y` is contained in `x` (fuzzy matching may apply). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- CAP Java
Value.contains(other)
Value.contains(other, isCaseInsensitive)
to control if case sensitiveValue.contains
is exact and never fuzzy- represented by
CqnContainmentTest
- implemented by
LIKE
orILIKE
, if available
- is the Compiler's implementation case sensitive or case insensitive
- OData v4, CAP: case sensitive
- OData v4, RAP: case insensitive (!)
- returns
Boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all OData inspired functions are case sensitive
Checks whether `y` is contained in `x` (fuzzy matching may apply). | ||
|
||
- `startswith(x, y)` | ||
Checks whether `y` starts with `x`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- CAP Java:
startsWith
- case sensitive?
- return
Boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all OData inspired functions are case sensitive
- `startswith(x, y)` | ||
Checks whether `y` starts with `x`. | ||
|
||
- `endswith(x, y)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- CAP Java:
endsWith
- case sensitive?
- return
Boolean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all OData inspired functions are case sensitive
- `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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- n/a in CAP Java
- please link to the corresponding HANA functions.
- these functions are very prone to one-off errors -> require a very precise specification
In addition to the OData and SAP HANA standard functions, the **CAP runtimes** provides special functions that are only available for runtime queries: | ||
|
||
- `search(xs, y)` | ||
Checks whether `y` is contained in any element of `xs` (fuzzy matching may apply). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- what is an
xs
? - please provide an example how this can be used in a view definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cant be used in a view defintion as indicated by the section heading and description. I will change xs
to x
:)
#### Numeric Functions | ||
|
||
- `ceiling(x)` | ||
Rounds the numeric parameter up to the nearest integer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n/a in CAP Java
- `ceiling(x)` | ||
Rounds the numeric parameter up to the nearest integer. | ||
|
||
- `floor(x)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n/a in CAP Java
- `session_context(v)` | ||
Utilizes standard variable names to maintain session context. | ||
Refer to [Session Variables](#session-variables) for additional information. | ||
|
||
- `now()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In CAP Java you can use the refs $now
, $user
, $valid.from
, $valid.to
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same for node, but this is besides the point of the standard functions. I will add a link to the other section though!
@@ -1015,7 +1008,8 @@ In addition to the OData and SAP HANA standard functions, the **CAP runtimes** p | |||
Utilizes standard variable names to maintain session context. | |||
Refer to [Session Variables](#session-variables) for additional information. | |||
|
|||
|
|||
- `now()` | |||
Returns the current datetime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In CAP Java we have the ref $now
but it returns the current Timestamp
and not the current DateTime
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In node we return now: () =>
session_context('$now')` and this in turn returns the current timestamp, thanks for pointing this out. I will adapt the docs :)
Extracts a substring from `x` starting at index `i` (0-based) with an optional length `n`. | ||
- `i`: | ||
- Positive: starts at index `i` | ||
- Negative: starts `i` positions before the end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not covered by OData.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it reads like it is:
The two-argument substring function with string parameter values returns a substring of the first parameter string value, starting at the Nth character and finishing at the last character (where N is the second parameter integer value)
A negative start index N, if supported, returns a string/collection starting N characters/items before the end of the string/collection.
we could align the parameter names in our docu with those found in the OData spec
The cds-compiler and the node database services now are on-par with regard to the supported standard database functions.
With this change we move the standard database function section out of the "runtime" part. Once CAP Java closed the gap, we can remove the disclaimer that this is only available for cds-compiler + node database services