Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions spec/v1/CSN-Interop-Effective.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,10 +1080,10 @@ definitions:

The `on` condition is constructed by triples of:
- Reference to the target element (ID) as array with 2 items
- Equals Operator "="
- Equals Operator `=` or Smaller Equals Operator `<=` or Bigger Equals Operator `>=`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Equals Operator `=` or Smaller Equals Operator `<=` or Bigger Equals Operator `>=`
- Operator: Equals `=`, Smaller Equals`<=` or Bigger Equals `>=`

- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)

The first and third entry MAY be reversed but the `=` operator MUST be in the middle.
The first and third entry MAY be reversed but the `=`, `<=` or `>=` operator MUST be in the middle.
The target element reference MUST have two array items. The first item is the association name and the second item is the target element name.
The local element reference MUST have one array item, which is the local element name.

Expand All @@ -1095,11 +1095,15 @@ definitions:
oneOf:
- $ref: "#/definitions/StructuredElementReference"
- $ref: "#/definitions/EqualsOperator"
- $ref: "#/definitions/SmallerEqualsOperator"
- $ref: "#/definitions/BiggerEqualsOperator"
- $ref: "#/definitions/AndOperator"
- $ref: "#/definitions/OnValue"
minItems: 3
examples:
- [{ "ref": ["to_Connection", "AirlineID"] }, "=", { "ref": ["AirlineID"] }]
- [{ "ref": ["to_Connection", "FlightDate"] }, "<=", { "ref": ["FlightDate"] }]
- [{ "ref": ["to_Connection", "FlightDate"] }, ">=", { "ref": ["FlightDate"] }]
Copy link
Member Author

@maiargu maiargu Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions from my side, to be discussed:

  1. if the operators "<=" and "<=" are allowed, are they restricted only to some specific cds. type operands?

Example, "<=" and "<=" operators :

  • allowed for operands of type "cds.Integer" | "cds.Integer64" | "cds.Decimal" | "cds.Double" | "cds.Date" | "cds.Time" | "cds.DateTime" | "cds.Timestamp" ?
  • but forbidden for operands of type "cds.Boolean" | "cds.String" | "cds.LargeString" | "cds.UUID"?
  1. Who does the check if the two operands are of the same type and it makes sense to combine them via an operator sign?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Yes, I'm pretty sure this is the case, and we need to spell this out somewhere. Maybe we should create a section in the Primer or somewhere else and link to it from the interface docu. We may even have a "sub-specification" here, where we need to explain how "on" condition queries work.

  2. @stewsk - do you know if this is something CAP compiler checks? It would be possible to check via the metadata validator, but writing that validation code will be a bit more involved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Fannon , CAP doesn't apply any restrictions on the ON condition. Any kind of condition (all operators, all types) are allowed. Accordingly, we don't have any such checks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if an operator is not known / supported by CAP or another consumer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CAP doesn't care.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But wouldn't this on condition need to be resolved, in the case of an association even as a foreign key?

Maybe the example added here is a bit confusing. An "on" condition of an association or composition probably always need to return exactly one match? Its a different use case compared to a view where we want to query / select multiple results. Here comparator operations like >= make more sense to me, but we don't have Views / Queries like that in CSN Interop.

- [
{ "ref": ["to_Connection", "AirlineID"] },
"=",
Expand Down Expand Up @@ -1426,14 +1430,28 @@ definitions:
title: Equals Operator
type: string
description: |-
The operator "="
The operator `=`
const: "="

SmallerEqualsOperator:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use smaller or bigger equals operators, the cardinality of the "on" condition has to be "to many".

We need to define for which data types a comparator like this is valid and how comparison works. So far we seem to only need it for date (time dependent references / queries)

title: Smaller Equals Operator
type: string
description: |-
The operator `<=`
const: "<="

BiggerEqualsOperator:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BiggerEqualsOperator:
GreaterEqualsOperator:

title: Bigger Equals Operator
type: string
description: |-
The operator `>=`
const: ">="

AndOperator:
title: AND Operator
type: string
description: |-
The operator "and"
The operator `and`
const: "and"

OnValue:
Expand Down
160 changes: 154 additions & 6 deletions src/generated/spec-v1/schemas/csn-interop-effective.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3231,7 +3231,7 @@
},
"on": {
"type": "array",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator \"=\"\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator `=` or Smaller Equals Operator `<=` or Bigger Equals Operator `>=`\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=`, `<=` or `>=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"items": {
"oneOf": [
{
Expand All @@ -3240,6 +3240,12 @@
{
"$ref": "#/definitions/EqualsOperator"
},
{
"$ref": "#/definitions/SmallerEqualsOperator"
},
{
"$ref": "#/definitions/BiggerEqualsOperator"
},
{
"$ref": "#/definitions/AndOperator"
},
Expand All @@ -3264,6 +3270,34 @@
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
"<=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
">=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
Expand Down Expand Up @@ -3534,7 +3568,7 @@
},
"on": {
"type": "array",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator \"=\"\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator `=` or Smaller Equals Operator `<=` or Bigger Equals Operator `>=`\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=`, `<=` or `>=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"items": {
"oneOf": [
{
Expand All @@ -3543,6 +3577,12 @@
{
"$ref": "#/definitions/EqualsOperator"
},
{
"$ref": "#/definitions/SmallerEqualsOperator"
},
{
"$ref": "#/definitions/BiggerEqualsOperator"
},
{
"$ref": "#/definitions/AndOperator"
},
Expand All @@ -3567,6 +3607,34 @@
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
"<=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
">=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
Expand Down Expand Up @@ -4256,13 +4324,25 @@
"EqualsOperator": {
"title": "Equals Operator",
"type": "string",
"description": "The operator \"=\"",
"description": "The operator `=`",
"const": "="
},
"SmallerEqualsOperator": {
"title": "Smaller Equals Operator",
"type": "string",
"description": "The operator `<=`",
"const": "<="
},
"BiggerEqualsOperator": {
"title": "Bigger Equals Operator",
"type": "string",
"description": "The operator `>=`",
"const": ">="
},
"AndOperator": {
"title": "AND Operator",
"type": "string",
"description": "The operator \"and\"",
"description": "The operator `and`",
"const": "and"
},
"OnValue": {
Expand Down Expand Up @@ -7179,7 +7259,7 @@
},
"on": {
"type": "array",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator \"=\"\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator `=` or Smaller Equals Operator `<=` or Bigger Equals Operator `>=`\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=`, `<=` or `>=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"items": {
"oneOf": [
{
Expand All @@ -7188,6 +7268,12 @@
{
"$ref": "#/definitions/EqualsOperator"
},
{
"$ref": "#/definitions/SmallerEqualsOperator"
},
{
"$ref": "#/definitions/BiggerEqualsOperator"
},
{
"$ref": "#/definitions/AndOperator"
},
Expand All @@ -7212,6 +7298,34 @@
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
"<=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
">=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
Expand Down Expand Up @@ -7487,7 +7601,7 @@
},
"on": {
"type": "array",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator \"=\"\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"description": "The property `on` holds a sequence of operators and operands to describe the join condition, similar to an SQL expression.\n\nThe `on` condition is constructed by triples of:\n- Reference to the target element (ID) as array with 2 items\n- Equals Operator `=` or Smaller Equals Operator `<=` or Bigger Equals Operator `>=`\n- Reference to the local element (ID) as array with 1 item OR a constant value (`val`)\n\nThe first and third entry MAY be reversed but the `=`, `<=` or `>=` operator MUST be in the middle.\nThe target element reference MUST have two array items. The first item is the association name and the second item is the target element name.\nThe local element reference MUST have one array item, which is the local element name.\n\nIn case of composite references / IDs, any number of \"triples\" can be combined with the `and` operator in between.\n\nSee also: (../primer.md#on-condition) and [CAP documentation](https://cap.cloud.sap/docs/cds/csn#assoc-on).",
"items": {
"oneOf": [
{
Expand All @@ -7496,6 +7610,12 @@
{
"$ref": "#/definitions/EqualsOperator"
},
{
"$ref": "#/definitions/SmallerEqualsOperator"
},
{
"$ref": "#/definitions/BiggerEqualsOperator"
},
{
"$ref": "#/definitions/AndOperator"
},
Expand All @@ -7520,6 +7640,34 @@
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
"<=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
"to_Connection",
"FlightDate"
]
},
">=",
{
"ref": [
"FlightDate"
]
}
],
[
{
"ref": [
Expand Down
Loading