mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-06-01 04:40:39 +00:00
fix: properly display CJK characters in table/column comments (#5633)
fix/comment-in-cjk: ### Update `OptionMap` Formatting and Add Tests - **Enhancements in `OptionMap`**: - Changed formatting from `escape_default` to `escape_debug` for better handling of special characters in `src/sql/src/statements/option_map.rs`. - Added unit tests to verify the new formatting behavior. - **Test Cases for CJK Comments**: - Added test cases for tables with comments in CJK (Chinese, Japanese, Korean) characters in `tests/cases/standalone/common/show/show_create.sql` and `show_create.result`.
This commit is contained in:
@@ -82,9 +82,9 @@ impl OptionMap {
|
||||
let mut result = Vec::with_capacity(self.options.len() + self.secrets.len());
|
||||
for (k, v) in self.options.iter() {
|
||||
if k.contains(".") {
|
||||
result.push(format!("'{k}' = '{}'", v.escape_default()));
|
||||
result.push(format!("'{k}' = '{}'", v.escape_debug()));
|
||||
} else {
|
||||
result.push(format!("{k} = '{}'", v.escape_default()));
|
||||
result.push(format!("{k} = '{}'", v.escape_debug()));
|
||||
}
|
||||
}
|
||||
for (k, _) in self.secrets.iter() {
|
||||
@@ -154,3 +154,23 @@ impl VisitMut for OptionMap {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::statements::OptionMap;
|
||||
|
||||
#[test]
|
||||
fn test_format() {
|
||||
let mut map = OptionMap::default();
|
||||
map.insert("comment".to_string(), "中文comment".to_string());
|
||||
assert_eq!("comment = '中文comment'", map.kv_pairs()[0]);
|
||||
|
||||
let mut map = OptionMap::default();
|
||||
map.insert("a.b".to_string(), "中文comment".to_string());
|
||||
assert_eq!("'a.b' = '中文comment'", map.kv_pairs()[0]);
|
||||
|
||||
let mut map = OptionMap::default();
|
||||
map.insert("a.b".to_string(), "中文comment\n".to_string());
|
||||
assert_eq!("'a.b' = '中文comment\\n'", map.kv_pairs()[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user