diff --git a/Cargo.lock b/Cargo.lock index de9b516..510e8b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,6 +641,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + [[package]] name = "html-escape" version = "0.2.13" @@ -1705,6 +1711,7 @@ dependencies = [ "console_log", "floating-ui", "fragile", + "hex", "istyles", "js-sys", "leptos", diff --git a/Cargo.toml b/Cargo.toml index df14416..1765773 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,3 +36,4 @@ wasm-bindgen-futures = "0.4.50" console_log = "1.0.0" log = "0.4.27" fragile = "2.0.1" +hex = "0.4.3" diff --git a/src/app/output/execute.rs b/src/app/output/execute.rs index 17bf53b..0e878fb 100644 --- a/src/app/output/execute.rs +++ b/src/app/output/execute.rs @@ -19,7 +19,10 @@ fn get_output(table: &SQLiteStatementTable) -> Option { }; Some( view! { - +
{values .columns diff --git a/src/app/output/section.rs b/src/app/output/section.rs index 290f2f6..c9ef169 100644 --- a/src/app/output/section.rs +++ b/src/app/output/section.rs @@ -13,9 +13,7 @@ pub fn Section(label: String, children: Children) -> impl IntoView { view! {
-
-                {children()}
-            
+ {children()}
} } diff --git a/src/lib.rs b/src/lib.rs index 06b0112..addd75c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ use app::{GlobalState, GlobalStateStoreFields}; use fragile::Fragile; use leptos::prelude::*; use reactive_stores::Store; -use serde_json::Value as JsonValue; use std::{ ops::{Deref, DerefMut}, sync::Arc, @@ -152,7 +151,7 @@ pub struct SQLiteStatementTable { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SQLiteStatementValues { pub columns: Vec, - pub rows: Vec>, + pub rows: Vec>, } #[derive(thiserror::Error, Debug, Serialize, Deserialize)] diff --git a/src/worker/sqlitend.rs b/src/worker/sqlitend.rs index d8287c5..8677535 100644 --- a/src/worker/sqlitend.rs +++ b/src/worker/sqlitend.rs @@ -1,4 +1,3 @@ -use serde_json::Value as JsonValue; use sqlite_wasm_rs::*; use std::ffi::{CStr, CString}; use std::sync::Arc; @@ -215,12 +214,12 @@ impl SQLitePreparedStatement { // https://www.sqlite.org/c3ref/column_blob.html let value = unsafe { match column_type { - SQLITE_NULL => JsonValue::Null, + SQLITE_NULL => "Null".to_string(), SQLITE_INTEGER => { let number = sqlite3_column_int64(self.stmt, col_ndx); - JsonValue::from(number) + number.to_string() } - SQLITE_FLOAT => JsonValue::from(sqlite3_column_double(self.stmt, col_ndx)), + SQLITE_FLOAT => sqlite3_column_double(self.stmt, col_ndx).to_string(), SQLITE_TEXT => { let slice = { let text = sqlite3_column_text(self.stmt, col_ndx); @@ -232,7 +231,7 @@ impl SQLitePreparedStatement { let Ok(text) = std::str::from_utf8(slice) else { return Err(SQLitendError::Utf8Text); }; - JsonValue::from(text) + format!("{text:?}") } SQLITE_BLOB => { let slice = { @@ -240,7 +239,8 @@ impl SQLitePreparedStatement { let len = sqlite3_column_bytes(self.stmt, col_ndx); std::slice::from_raw_parts(blob.cast::(), len as usize) }; - JsonValue::from(slice) + let hex = hex::encode(slice); + format!("x'{hex}'") } _ => return Err(SQLitendError::UnsupportColumnType(column_type)), }