mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +02:00
Co-authored-by: Fabian-Lars <github@fabianlars.de>
This commit is contained in:
@@ -29,10 +29,11 @@ tauri = { workspace = true }
|
||||
log = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
futures-core = "0.3"
|
||||
sqlx = { version = "0.8", features = ["json", "time"] }
|
||||
sqlx = { version = "0.8", features = ["json", "time", "uuid"] }
|
||||
time = "0.3"
|
||||
tokio = { version = "1", features = ["sync"] }
|
||||
indexmap = { version = "2", features = ["serde"] }
|
||||
uuid = "1"
|
||||
|
||||
[features]
|
||||
sqlite = ["sqlx/sqlite", "sqlx/runtime-tokio"]
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
use serde_json::Value as JsonValue;
|
||||
use sqlx::{postgres::PgValueRef, TypeInfo, Value, ValueRef};
|
||||
use time::{Date, OffsetDateTime, PrimitiveDateTime, Time};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::Error;
|
||||
|
||||
@@ -14,13 +15,20 @@ pub(crate) fn to_json(v: PgValueRef) -> Result<JsonValue, Error> {
|
||||
}
|
||||
|
||||
let res = match v.type_info().name() {
|
||||
"CHAR" | "VARCHAR" | "TEXT" | "NAME" | "UUID" => {
|
||||
"CHAR" | "VARCHAR" | "TEXT" | "NAME" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode() {
|
||||
JsonValue::String(v)
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"UUID" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<Uuid>() {
|
||||
JsonValue::String(v.to_string())
|
||||
} else {
|
||||
JsonValue::Null
|
||||
}
|
||||
}
|
||||
"FLOAT4" => {
|
||||
if let Ok(v) = ValueRef::to_owned(&v).try_decode::<f32>() {
|
||||
JsonValue::from(v)
|
||||
|
||||
Reference in New Issue
Block a user