Skip to content
Merged
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
8 changes: 7 additions & 1 deletion cds/cdl.md
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ entity P_Authors as projection on Authors {
In this example, in addition to `books` projection `P_Authors` has a new association `availableBooks`
that points only to those books where `stock > 0`.

If the filter condition effectively reduces the cardinality of the association
If the filter condition effectively reduces the cardinality of the association (or composition)
to one, you should make this explicit in the filter by adding a `1:` before the condition:

```cds
Expand All @@ -1164,6 +1164,12 @@ entity P_Employees as projection on Employees {
}
```

::: warning `:1` doesn't itself reduce the cardinality
The `:1` syntax itself has no effect on the cardinality. It is only an information by the developer
that the specified condition reduces the cardinality of the association or composition to one.
:::


Filters usually are provided only for to-many associations, which usually are unmanaged.
Thus publishing with a filter is almost exclusively used for unmanaged associations.
Nevertheless you can also publish a managed association with a filter. This will automatically
Expand Down
5 changes: 5 additions & 0 deletions cds/cql.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ If an infix filter effectively reduces the cardinality of a *to-many* associatio
SELECT name, books[1: favorite=true].title from Authors
```

::: warning `:1` has no effect on result set
The `:1` syntax in the filter has no effect on the result. It is only an information by the developer
that the specified condition reduces the result to a single entry.
:::

### Exists Predicate

Use a filtered path expression to test if any element of the associated collection matches the given filter:
Expand Down
Loading