Skip to content

Commit

Permalink
Fix negated introduced:x search
Browse files Browse the repository at this point in the history
1. Add outer brackets.
2. Coalesce aggregate, because `null and true` is `null` in SQL land,
so cards that were not introduced, but manually rescheduled in the
period of interest, would not show up in a negated search.
  • Loading branch information
RumovZ committed Jan 9, 2023
1 parent cef672a commit c11697e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rslib/src/search/sqlwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,11 @@ impl SqlWriter<'_> {
write!(
self.sql,
concat!(
"(SELECT min(id) > {cutoff} FROM revlog WHERE cid = c.id ",
"((SELECT coalesce(min(id) > {cutoff}, false) FROM revlog WHERE cid = c.id ",
// Exclude manual reschedulings
"AND ease != 0) ",
// Logically redundant, speeds up query
"AND c.id IN (SELECT cid FROM revlog WHERE id > {cutoff})"
"AND c.id IN (SELECT cid FROM revlog WHERE id > {cutoff}))"
),
cutoff = cutoff,
)
Expand Down Expand Up @@ -785,8 +785,8 @@ mod test {
s(ctx, "introduced:3").0,
format!(
concat!(
"((SELECT min(id) > {cutoff} FROM revlog WHERE cid = c.id AND ease != 0) ",
"AND c.id IN (SELECT cid FROM revlog WHERE id > {cutoff}))"
"(((SELECT coalesce(min(id) > {cutoff}, false) FROM revlog WHERE cid = c.id AND ease != 0) ",
"AND c.id IN (SELECT cid FROM revlog WHERE id > {cutoff})))"
),
cutoff = (timing.next_day_at.0 - (86_400 * 3)) * 1_000,
)
Expand Down

0 comments on commit c11697e

Please sign in to comment.