This commit is contained in:
Brandon Thomas
2026-11-01 22:06:44 -05:00
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -226,7 +226,7 @@ fn token_matches(p: &Photo, tok: &str) -> bool {
"person" | "who" => has_person(p, val),
"type" | "kind" => format!("{:?}", p.kind).eq_ignore_ascii_case(val),
"edited" => (val == "true" || val == "yes") == p.is_edited(),
"date" => p.captured.as_deref().is_some_and(|c| c.starts_with(val)),
"date" => p.captured.as_deref().is_some_and(|c| c.get(..val.len()).is_some_and(|h| h.eq_ignore_ascii_case(val))),
"copy" | "virtual" => (val == "true" || val == "yes") == p.copy_of.is_some(),
"name" | "file" => p.file_name.to_lowercase().contains(val),
// Not a known field: the colon is part of a plain word ("10:30", "Re:"), its value unquoted
+11
View File
@@ -12,6 +12,17 @@ fn photo(c: &mut Catalog, name: &str, date: &str) -> PhotoId {
id
}
#[test]
fn date_token_matches_time_part_case_insensitively() {
let mut c = Catalog::new();
let a = photo(&mut c, "a.jpg", "2026-05-01T10:00:00");
let q = |c: &Catalog, text: &str| c.query(&Filter { text: text.into(), ..Default::default() }, &Sort::default());
assert_eq!(q(&c, "date:2026-05-01T10"), vec![a]);
assert_eq!(q(&c, "date:2026-05-01t10"), vec![a]);
assert_eq!(q(&c, "date:2026-05"), vec![a]);
assert!(q(&c, "date:2026-05-01T11").is_empty());
}
#[test]
fn apply_and_inverse_roundtrip() {
let mut c = Catalog::new();