fix(mysql): parse geometry WKB to WKT for display and editing
This commit is contained in:
1 parent
3695042c8e
commit
63bb6a21ca
5 files changed
+362
-308
No files matched your search
@@ -801,6 +801,13 @@ pub fn format_grid_sql_literal(
|
||||
if text.is_empty() {
|
||||
return if database_type == Some(DatabaseType::SqlServer) { "N''" } else { "''" }.to_string();
|
||||
}
|
||||
// MySQL geometry columns: wrap WKT text with ST_GeomFromText()
|
||||
if is_mysql_geometry_literal_database(database_type)
|
||||
&& column_info.map(|column| is_geometry_column_type(&column.data_type)).unwrap_or(false)
|
||||
{
|
||||
let escaped = text.replace('\\', "\\\\").replace('\'', "''");
|
||||
return format!("ST_GeomFromText('{}')", escaped);
|
||||
}
|
||||
let literal_text = if database_type == Some(DatabaseType::Tdengine) {
|
||||
format_tdengine_timestamp_literal_text(&text)
|
||||
} else if is_mysql_datetime_literal_database(database_type)
|
||||
@@ -832,6 +839,35 @@ fn is_bit_column_type(data_type: &str) -> bool {
|
||||
lower.split(|ch: char| !ch.is_ascii_alphanumeric()).any(|token| token == "bit")
|
||||
}
|
||||
|
||||
fn is_mysql_geometry_literal_database(database_type: Option<DatabaseType>) -> bool {
|
||||
matches!(
|
||||
database_type,
|
||||
Some(
|
||||
DatabaseType::Mysql
|
||||
| DatabaseType::Doris
|
||||
| DatabaseType::StarRocks
|
||||
| DatabaseType::Goldendb
|
||||
| DatabaseType::Sundb
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fn is_geometry_column_type(data_type: &str) -> bool {
|
||||
let lower = data_type.to_ascii_lowercase();
|
||||
let base = lower.split('(').next().unwrap_or(&lower).trim();
|
||||
matches!(
|
||||
base,
|
||||
"geometry"
|
||||
| "point"
|
||||
| "linestring"
|
||||
| "polygon"
|
||||
| "multipoint"
|
||||
| "multilinestring"
|
||||
| "multipolygon"
|
||||
| "geometrycollection"
|
||||
)
|
||||
}
|
||||
|
||||
fn manticore_typed_attribute_value(text: &str, column_info: Option<&DataGridColumnInfo>) -> Option<Value> {
|
||||
let data_type = column_info?.data_type.to_ascii_lowercase();
|
||||
if is_boolean_type(&data_type) && text.eq_ignore_ascii_case("true") {
|
||||
|
||||
Reference in new issue
Block a user