Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 1.47 KB

sql-cast-suggestion.md

File metadata and controls

50 lines (38 loc) · 1.47 KB
outline breadcrumbs status
2
2
CDS Lint - Rules Reference
released
<script setup> import PlaygroundBadge from '../components/PlaygroundBadge.vue' </script>

sql-cast-suggestion

Rule Details

With compiler v2, appending a type declaration to a column expression in a view's query doesn't generate a cast in SQL anymore, as that created conflicts with various database-specific behaviors. This rule ensures that such casts are added explicitly by suggesting possible missing SQL casts.

Examples

✅   Correct example

In the following example, the entity ListOfBooks contains explicit casts for elements name2 and name3, so the rule will not be triggered for these elements:

::: code-group <<< ../examples/sql-cast-suggestion/correct/db/schema.cds#snippet{ts:line-numbers} [db/schema.cds] :::

❌   Incorrect example

In the next example, the rule will be triggered for elements name1 and name2 because they require explicit casts:

::: code-group <<< ../examples/sql-cast-suggestion/incorrect/db/schema.cds#snippet{ts:line-numbers} [db/schema.cds] :::

Version

This rule was introduced in @sap/eslint-plugin-cds 1.0.8.