aboutsummaryrefslogtreecommitdiff
path: root/database/src/query_ser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'database/src/query_ser.rs')
-rw-r--r--database/src/query_ser.rs21
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:?}"),
+ }
}