array_cat(array1, array2) - Concatenate two arrays
(conn: &Connection)
| 240 | |
| 241 | /// array_cat(array1, array2) - Concatenate two arrays |
| 242 | fn register_array_cat(conn: &Connection) -> Result<()> { |
| 243 | conn.create_scalar_function( |
| 244 | "array_cat", |
| 245 | 2, |
| 246 | FunctionFlags::SQLITE_UTF8 | FunctionFlags::SQLITE_DETERMINISTIC, |
| 247 | |ctx| { |
| 248 | let array1_json: String = ctx.get(0)?; |
| 249 | let array2_json: String = ctx.get(1)?; |
| 250 | |
| 251 | match ( |
| 252 | serde_json::from_str::<JsonValue>(&array1_json), |
| 253 | serde_json::from_str::<JsonValue>(&array2_json), |
| 254 | ) { |
| 255 | (Ok(JsonValue::Array(mut arr1)), Ok(JsonValue::Array(arr2))) => { |
| 256 | arr1.extend(arr2); |
| 257 | Ok(serde_json::to_string(&arr1).ok()) |
| 258 | } |
| 259 | _ => Ok(None), |
| 260 | } |
| 261 | }, |
| 262 | )?; |
| 263 | |
| 264 | Ok(()) |
| 265 | } |
| 266 | |
| 267 | /// array_remove(array, element) - Remove all occurrences of element |
| 268 | fn register_array_remove(conn: &Connection) -> Result<()> { |
no test coverage detected