diff --git a/src/main.rs b/src/main.rs index 27d7243..6851a71 100644 --- a/src/main.rs +++ b/src/main.rs @@ -342,7 +342,7 @@ mod sqlite { Ok(responses::Overview { file_name, - sqlite_version, + sqlite_version: Some(sqlite_version), file_size, created, modified, @@ -443,7 +443,7 @@ mod sqlite { Ok(responses::Table { name, - sql, + sql: Some(sql), row_count, table_size, index_count, @@ -689,7 +689,7 @@ mod libsql { Ok(responses::Overview { file_name, - sqlite_version, + sqlite_version: Some(sqlite_version), file_size, created, modified, @@ -816,7 +816,7 @@ mod libsql { Ok(responses::Table { name, - sql, + sql: Some(sql), row_count, table_size, index_count, @@ -996,7 +996,6 @@ mod postgres { .await? .get(0); - let sqlite_version = "---".to_owned(); let file_size: i64 = self .client .query_one("SELECT pg_database_size($1)", &[&file_name]) @@ -1082,7 +1081,7 @@ mod postgres { Ok(responses::Overview { file_name, - sqlite_version, + sqlite_version: None, file_size, created, modified, @@ -1119,8 +1118,6 @@ mod postgres { } async fn table(&self, name: String) -> color_eyre::Result { - let sql = "".to_owned(); - let row_count: i64 = self .client .query_one(&format!(r#"SELECT count(*) FROM "{name}""#), &[]) @@ -1163,7 +1160,7 @@ mod postgres { Ok(responses::Table { name, - sql, + sql: None, row_count: row_count as i32, table_size, index_count: index_count as i32, @@ -1316,8 +1313,8 @@ mod responses { #[derive(Serialize)] pub struct Overview { pub file_name: String, - pub sqlite_version: String, pub file_size: String, + pub sqlite_version: Option, pub created: Option>, pub modified: Option>, pub tables: i32, @@ -1341,7 +1338,7 @@ mod responses { #[derive(Serialize)] pub struct Table { pub name: String, - pub sql: String, + pub sql: Option, pub row_count: i32, pub index_count: i32, pub column_count: i32, diff --git a/ui/src/api.ts b/ui/src/api.ts index 7505b41..d7b7255 100644 --- a/ui/src/api.ts +++ b/ui/src/api.ts @@ -5,7 +5,7 @@ const BASE_URL = import.meta.env.PROD ? "/api" : "http://localhost:3030/api"; const overview = z.object({ file_name: z.string(), - sqlite_version: z.string(), + sqlite_version: z.string().nullable(), file_size: z.string(), created: z .string() @@ -40,7 +40,7 @@ const tables = z.object({ const table = z.object({ name: z.string(), - sql: z.string(), + sql: z.string().nullable(), row_count: z.number(), index_count: z.number(), column_count: z.number(), diff --git a/ui/src/routes/index.lazy.tsx b/ui/src/routes/index.lazy.tsx index a8634ce..83e1b88 100644 --- a/ui/src/routes/index.lazy.tsx +++ b/ui/src/routes/index.lazy.tsx @@ -134,17 +134,19 @@ function Index() { {data.file_size} - - -
SQLite version
-
- The SQLite version the DB was created with. -
-
- - {data.sqlite_version} - -
+ {data.sqlite_version && ( + + +
SQLite version
+
+ The SQLite version the DB was created with. +
+
+ + {data.sqlite_version} + +
+ )} {data.created && ( diff --git a/ui/src/routes/tables.lazy.tsx b/ui/src/routes/tables.lazy.tsx index 916cd86..d2ae790 100644 --- a/ui/src/routes/tables.lazy.tsx +++ b/ui/src/routes/tables.lazy.tsx @@ -134,20 +134,22 @@ function Table({ name }: Props) { - - - + {data.sql && ( + + + + )}