fix(data): preserve jsonb numbers for metadata CAS

This commit is contained in:
ZheFox
2026-09-03 14:37:10 +08:00
parent d672ba2068
commit 979dbc4b33
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -125,7 +125,7 @@ regex = "1"
rustls = { version = "0.23", features = ["ring"] } rustls = { version = "0.23", features = ["ring"] }
semver = "1" semver = "1"
serde = { version = "1", features = ["derive"] } serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", features = ["preserve_order"] } serde_json = { version = "1", features = ["arbitrary_precision", "preserve_order"] }
serde_path_to_error = "0.1" serde_path_to_error = "0.1"
sha2 = "0.10" sha2 = "0.10"
socket2 = "0.6" socket2 = "0.6"
@@ -3671,6 +3671,17 @@ mod tests {
assert!(!sql.contains("is_active")); assert!(!sql.contains("is_active"));
} }
#[test]
fn runtime_metadata_cas_preserves_postgres_jsonb_numeric_lexemes() {
// PostgreSQL jsonb keeps the exact decimal value. Losing that lexeme while
// decoding into serde_json::Value makes a subsequent namespace CAS compare
// a nearby-but-different number and report a false conflict.
let postgres_json = r#"{"used_percent":9.373679999999995}"#;
let decoded: serde_json::Value = serde_json::from_str(postgres_json).unwrap();
assert_eq!(serde_json::to_string(&decoded).unwrap(), postgres_json);
}
#[test] #[test]
fn ordinary_key_update_does_not_own_runtime_observation_fields() { fn ordinary_key_update_does_not_own_runtime_observation_fields() {
let sql = super::KEY_UPDATE_SQL.to_ascii_lowercase(); let sql = super::KEY_UPDATE_SQL.to_ascii_lowercase();