From 3aace2da2f60e6f0be4cf62e06a453e61bf4f5f4 Mon Sep 17 00:00:00 2001 From: Kirk Rodrigues <2454684+kirkrodrigues@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:34:03 -0400 Subject: [PATCH] Bug-fix: Undo logic error in how database timestamp filtering criteria was set (fixes #69). --- components/core/src/streaming_archive/MetadataDB.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/core/src/streaming_archive/MetadataDB.cpp b/components/core/src/streaming_archive/MetadataDB.cpp index d1fa06e26..0205a890d 100644 --- a/components/core/src/streaming_archive/MetadataDB.cpp +++ b/components/core/src/streaming_archive/MetadataDB.cpp @@ -128,12 +128,18 @@ namespace streaming_archive { // Add clauses bool clause_exists = false; if (cEpochTimeMin != ts_begin) { - fmt::format_to(statement_buffer_ix, " WHERE {} >= ?{}", streaming_archive::cMetadataDB::File::BeginTimestamp, + // If the end-timestamp of the file is less than the given begin- + // timestamp, messages within the file are guaranteed to be outside + // the timestamp range. So this filters for the opposite. + fmt::format_to(statement_buffer_ix, " WHERE {} >= ?{}", streaming_archive::cMetadataDB::File::EndTimestamp, enum_to_underlying_type(FilesTableFieldIndexes::BeginTimestamp) + 1); clause_exists = true; } if (cEpochTimeMax != ts_end) { - fmt::format_to(statement_buffer_ix, " {} {} <= ?{}", clause_exists ? "AND" : "WHERE", streaming_archive::cMetadataDB::File::EndTimestamp, + // If the begin-timestamp of the file is greater than the given end- + // timestamp, messages within the file are guaranteed to be outside + // the timestamp range. So this filters for the opposite. + fmt::format_to(statement_buffer_ix, " {} {} <= ?{}", clause_exists ? "AND" : "WHERE", streaming_archive::cMetadataDB::File::BeginTimestamp, enum_to_underlying_type(FilesTableFieldIndexes::EndTimestamp) + 1); clause_exists = true; }