MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_json_populate_record_function

Function test_json_populate_record_function

src/functions/json_functions.rs:2288–2325  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2286
2287 #[test]
2288 fn test_json_populate_record_function() {
2289 let conn = Connection::open_in_memory().unwrap();
2290 register_json_functions(&conn).unwrap();
2291
2292 // Test basic json_populate_record functionality
2293 let base_record = "null";
2294 let json_data = r#"{"name": "John", "age": 30}"#;
2295 let result: Option<String> = conn.query_row(
2296 "SELECT json_populate_record(?, ?)",
2297 [base_record, json_data],
2298 |row| row.get(0)
2299 ).unwrap();
2300
2301 assert!(result.is_some());
2302 let result_str = result.unwrap();
2303 assert!(result_str.contains("json_populate_record"));
2304 assert!(result_str.contains(json_data));
2305
2306 // Test with empty base record
2307 let empty_base = "";
2308 let result: Option<String> = conn.query_row(
2309 "SELECT json_populate_record(?, ?)",
2310 [empty_base, json_data],
2311 |row| row.get(0)
2312 ).unwrap();
2313
2314 assert!(result.is_some());
2315
2316 // Test with invalid JSON
2317 let invalid_json = "{not valid json}";
2318 let result: Option<String> = conn.query_row(
2319 "SELECT json_populate_record(?, ?)",
2320 [base_record, invalid_json],
2321 |row| row.get(0)
2322 ).unwrap();
2323
2324 assert!(result.is_some());
2325 }
2326
2327 #[test]
2328 fn test_json_to_record_function() {

Callers

nothing calls this directly

Calls 2

register_json_functionsFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected