From 62e8da689d359c080831216b84b7717d7912154a Mon Sep 17 00:00:00 2001 From: Greg Heartsfield Date: Fri, 6 Jan 2023 12:57:48 -0600 Subject: [PATCH] fix: do not force kind_created_at_index when there are tags --- src/db.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/db.rs b/src/db.rs index 70f21cb..27b5b55 100644 --- a/src/db.rs +++ b/src/db.rs @@ -510,6 +510,7 @@ fn override_index(f: &ReqFilter) -> Option { ks.len() > 1 && f.since.is_none() && f.until.is_none() && + f.tags.is_none() && f.authors.is_none() { return Some("kind_created_at_index".into()); } @@ -529,15 +530,12 @@ fn query_from_filter(f: &ReqFilter) -> (String, Vec>, Option> = vec![]; - return (empty_query, empty_params); + return (empty_query, empty_params, None); } // check if the index needs to be overriden let idx_name = override_index(&f); - if let Some(n) = &idx_name { - debug!("using explicit index: {:?}", n); - } - let idx_stmt = idx_name.map_or_else(|| "".to_owned(), |i| format!("INDEXED BY {}",i)); + let idx_stmt = idx_name.as_ref().map_or_else(|| "".to_owned(), |i| format!("INDEXED BY {}",i)); let mut query = format!("SELECT e.content, e.created_at FROM event e {}", idx_stmt); // query parameters for SQLite let mut params: Vec> = vec![]; @@ -680,7 +678,7 @@ fn query_from_sub(sub: &Subscription) -> (String, Vec>, Vec = Vec::new(); - let indexes = vec![]; + let mut indexes = vec![]; // subquery params let mut params: Vec> = vec![]; // for every filter in the subscription, generate a subquery