fixed hierarchy null jsonb merging issue with merger when a part of the more specific hierarchy does not exist yet

This commit is contained in:
2026-08-03 16:40:26 -04:00
parent 580fa0bc9f
commit 1619ca4400
4 changed files with 23 additions and 23 deletions

View File

@ -119,7 +119,7 @@ impl SqlFormatter {
for (i, val) in val_tokens.iter().enumerate() {
let comma = if i < val_tokens.len() - 1 { "," } else { "" };
if val.starts_with("'{") && val.ends_with("}'") {
if val.starts_with("'{") && val.ends_with("}'") && val.len() > 4 {
let inner = &val[1..val.len() - 1];
// Unescape single quotes from SQL strings
let unescaped = inner.replace("''", "'");
@ -341,7 +341,7 @@ impl SqlFormatter {
}
Expr::Value(sqlparser::ast::ValueWithSpan { value: Value::SingleQuotedString(s), .. }) | Expr::Value(sqlparser::ast::ValueWithSpan { value: Value::EscapedStringLiteral(s), .. }) => {
if s.starts_with('{') && s.ends_with('}') {
if s.starts_with('{') && s.ends_with('}') && s.len() > 2 {
if let Ok(json) = serde_json::from_str::<serde_json::Value>(s) {
if let Ok(pretty) = serde_json::to_string_pretty(&json) {
let lines: Vec<&str> = pretty.split('\n').collect();