I have this sql query:
ALTER TABLE outfit
ADD CONSTRAINT check_non_empty_string CHECK (image_uri <> '');
This works good but SonarCloud raised this as a bug. I am using PostgreSQL 13.2, is there a better way of writing this query or can I safely ignore this error in SonarCloud?
Use IS NULL and IS NOT NULL instead of direct NULL comparisons.
In a Zen-like manner, "NULL" is never equal to anything, even itself. Therefore comparisons using equality operators will always return False, even when the value actually IS NULL.
For that reason, comparison operators should never be used to make comparisons with NULL; IS NULL and IS NOT NULL should be used instead. This extends as well to empty string (""), which is equivalent to NULL for some database engines.