diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-18 13:24:44 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-18 13:24:44 +0100 |
| commit | 3bbedf5ab337d8c6d608ed0b24b9c656b0ee1004 (patch) | |
| tree | bf0cda90ed493af37569a7b3f27374decfcddb10 /database/src/query_ser.rs | |
| parent | b176a9f7c36bf26f0e42d8b1bc30e214de9f14c9 (diff) | |
| download | jellything-3bbedf5ab337d8c6d608ed0b24b9c656b0ee1004.tar jellything-3bbedf5ab337d8c6d608ed0b24b9c656b0ee1004.tar.bz2 jellything-3bbedf5ab337d8c6d608ed0b24b9c656b0ee1004.tar.zst | |
dynamic typed db match values
Diffstat (limited to 'database/src/query_ser.rs')
| -rw-r--r-- | database/src/query_ser.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/database/src/query_ser.rs b/database/src/query_ser.rs index d76dea7..de62a72 100644 --- a/database/src/query_ser.rs +++ b/database/src/query_ser.rs @@ -4,8 +4,8 @@ Copyright (C) 2026 metamuffin <metamuffin.org> */ -use crate::{Filter, MultiBehaviour, Query, Sort, SortOrder}; -use jellyobject::{Path, Tag}; +use crate::{Filter, MultiBehaviour, Query, Sort, SortOrder, Value}; +use jellyobject::Path; impl Query { pub fn show(&self) -> String { @@ -40,11 +40,7 @@ impl Filter { .join(" OR ") ), Filter::Match(path, value) => { - format!( - "{} = {}", - show_path(path), - show_value(*path.0.last().unwrap(), value) - ) + format!("{} = {}", show_path(path), show_value(value)) } Filter::Has(path) => show_path(path), } @@ -85,6 +81,13 @@ fn show_path(path: &Path) -> String { .collect::<Vec<_>>() .join(".") } -fn show_value(_tag: Tag, value: &[u8]) -> String { - format!("{value:?}") // TODO +fn show_value(value: &Value) -> String { + match value { + Value::Tag(tag) => format!("{tag}"), + Value::U32(x) => format!("{x}"), + Value::U64(x) => format!("{x}"), + Value::I64(x) => format!("{x}"), + Value::String(x) => format!("{x:?}"), + Value::Binary(x) => format!("{x:?}"), + } } |