sql-null-comparison
Rule Details
Comparing values against null in views is a common pitfall in SQL. This rule helps find places where incorrect SQL comparisons are used and proposes using IS NULL or IS NOT NULL instead.
Examples
✅ Correct example
In the following example, the rule is satisfied because null comparison is valid:
cds
using { sap.capire.bookshop as my } from '../db/schema';
service CatalogService {
entity Books as projection on my.Books { * }
where title IS NOT NULL;
}1
2
3
4
5
6
2
3
4
5
6
❌ Incorrect example
This example shows the rule reporting a warning because the comparison = null is not correct:
cds
using { sap.capire.bookshop as my } from '../db/schema';
service CatalogService {
entity Books as projection on my.Books { * }
where title != NULL;
}1
2
3
4
5
6
2
3
4
5
6
Version
This rule was introduced in @sap/eslint-plugin-cds 3.1.0.