Skip to content
Open
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
5 changes: 4 additions & 1 deletion guides/databases/cql-to-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ SELECT from Books where genre.name != 'Science Fiction';

The result set includes all books where genre is not 'Science Fiction', including the ones with an unspecified genre. In contrast, using SQL's `<>` operator, the ones with unspecified genre would be excluded.

The CQL behavior is consistent with common programming languages like JavaScript and Java, as well as with OData semantics. It is implemented in database by, the translation of `!=` to `IS NOT` in SQLite, or to `IS DISTINCT FROM` in standard SQL, and to an equivalent polyfill in SAP HANA.
The CQL behavior is consistent with common programming languages like JavaScript and Java, and with OData semantics. The runtime implements this by translating `!=` to `IS DISTINCT FROM` in standard SQL databases (PostgreSQL, H2), and to equivalent polyfills using `CASE` expressions in SAP HANA and SQLite.

> [!tip] Prefer == and !=
> Prefer using `==` and `!=` in most cases to avoid unexpected `null` results. Only use `=` and `<>` if you _really_ want SQL's three-valued logic behavior.
Expand Down Expand Up @@ -83,6 +83,9 @@ The compiler translates this operator to the best-possible equivalent in the tar

Following are portable functions supported by CAP. You can safely use these in CDS view definitions and runtime queries expressed in CQL. The compiler translates them to the best-possible database-specific native SQL equivalents.

> [!note] Database-Specific Behavior
> While CAP aims for consistent behavior, some functions may exhibit subtle differences across databases due to underlying SQL dialect variations. Test critical functionality on your target database.

String functions:

- `concat(x,y,...)`
Expand Down
14 changes: 14 additions & 0 deletions guides/databases/initial-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,21 @@ Common rules apply to text content in `.csv` files, like:
| Numeric content should be treated as texts | -> enclose in double quotes |
| Boolean values should be treated as text | -> enclose in double quotes |

## Data Loading Order

CAP loads CSV files in **alphabetical order by filename**. When tables have foreign key relationships, ensure parent tables load before child tables to avoid constraint violations.

**Example:**
```
db/data/
├── sap.capire.bookshop-Authors.csv # Loads first (parent)
└── sap.capire.bookshop-Books.csv # Loads second (references Authors)
```

The filename prefix ensures correct order: `Authors` loads before `Books` alphabetically. If you encounter foreign key violations, verify your file naming follows dependency order.

> [!tip] Large Datasets
> For datasets with thousands of rows, consider using database-specific bulk loading tools instead of CSV files. The CSV mechanism loads all data in a single transaction, which can cause memory issues and long startup times.
Comment on lines +84 to +98
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another proposal by AI. I don't think that this is true, but how is the actual behavior?


## Initial vs Test Data

Expand Down
Loading