fix: include empty or null values#4124
Conversation
|
@ElfenB is attempting to deploy a commit to the Umami Software Team on Vercel. A member of the Team first needs to authorize it. |
Greptile SummaryThis PR fixes filter queries in both the ClickHouse and Prisma (PostgreSQL) database layers so that rows with absent/empty values are correctly included when applying negative filter operators ( Key changes:
Minor concern: In ClickHouse, if a user ever provides an empty string Confidence Score: 5/5Safe to merge — both fixes are logically correct for their respective databases and address the reported bug. The Prisma fix is straightforward and correct: adding OR IS NULL is the standard SQL pattern for including NULL rows in negative comparisons. The ClickHouse fix correctly uses OR = '' to match the non-nullable String column design. The only remaining concern (tautology when filtering by empty string in ClickHouse) is a P2 edge case that does not affect normal usage. No files require special attention, though src/lib/clickhouse.ts has a minor edge-case noted above. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[mapFilter called] --> B{operator}
B --> |equals| C["column = value"]
B --> |notEquals - Prisma| D["(column != value OR column IS NULL)"]
B --> |notEquals - ClickHouse| E["(column != value OR column = '')"]
B --> |contains| F["column ilike value / positionCaseInsensitive > 0"]
B --> |doesNotContain - Prisma| G["(column NOT ilike value OR column IS NULL)"]
B --> |doesNotContain - ClickHouse| H["positionCaseInsensitive = 0"]
note1["ClickHouse String columns are non-nullable\n→ empty string '' is the 'no value' sentinel\n→ positionCaseInsensitive('', v) = 0 already TRUE\n so doesNotContain needs no fix"]
note2["Postgres columns are nullable\n→ NULL rows silently dropped by != and NOT ILIKE\n→ OR IS NULL fix required for both operators"]
E -.-> note1
D -.-> note2
G -.-> note2
Reviews (1): Last reviewed commit: "fix: include empty or null values" | Re-trigger Greptile |
| return `${column} = ${value}`; | ||
| case OPERATORS.notEquals: | ||
| return `${column} != ${value}`; | ||
| return `(${column} != ${value} OR ${column} = '')`; |
There was a problem hiding this comment.
Tautology when filtering by empty string
The guard OR ${column} = '' is the ClickHouse equivalent of IS NULL for Postgres, but it introduces a tautology when the filter value itself is an empty string ''. In that case the generated SQL becomes:
(column != '' OR column = '')which is always TRUE for every row — so a "not equals empty-string" filter would return the entire dataset instead of excluding nothing. In practice users are unlikely to filter on an exact empty-string value, but it is worth being aware of this edge case. The Prisma fix avoids this because IS NULL only catches NULL, not the '' value itself.
fixes #4123