feat(objects): default filter to tables and align context menu with sidebar (#416)
Object browser now defaults to showing tables when tables exist. Table/view context menus match sidebar tree with structure editing, export, import, diagram, data compare, truncate, empty, duplicate, and copy name support.
This commit is contained in:
1 parent
c2a13f3057
commit
51662c692f
2 files changed
+472
-11
No files matched your search
@@ -90,6 +90,28 @@ fn mysql_datetime_to_string(value: DateTime<Utc>) -> String {
|
||||
value.naive_utc().to_string()
|
||||
}
|
||||
|
||||
fn is_mysql_lossless_integer_type(type_name: &str) -> bool {
|
||||
let upper_type = type_name.to_uppercase();
|
||||
upper_type.contains("BIGINT") || upper_type.contains("LARGEINT")
|
||||
}
|
||||
|
||||
fn mysql_lossless_integer_to_json(row: &MySqlRow, idx: usize) -> serde_json::Value {
|
||||
row.try_get::<String, _>(idx)
|
||||
.map(serde_json::Value::String)
|
||||
.or_else(|_| row.try_get::<Decimal, _>(idx).map(|v: Decimal| serde_json::Value::String(v.to_string())))
|
||||
.or_else(|_| row.try_get::<i64, _>(idx).map(|v| serde_json::Value::String(v.to_string())))
|
||||
.or_else(|_| row.try_get::<u64, _>(idx).map(|v| serde_json::Value::String(v.to_string())))
|
||||
.or_else(|_| {
|
||||
row.try_get::<Vec<u8>, _>(idx).map(|b| serde_json::Value::String(String::from_utf8_lossy(&b).to_string()))
|
||||
})
|
||||
.or_else(|_| row.try_get_unchecked::<String, _>(idx).map(serde_json::Value::String))
|
||||
.or_else(|_| {
|
||||
row.try_get_unchecked::<Vec<u8>, _>(idx)
|
||||
.map(|b| serde_json::Value::String(String::from_utf8_lossy(&b).to_string()))
|
||||
})
|
||||
.unwrap_or(serde_json::Value::Null)
|
||||
}
|
||||
|
||||
fn mysql_value_to_json(row: &MySqlRow, idx: usize, type_name: &str) -> serde_json::Value {
|
||||
if row.try_get_raw(idx).map(|v| v.is_null()).unwrap_or(true) {
|
||||
return serde_json::Value::Null;
|
||||
@@ -116,12 +138,8 @@ fn mysql_value_to_json(row: &MySqlRow, idx: usize, type_name: &str) -> serde_jso
|
||||
.unwrap_or(serde_json::Value::Null);
|
||||
}
|
||||
|
||||
if upper_type.contains("BIGINT") {
|
||||
return row
|
||||
.try_get::<i64, _>(idx)
|
||||
.map(|v| serde_json::Value::String(v.to_string()))
|
||||
.or_else(|_| row.try_get::<u64, _>(idx).map(|v| serde_json::Value::String(v.to_string())))
|
||||
.unwrap_or(serde_json::Value::Null);
|
||||
if is_mysql_lossless_integer_type(&upper_type) {
|
||||
return mysql_lossless_integer_to_json(row, idx);
|
||||
}
|
||||
|
||||
if upper_type == "DECIMAL" {
|
||||
@@ -678,6 +696,11 @@ mod tests {
|
||||
assert!(sql.contains("c.COLUMN_KEY"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mysql_largeint_uses_lossless_integer_decoding() {
|
||||
assert!(is_mysql_lossless_integer_type("LARGEINT"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mysql_column_key_marks_primary_when_key_column_usage_is_unavailable() {
|
||||
let primary_key_columns = HashSet::new();
|
||||
|
||||
Reference in new issue
Block a user