mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-02 06:27:53 -06:00
Match library search date: token case-insensitively
Found while testing crates/catalog/src/query.rs:178 (token_matches, the "date" branch at :215) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
c4fd54e0a6
commit
9d4f33a77c
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user