Skip to content

Commit

Permalink
Merge 'Fix wrong count() result if the column specified contains a NU…
Browse files Browse the repository at this point in the history
…LL' from lgualtieri75

Fixes #1064

Closes #1065
  • Loading branch information
penberg committed Feb 28, 2025
2 parents 672fe06 + cf407f6 commit c5095e8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/vdbe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,7 @@ impl Program {
*acc += col;
}
AggFunc::Count | AggFunc::Count0 => {
let col = state.registers[*col].clone();
if matches!(&state.registers[*acc_reg], OwnedValue::Null) {
state.registers[*acc_reg] = OwnedValue::Agg(Box::new(
AggContext::Count(OwnedValue::Integer(0)),
Expand All @@ -1734,7 +1735,12 @@ impl Program {
let AggContext::Count(count) = agg.borrow_mut() else {
unreachable!();
};
*count += 1;

if (matches!(func, AggFunc::Count) && matches!(col, OwnedValue::Null))
== false
{
*count += 1;
};
}
AggFunc::Max => {
let col = state.registers[*col].clone();
Expand Down

0 comments on commit c5095e8

Please sign in to comment.